Repository navigation
optimize perfermance of fd_read/fd_write - #8303
Conversation
ce78858 to
adee567
Compare
alexcrichton
left a comment
There was a problem hiding this comment.
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-readcan 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 deletingHostInputStreamintoWasiView, and the cost of accessing guest memory(merged PR);This PR is mainly optimized for the first type of performance hotspot:
HostInputStreamintoWasiView;The perfermance hotspots of
fd_writeis the samefd_read:wasmtime/crates/wasi/src/preview1.rs
Line 1682 in 86dcae4
wasmtime/crates/wasi/src/preview1.rs
Line 244 in 86dcae4