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

Improve CLI performance by serializing pregenerating data at build time that can deserialized during runtime #323

Closed
bbottema opened this issue Jun 12, 2021 · 3 comments
Assignees
Milestone

Comments

@bbottema
Copy link
Owner

bbottema commented Jun 12, 2021

The way CLI support works is that each time the Main method is invoked, Simple Java Mail builds up the entire CLI command tree that can be invoked. This is a time consuming action and delays and command line execution by many seconds.

Instead, it would be great if we could generate it before each release, serialize the result to a file and deserialize that instead each time. That would make CLI commands execute near instantly.

@bbottema bbottema added this to the 7.0.0 milestone Jun 12, 2021
@bbottema bbottema self-assigned this Jun 12, 2021
@bbottema
Copy link
Owner Author

bbottema commented Jun 19, 2021

I've implemented a solution that covers part of the problem, by serializing a CLI tree state snapshot using Kryo to file and reading it back instead of recreating the tree from scratch. This improves performance by about 25%.

I'm still looking into further optimization, because a lot of performance is lost by the therapi library, which provides Javadoc in runtime (which is used to fuel the CLI commands/options documentation).

@bbottema
Copy link
Owner Author

I've also implemented a serialized cache now that maps lookups from Method to their resolved MethodJavadoc therapi counterpart.

Total runtime has not been reduced to maybe 10-20% of the old runtime. On my heavy duty dev laptop it took 4 seconds to start executing from CLI, which is now takes mere milliseconds. Huge performance increase from the command line.

@bbottema bbottema changed the title Pregenerate CLI commands for each release and serialize and deserialize instead of generating in runtime Improve CLI performance by serializing pregenerating data at build time that can deserialized during runtime Jun 19, 2021
bbottema added a commit that referenced this issue Jun 29, 2021
… snapshot as serialized data (using Kryo) and reading that back instead of rebuilding the tree from scratch (saves 1 seconds or roughly 25% of total time)
bbottema added a commit that referenced this issue Jun 29, 2021
…instances in addition to the previous CLI tree snapshot serialized data file. These cache data files are generated during package phase and included in the CLI artifact zips in the classpath folder. [skip ci]
@bbottema
Copy link
Owner Author

bbottema commented Jan 2, 2022

7.0.0 just released with this improvement.

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

1 participant