Repository navigation
sort: add wasi support for merge operations - #16689
eduardomourar wants to merge 2 commits into
Conversation
|
thanks for the patch! |
| /// WASI has no `getrlimit`; guess a conservative limit instead of `None`, so | ||
| /// `--batch-size`/merge stay bounded on wasmtime's often-smaller fd table. | ||
| #[cfg(target_os = "wasi")] | ||
| #[allow(clippy::unnecessary_wraps)] |
There was a problem hiding this comment.
please avoid the #[allow], and where does 256 come from?
There was a problem hiding this comment.
I made the modification accordingly. I am not too happy with it visually. If this was not what you had in mind, please propose the way in the code concretely so I can learn for next time.
|
Binary size comparison: |
f2d23b7 to
162ed9a
Compare
|
GNU testsuite comparison: |
| /// `carry_over` once it has reported `false`; calling it again would | ||
| /// misparse that padding as a spurious extra chunk, so this must be | ||
| /// checked instead of only looking at whether a chunk was sent. | ||
| finished: bool, |
There was a problem hiding this comment.
please make the comments shorter (same for recycled)
| files: F, | ||
| settings: &GlobalSettings, | ||
| ) -> UResult<FileMerger<'_, M>> { | ||
| let separator = settings.line_ending.into(); |
There was a problem hiding this comment.
the threaded path sets fast_locale_collation = false before reading, shouldn't we do the same here?
| #[cfg(target_os = "wasi")] | ||
| impl<M: MergeInput> FileMerger<'_, M> { | ||
| /// Write the merged contents to the output file. | ||
| fn write_all(self, settings: &GlobalSettings, output: Output) -> UResult<()> { |
There was a problem hiding this comment.
write_all / write_all_to are almost the same in both impls, could they be shared too?
|
thanks for the work on this! |
sort -m spawns an OS thread per merge batch to overlap reading and sorting. WASI has no real threads, so this panicked into an
unreachabletrap instead of a usable error, and every affected merge test was skipped under WASI.Add a synchronous
target_os = "wasi"merge and--checkpath that reads chunks on the calling thread instead of handing them to a reader thread, reusing the same chunk-parsing code. Also tighten--batch-sizehandling: WASI has nogetrlimit, so it now assumes a conservative fd limit instead of treating merge batch size as unbounded.Addresses the
sort -mhalf of #16599 (dd's thread spawn is a separate issue).🤖 Generated with Claude Code