-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
optimize perfermance of fd_read/fd_write #8303
Conversation
ce78858
to
adee567
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR!
I've left some notes below, but I'll additionally point out that this is specifically ignoring the blocking_mode
now. Previously that was "respected" to a certain degree, but now it's being ignored. I believe that's ok because that's what the previous implementation in wasi-common did anyway as OSes tend to ignore nonblocking on files. That being said the current state of the code is a bit confusing where the blocking_mode
is sometimes used and sometimes isn't.
I mostly wanted to point this out in case anyone runs into this in the future. I'll follow up with a PR after this one to clean this up. You don't have to clean it up here yourself @liutao-liu
d978cc4
to
cf7dfd6
Compare
cf7dfd6
to
1cf2a9c
Compare
@alexcrichton Your review comments have been completed,this pr can be merged. |
* Explicitly document why `blocking_mode` is being ignored. * Don't write-in-a-loop to doing a partial write and then returning an error. * Spawn a background read/write when the embedding cannot block the current thread. * Don't panic on overflows for addition. Follow-ups to bytecodealliance#8303
* Explicitly document why `blocking_mode` is being ignored. * Don't write-in-a-loop to doing a partial write and then returning an error. * Spawn a background read/write when the embedding cannot block the current thread. * Don't panic on overflows for addition. * Fix panic on reads with shared memory Follow-ups to bytecodealliance#8303
* Explicitly document why `blocking_mode` is being ignored. * Don't write-in-a-loop to doing a partial write and then returning an error. * Spawn a background read/write when the embedding cannot block the current thread. * Don't panic on overflows for addition. * Fix panic on reads with shared memory Follow-ups to #8303
Compared to native(C/C++),
fd-read
can only reach 20% of native. I will divide the performance hotspots into the following two categories:,fd-read
(approximately 30% of the hotspots), such as the cost of redundant memory copies, the cost of inserting and deletingHostInputStream
intoWasiView
, and the cost of accessing guest memory(merged PR);This PR is mainly optimized for the first type of performance hotspot:
HostInputStream
intoWasiView
;The perfermance hotspots of
fd_write
is the samefd_read
:wasmtime/crates/wasi/src/preview1.rs
Line 1682 in 86dcae4
wasmtime/crates/wasi/src/preview1.rs
Line 244 in 86dcae4