Skip to content

Conversation

@tompng
Copy link
Member

@tompng tompng commented Dec 2, 2024

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{}}`
Copy link
Member

@ima1zumi ima1zumi left a comment

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
40 checks passed
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