Opportunistic CoW for platforms that support it#669
Merged
jaybosamiya-ms merged 3 commits intomainfrom Mar 2, 2026
Merged
Conversation
18b9116 to
fe79cd5
Compare
fe79cd5 to
d03cf6a
Compare
Member
|
I think @CvvT should review this PR. |
CvvT
reviewed
Feb 21, 2026
Contributor
CvvT
left a comment
There was a problem hiding this comment.
Thanks for the change! I have a few questions.
CvvT
approved these changes
Feb 24, 2026
CvvT
approved these changes
Feb 24, 2026
|
🤖 SemverChecks 🤖 No breaking API changes detected Note: this does not mean API is unchanged, or even that there are no breaking changes; simply, none of the detections triggered. |
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 LiteBox performance by shaving off ~65% of our execution time by introducing opportunistic CoW:
Concretely, this PR introduces a new platform interface to
PageManagementProvidercalledtry_allocate_cow_pages. This defaults toUnsupportedByPlatform, but any platform that has the ability to support copy-on-write page allocation can override this method in order to automatically obtain improved performance.The improved performance itself comes from
mmapin the Linux shim, where file-based mapping can be sped up.This is not a trivial "pass through" since the files inside LiteBox need not correspond to files on the host (so even for Linux-on-Linux, there is work that must be done). This motivates the actual design of
try_allocate_cow_pagesthat I've chosen, which is closer to a memcpy-like interface, rather than anything file-oriented. Platforms that have file-oriented support for it are welcome to keep those platform-specific details to themselves. What this means is thatmmapon the shim actually first looks up the file, then it checks to get a backing store memory of it; if one exists, then a CoW is attempted, at which point the platform itself does the lookup of the file (on Linux platform) and decides to make a CoW map of the page.Currently, the biggest gains for us come from the actual ELF load time, since that is all that I have set up as supporting CoW for now (it was our biggest bottleneck; thus the 65% savings in execution time). However, now that the core framework has been set up by this PR, future PRs should more easily be able to unlock performance wherever CoW might help.
There are some small bits I am not yet fully happy with the PR that I've marked with
TODO(jb)etc., for example, it'd be good to store pre-loaded FDs rather than constantly opening/closing them. However, that can/will be handled in a future PR.