Skip to content

Reduce the number of host calls when logging#279

Merged
jeffcharles merged 4 commits into
mainfrom
jc.reduce-hostcall-invocations
Mar 14, 2023
Merged

Reduce the number of host calls when logging#279
jeffcharles merged 4 commits into
mainfrom
jc.reduce-hostcall-invocations

Conversation

@jeffcharles
Copy link
Copy Markdown
Collaborator

While investigating something related to failures when calling console.error, I noticed our current implementation is making more host calls than necessary when writing logs. Each call to write on stream will invoke a host call since writes to the stderr stream are not buffered.

This change ensures we only make one one host call when invoking console.error which should improve runtime performance.

Comment thread crates/core/src/globals.rs Outdated
@saulecabrera
Copy link
Copy Markdown
Member

which should improve runtime performance.

I think we should run some benchmarks as part of this change to have a concrete idea of the improvements that we're referring to here.

Copy link
Copy Markdown
Contributor

@jianghong jianghong left a comment

Choose a reason for hiding this comment

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

Nice find

@jeffcharles
Copy link
Copy Markdown
Collaborator Author

Added a benchmark, I'm seeing a 9% to 17% improvement for 100 console.error calls with multiple arguments

@jeffcharles jeffcharles merged commit 0d02b87 into main Mar 14, 2023
@jeffcharles jeffcharles deleted the jc.reduce-hostcall-invocations branch March 14, 2023 13:12
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.

3 participants