-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support key stroke in trap key #332
Conversation
@@ -1,8 +1,59 @@ | |||
class Reline::KeyStroke | |||
using Module.new { | |||
refine Integer do | |||
def ==(other) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we achieve this another way? Redefining ==
on integer (even in a refinement) will clear BOP_EQ for integers, making all comparisons slower.
ie. This optimization in MRI will no longer work https://github.com/ruby/ruby/blob/master/vm_insnhelper.c#L1986-L1987
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Terminal control software often spends more than 99% of its processing time displaying characters to the terminal. Do you have any performance measurement results that show that key processing is the bottleneck and should be improved?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry. The issue isn't in reline's processing, but that this will make Ruby's integer comparisons slower globally. All code will be slower, not just reline.
Here's a hacky demonstration benchmark on latest Ruby trunk:
jhawthorn@zergling:~/src/ruby (int_bop ) [ruby 3.1.0]
$ ruby -r 'benchmark' -e 'p Benchmark.realtime { 10_000_000.times { 1==1;1==1;1==1;1==1;1==1;1==1;1==1;1==1;1==1;1==1 } }'
1.1078672040021047
jhawthorn@zergling:~/src/ruby (int_bop ) [ruby 3.1.0]
$ ruby -r 'benchmark' -rreline -e 'p Benchmark.realtime { 10_000_000.times { 1==1;1==1;1==1;1==1;1==1;1==1;1==1;1==1;1==1;1==1 } }'
4.35402021300979
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will make Ruby's integer comparisons slower globally.
Thanks for the concise and clear explanation. I now understand the problem. It looks like binding.irb
is going to cause serious problems in Rails applications.
Please wait a bit while we work on it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#347
I did it. I think this problem was pretty bad. I'm glad I could handle it. Thanks again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change looks great! Thank you for looking into this.
No description provided.