Skip to content
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

Integrate 'Coordinated Restore at Checkpoint' #1197

Open
abelsromero opened this issue May 4, 2023 · 5 comments
Open

Integrate 'Coordinated Restore at Checkpoint' #1197

abelsromero opened this issue May 4, 2023 · 5 comments

Comments

@abelsromero
Copy link
Member

There's an experimental feature to save and restore the state of the JVM that helps to improve startup.
Since one of our main pain points is the initial parsing of the gem which takes most of the time when converting a single document, this could be a great improvement.

References:

I know that I am not the first to think about it /cc @someth2say

@someth2say
Copy link

Yes!
In my current daywork we are already using AppCDS, that is a "lightweight" version of CRaC.
AppCDS stores the statically initialized classes when the application shuts down, so it shaves a few seconds from initializing JRuby.
But, AFAIK, AppCDS does not store information about the dinamically generated classes, so the benefit is limited.

CRaC works a bit differently: It stores the whole status of the JVM.
So CRaC will definitelly boost the startup.
But with CRaC, it is the developer who decides when and where (file) to create the checkpoint.

So this arises two questions in my mind:

  1. Can AsciidoctorJ decide when to create the checkpoint. I don´t think so, as that is a stop-the-world action.
    If we want to go this way, we probably need to add an extension API for devs to be able to decide the moment.
  2. Where do we create the checkpoint (in the FS)? I am not sure if we are already using some kind of starndard place to save things (maybe XDG Base Directory Specification?), but in any case I feel messing with host FS a bit off.

@abelsromero
Copy link
Member Author

abelsromero commented May 8, 2023

So this arises two questions in my mind:

This is a research story more than anything 💡
My first idea was creating a snapshot around RubyGemsPreloader::preloadRequiredLibraries which parses the gems and we know it's the main culprit of slow startup and see if it improves anything. Then, if it works, we could bundle any extra file in the jar and load it from the classpath.
We'd need to upgrade the snapshot on every asciidoctor Ruby gem upgrade only.

@abelsromero
Copy link
Member Author

Another article on the topic for reference https://openliberty.io/blog/2023/09/26/spring-boot-3-instant-on.html

@someth2say
Copy link

Nice one.
Sadly, it seems that only a few Java implementations support CrAC: OpenLiberty, Eclipse and Zulu. OpenJDK has also a variant that supports CrAC, but not in the main stream.

@abelsromero
Copy link
Member Author

Another article on the topic https://spring.io/blog/2023/10/16/runtime-efficiency-with-spring. Nothing relevant though, only interesting to see that it's being adopted, even if in early builds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants