Improve prompt generating performance by caching prompt parts(%m, %M)#1127
Merged
tompng merged 3 commits intoruby:masterfrom Oct 24, 2025
Merged
Improve prompt generating performance by caching prompt parts(%m, %M)#1127tompng merged 3 commits intoruby:masterfrom
tompng merged 3 commits intoruby:masterfrom
Conversation
cd56ed4 to
fdea403
Compare
In prompt calculation, `main.to_s` was called on every keystroke and every line in multiline input. Cache prompt parts(%m, %M) so that `main.to_s` is only called once per read-eval cycle.
fdea403 to
35eb9e2
Compare
st0012
reviewed
Oct 18, 2025
lib/irb.rb
Outdated
| end | ||
|
|
||
| def readmultiline | ||
| @prompt_part_cache = {} |
Member
There was a problem hiding this comment.
I think we can create a wrapper to ensure wherever we can generate prompt we have this set and cleaned. Like
with_prompt_part_cached do
...
end
st0012
approved these changes
Oct 22, 2025
Co-authored-by: Stan Lo <stan001212@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1126
In prompt calculation,
main.to_swas called on every keystroke and every line in multiline input.Cache prompt parts(
%mand%M) so thatmain.to_sis only called once per read-eval cycle.Also fixes this problem.