编辑文本时,Rails控制台运行速度非常慢 [英] Rails console running incredibly slowly when editing text

查看:135
本文介绍了编辑文本时,Rails控制台运行速度非常慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的一个rails应用程序,控制台开始运行真的很慢,当我粘贴文本,类型和(特别是)删除文本。我可以看到在顶部,irb是使用大量的cpu。但我不知道如何诊断这个问题任何进一步。它刚刚开始发生几个星期前。我想知道如果它可能是readline / wirble相关?我使用这两个。

In one of my rails apps, the console has started running really slowly when i paste in text, type and (especially) delete text. I can see in top that irb is using lots of cpu. But i don't know how to diagnose this problem any further. It just started happening a couple of weeks ago. I'm wondering if it's possibly readline/wirble related? I use both of those.

我刚刚在另一个应用程序中尝试,粘贴在一个文本块,它似乎只是同样坏 - 文本是以速率的一个char一秒!也许我的命令行历史已经填满了什么?如何删除它? (对于rails控制台,而不是我的bash命令行历史记录)

I just tried it in another app, pasting in a block of text, and it seems just as bad - the text is appearing at the rate of one char a second! Maybe my command line history has filled up or something? How can i delete it? (for the rails console, not my bash command line history)

感谢任何建议 - max

grateful for any advice - max

- 对不起,应该提供一些系统细节。这里你去:

Edit - sorry, should have supplied some system details. Here you go:

System - Ubuntu 10.04
Ruby version - ruby 1.8.6 (2007-09-24 patchlevel 111) [i486-linux]



我刚刚尝试过纯irb,我有同样的问题。它可能会更慢,它通过我粘贴的文本块中途停下来测试它。

I just tried plain irb and i have the same problem. It might even be slower, it's pretty much ground to a halt halfway through the block of text i pasted in to test it.

我重新启动了很多次(我的笔记本电脑电池是诀窍,所以我必须重新启动,每次我拔下它反正)。

I've rebooted many times (my laptop battery is knackered so i have to restart every time i unplug it anyway).

我不在vm。

我最近开始使用RVM(ruby版本管理器),它似乎与此同时发生,虽然它可能只是一个巧合。有问题的控制台正在使用系统ruby,但不是rvm。

I have recently started using RVM (ruby version manager) and it seems to have coincided with that, though it might just be a coincidence. The problematic consoles are happening using system ruby, though, not an rvm.

以下是 ps aux的输出结果: grep irb

max      12583  0.0  0.0   1756   484 pts/7    S+   Apr11   0:00 sh -c irb  -r irb/completion -r "/home/max/work/rails_apps/millionaire_container/millionaire/config/environment" -r console_app -r console_with_helpers --simple-prompt
max      12584 15.9  2.7  61872 56956 pts/7    S+   Apr11 158:26 irb                                                                                                                                                                                     
max      13981 64.4  0.9  20080 18708 pts/9    R+   09:40  29:51 irb                          
max      14625 21.8  0.6  15020 12628 pts/12   Rl+  10:25   0:20 irb                                             
max      14757  0.0  0.0   3048   804 pts/13   R+   10:27   0:00 grep --color=auto irb


推荐答案

看起来rvm的readline是导致缓慢,把这行在你的〜/ .irbrc:

It seems like rvm's readline is causing the slowness, put this line in your ~/.irbrc:

IRB.conf[:USE_READLINE] = false

在irb上的东西。是快吗?很好!

Now try pasting something on irb. Is it fast? Good!

现在只有问题是你失去了编辑线条的能力。我们需要修复rvm的readline。

Only problem now is that you've lost the ability to edit your lines. We need to fix rvm's readline.

# assuming 1.8.6 is your rvm's default ruby version
rvm package install readline
rvm remove 1.8.6
rvm install 1.8.6 --with-readline-dir=$rvm_path/usr

不要忘记从irbrc编辑出IRB.conf行。

Don't forget to edit out the IRB.conf line from your irbrc.

这篇关于编辑文本时,Rails控制台运行速度非常慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆