You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently when IRB outputs something with a large amount of data such as MyRecord.all in Rails it will pause for a long time and then dump everything to the screen at once. This can be a bit of a pain when coming from Pry where it comes with a pager that will instantly return and allow the user to navigate around in the data.
You can reproduce this wait with...
> [1] * 1_000_000
I was wondering if IRB could add a pager similar to Pry. If so, I'd be happy to explore it but also don't want to step on any toes if this is a no go.
I gave it a try but unfortunately simply paging the result won’t solve the issue. The slowness comes from IRB using ColorPrinter.pp to generate the inspected value string all at once. And value inspection behavior is customisable in IRB so it’s not something we can easily change.
That being said, paging the generated long string itself doesn’t seem difficult to achieve. Do you think if we implement only that part for now will already help? Or the main concern is just the rendering speed?
That is unfortunate. The rendering speed is definitely the main issue, but there is still significant value in the pager.
For instance, I regularly use the pager in Pry to find text (this feature especially) or scroll back-and-forth using the vim keybindings. Basically it makes navigating large chunks of output so much easier. That being said, if it makes its way into IRB that would be amazing.
And value inspection behavior is customisable in IRB so it’s not something we can easily change.
So when you say it is customizable, does that mean it can be disabled through configuration (e.g., like an environment variable)?
So when you say it is customizable, does that mean it can be disabled through configuration (e.g., like an environment variable)?
Yes, you can configure it with IRB.conf[:INSPECT_MODE] in your .irbrc. Here's a list of default inspectors in IRB. But you can also define your own with the same APIs.
I think to dramatically improve the speed in your example input, setting it to IRB.conf[:INSPECT_MODE] = :to_s # or :raw or false should do the trick.
What do you think about adding a timeout to the coloring process? I've sent a patch for that in #759 .
Nonetheless, pager support would be a super great feature for me, regardless of coloring! Sometimes I have to scroll back 1000+ lines when I inspect large ActiveRecord query results; pagers would help a lot there.
I'm closing this now as pager support for evaluation result has been implemented in #784 and there's no good way to get around slow value inspection at the moment.
Activity
st0012 commentedon May 23, 2023
I gave it a try but unfortunately simply paging the result won’t solve the issue. The slowness comes from IRB using
ColorPrinter.ppto generate the inspected value string all at once. And value inspection behavior is customisable in IRB so it’s not something we can easily change.That being said, paging the generated long string itself doesn’t seem difficult to achieve. Do you think if we implement only that part for now will already help? Or the main concern is just the rendering speed?
nickjer commentedon May 23, 2023
That is unfortunate. The rendering speed is definitely the main issue, but there is still significant value in the pager.
For instance, I regularly use the pager in Pry to find text (this feature especially) or scroll back-and-forth using the vim keybindings. Basically it makes navigating large chunks of output so much easier. That being said, if it makes its way into IRB that would be amazing.
So when you say it is customizable, does that mean it can be disabled through configuration (e.g., like an environment variable)?
[-]Add a pager due to long waits[/-][+]Add a pager to evaluation result[/+]st0012 commentedon Nov 8, 2023
Sorry for the long delay.
Yes, you can configure it with
IRB.conf[:INSPECT_MODE]in your.irbrc. Here's a list of default inspectors in IRB. But you can also define your own with the same APIs.I think to dramatically improve the speed in your example input, setting it to
IRB.conf[:INSPECT_MODE] = :to_s # or :raw or falseshould do the trick.osyoyu commentedon Nov 13, 2023
What do you think about adding a timeout to the coloring process? I've sent a patch for that in #759 .
Nonetheless, pager support would be a super great feature for me, regardless of coloring! Sometimes I have to scroll back 1000+ lines when I inspect large ActiveRecord query results; pagers would help a lot there.
st0012 commentedon Dec 17, 2023
I'm closing this now as pager support for evaluation result has been implemented in #784 and there's no good way to get around slow value inspection at the moment.