Skip to content

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

Closed

Description

@bbottema

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.

Activity

  1. added this to the 7.0.0 milestone on Jun 12, 2021
  2. self-assigned this
    on Jun 12, 2021
  3. bbottema commented on Jun 19, 2021

    @bbottema
    OwnerAuthor

    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).

  4. bbottema commented on Jun 19, 2021

    @bbottema
    OwnerAuthor

    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.

  5. 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[/+] on Jun 19, 2021
  6. added 3 commits that reference this issue on Jun 29, 2021
  7. bbottema commented on Jan 2, 2022

    @bbottema
    OwnerAuthor

    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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions