Skip to content

Implement buffered output to Reline::ANSI - #790

Merged
ima1zumi merged 1 commit into
ruby:masterfrom
tompng:stdout_buffering
Dec 2, 2024
Merged

ima1zumi merged 1 commit into
ruby:masterfrom
tompng:stdout_buffering

Conversation

@tompng

@tompng tompng commented Dec 2, 2024

Copy link
Copy Markdown
Member

Rendering gets slow after you enter Thread.new{loop{}} to IRB.
Every STDOUT.write call seems to pass execution to the cpu bound thread, making rendering slow.
Minimizing the number of STDOUT.write call will improve it.

Before
https://github.com/user-attachments/assets/b34dd1f2-bb79-4373-88d5-353fda2fe3bf

After
https://github.com/user-attachments/assets/a33f2e01-2591-4d45-84f5-6f43d1a067da

While trying Thread.new{loop{}}, be careful not to press TAB key. Loading RDoc document will hang up.

Minimize the call of STDOUT.write
This will improve rendering performance especially when there is a busy thread `Thread.new{loop{}}`

@ima1zumi ima1zumi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@ima1zumi
ima1zumi merged commit a6fe45f into ruby:master Dec 2, 2024
matzbot pushed a commit to ruby/ruby that referenced this pull request Dec 2, 2024
(ruby/reline#790)

Minimize the call of STDOUT.write
This will improve rendering performance especially when there is a busy thread `Thread.new{loop{}}`

ruby/reline@a6fe45f5ba
@tompng
tompng deleted the stdout_buffering branch December 2, 2024 17:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants