Skip to content
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

perf: add BufWriter to Stderr to avoid frequent system calls and increase rendering frame rate #849

Merged
merged 1 commit into from
Mar 29, 2024

Conversation

sxyazi
Copy link
Owner

@sxyazi sxyazi commented Mar 29, 2024

Resolves an issue reported by @DreamMaoMao on Yazi's Discord server, https://discord.com/channels/1136203602898194542/1136203604076802092/1223142137860984943


This PR fixes a performance regression introduced by the latest main branch. Recently, Yazi switched from stdout to stderr, but since stderr is unbuffered (previously stdout was line-buffered, i.e. LineWriter), this change caused a decrease in rendering frame rate.

This PR adds a block buffer ( BufWriter) to stderr, while solving this performance regression, it theoretically can further improve performance - this is an example comparing LineWriter and BufWriter, https://github.com/orhun/rust-stdout-vs-stderr

stdout-vs-stderr-detailed

(Image source: https://github.com/orhun/rust-stdout-vs-stderr)

@sxyazi sxyazi merged commit 66d12da into main Mar 29, 2024
5 checks passed
@sxyazi sxyazi deleted the pr-728f2658 branch March 29, 2024 07:40
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant