buffer more reads from a boot-file file descriptor #769
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.
Before:
After:
The overall difference in startup time turns out to be very small on Linux and macOS — just a a couple of milliseconds, if anything. But buffering is generally a good idea, and the change makes a startup system-call trace look less suspicious. (See, for example, the discussion in #263.)
I tried this kind of change a couple of times before over the years, but the result always seemed like too much for little benefit. This time, I found a path that involves fewer changes, involves simpler local changes that are easier to check through a diff, and tends to make the code nicer (collapsing two
uptr
decodings into one) instead of more complicated; so, I think it's worthwhile.In addition to buffering changes, this commit adds
Sregister_boot_file_bytes
, so that an embedding application can point to bytes that are already loaded into memory. I experimented with that by linking a program with-sectcreate
on macOS and usinggetsectiondata
to find embedded boot files at run time. It doesn't make startup any faster, but that kind of approach might be useful for tools that create a single-file executable including boot files.