Optimize file reads in fs module#1071
Open
joseluisq wants to merge 4 commits intoseanmonstar:masterfrom
Open
Conversation
By implementing a file stream and prefering std::fs::File instead of its tokio async variant, the fs module performance improves significantly when reading files resulting in ~79% more req/sec using ~57 less memory in Linux. A similar result should also be expected in Unix targets.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR improves the performance of
fsmodule when reading files in particular for the file stream implementation.By refactoring the
fsfile stream and preferringstd::fs::Fileinstead of its tokio async variant, thefsmodule performance improves significantly when doing file io reads resulting in~79%more req/sec using~57%less memory in Linux (according to my tests). However, a similar result should also be expected in Unix targets.Results
Here is a generic benchmark in Linux just to illustrate.
The
examples/file.rswas used in the tests.Basically,
~79.33%more requests per second utilizing~57.14%less memory.Context
Below I highlight a quote from the Tokio website talking about Linux
io_uringsupport which I think is self-explanatory.Credits
Not all are mine, there are other people involved in making this possible like the https://github.com/weihanglo/sfz project (inspiration) as well as contributors to SWS.
--
We're enjoying this optimization in SWS so that's why I share it with the warp folks too 😅.
Let me know what are your thoughts on this.