-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
8349713: [leyden] Memory map the cached code file #34
Conversation
👋 Welcome back shade! A progress list of the required criteria for merging this PR into |
@shipilev This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 1 new commit pushed to the
Please see this link for an up-to-date comparison between the source branch of this pull request and the As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@vnkozlov, @iklam) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
It demonstrably improves performance on Linux, kicking out the 30ms out of critical startup path.
|
Webrevs
|
Does the numbers still holds with
before the benchmark (single shot) run? |
Yes, they do, and there is a good reason why: without caches, the hit on the critical startup path is even worse, even with a modern SSD. And AFAIU, file-backed mmap does play well with I/O caches too. Observe:
|
Current GHA failures should be fixed by #35. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good. Until, as we discussed, cached code (and its data) will be part of CDS archive file.
How CDS handles mmap
on windows?
Yes, that would make this whole thing no-op. CDS mmap-s the archive already.
Windows can still memory-map the file through its Windows APIs. But I vaguely recollect some corner cases that @iklam fights every so often in CDS. Something with remapping or so? See |
With the Windows APIs used by HotSpot today (VirtualAlloc and MapViewOfFile), we can't map a file into a reserved region. If we just want to mmap the SCCache into non-reserved, random location that's picked by the OS, we can already do that today with HotSpot. In some cases, CDS wants to mmap into reserved regions. On Windows, we end up not mapping with MapViewOfFile, but simply reading the entire CDS file into reserved memory. I think with this new API MapViewOfFile3, we can map into a reserved region. This would be useful if, for example, we want the SCCache to be immediately next to CDS, so that the AOT code can use relative addressing for metadata pointers (InstanceKlass*, etc). |
OK, great. AFAICS, this technically allows us to do Still, I think it is a bit saner to keep doing mmap-ing only on Linux, if only to test that non-mmap path works and not force us to debug Windows mmap issues in Leyden prototype. But I don't feel strongly about this. Opinions welcome! |
Any other opinions about this? I would like to integrate this to reap some startup benefits :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this looks fine. The change is small, so we can update or remove it when migrating the SCCache into CDS.
@vnkozlov what do you think?
Yes, that is the plan. |
I think this PR would be superseded by @ashu-mehra's #39. We can still do it ahead of #39. |
@shipilev I am fine with merging this as is. |
This reverts commit 2f884d8.
All right, the flag stays for a while. Once Ashu moves this whole thing to CDS, we can remove the flag. Meanwhile, we only do mmap on Linux. I think we are ready to integrate this. |
/integrate |
/sponsor |
It is visible in profiles for lots of applications that reading the SC cache file at startup costs significantly. On JavacBenchApp example, loading ~25M code requires about 30ms. This is ~1 GB/sec, so it is I/O limited.
We should really mmap the SC cache file to alleviate these costs. Let the actual SC readers (separate threads) to eat the cost of reading from the backing file.
I was not entirely sure COW for file mappings works correctly on Windows, so I excepted that one.
Additional testing:
runtime/cds
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/leyden.git pull/34/head:pull/34
$ git checkout pull/34
Update a local copy of the PR:
$ git checkout pull/34
$ git pull https://git.openjdk.org/leyden.git pull/34/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 34
View PR using the GUI difftool:
$ git pr show -t 34
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/leyden/pull/34.diff
Using Webrev
Link to Webrev Comment