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

[WIP] Replace HK2/Types/Parser/Scanner with Jandex and cache in the domain #7165

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

lprimak
Copy link
Contributor

@lprimak lprimak commented Jan 21, 2025

Deploy performance improvements

This is an experiment (for now)

Currently, it's not certain how much performance improvements are achieved by this PR.
In the next few weeks, I would like to do some testing on exactly how much performance gains are achieved.
I am hoping that the PR will achieve orders-of-magnitude performance increase.

Payara can be run in Docker with --cpus argument to give it fractional CPUs to simulate
a slow machine and long deploy times.
My issue is that my computer is too fast to compare deploy performance currently,
and I would need to overcome that issue.

Feedback is appreciated

Thank you.

Current (very preliminary) results

Currently, performance is only slightly improved for cached runs,
but slightly degraded for first-time deployments.
This is probably due to not-yet-implemented parallel scanning of dependencies.

Fixes #7079

Important info

This PR depends on #7032 and #7097 until that gets merged.

  • Save jandex to transient metadata
  • Refactor HK2-Types stuff in WeldUtils into separate file
  • Use Jandex in addition to Types in WeldUtils (get jandex-based WAR to deploy) - ignoring dependencies for now
  • How does Scanner / Parser parse war-libraries? - what's the calling flow? - in ApplicationLifecycle (kernel)
  • Save / cache Types or use Jandex for dep libs? - Jandex
  • Index (via Jandex)
  • Index via Jandex - WAR dependencies
  • Restore shared WARlib functionality
  • Cache Jandex indexes in the domain - file cache on disk
  • Load Jandex from cache, if exists
  • Does old scanner get invoked for WARlibs? - No, scanner doesn't get invoked for warlibs
  • DOL Factory using Jandex
  • WarScanner using Jandex
  • EAR support (DOL module, etc)
  • Do not cache -SNAPSHOT dependencies
  • DOL: remove handler stack, make it no-op
  • Sync w/main branch
  • Profile the code, see where the bottlenecks actually are
  • Check default context push / pop
  • Re-introduce parallel scanning. Hopefully causes much more performance improvement
  • Delay writing jandex cache to disk until after deployment
  • Check for ClassLoader leaks
  • Check new SpringBoot-related code and remove types from there / cc: @Pandrex247
  • Remove AnnotationClassModel and use Jandex-based model directly
  • Check old lifecycle to see if anything is missing that needs to be restored
  • Remove APF/hk2 folders (old lifecycle)
  • Code cleanup
  • Get tests to pass again

@lprimak lprimak changed the title [WIP] Replace HK2/Types with Jandex and cache in the domain [WIP] Replace HK2/Types/Parser/Scanner with Jandex and cache in the domain Jan 21, 2025
void index(DeploymentContext deploymentContext) throws IOException;
void reindex(DeploymentContext deploymentContext) throws IOException;
boolean isJakartaEEApplication(DeploymentContext deploymentContext) throws IOException;
Index getRootIndex(DeploymentContext deploymentContext);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might want to avoid spreading the JBoss classes like i.e. Index around in the Payara codebase.

Copy link
Contributor Author

@lprimak lprimak Jan 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Index is kinda the whole point of this PR.
The issue is that current annotation scanning framework is not made for CDI, is slow, and can't be cached.
Jandex is a small, separate project, has no dependencies, and is tailor made for CDI.
While it did come from JBoss, it's no longer embedded in that ecosystem and can be used unencumbered.

Any effort to isolate Index class will result in an unnecessary wrapper that would not add any value.

Do you have a specific suggestion? Am I missing something?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would result in a wrapper class. I agree. But I would call it a useful one. It allows to control and limit the interface towards payara code and allows to switch technology if needed/wanted.

Copy link
Contributor

@svendiedrichsen svendiedrichsen Jan 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And you could have convenience methods useful for payaras interaction with the index.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's see where this goes... I think it's only used in one place anyway

@lprimak
Copy link
Contributor Author

lprimak commented Feb 2, 2025

Currently, performance is same or better, so primary goal looking good.

@lprimak lprimak force-pushed the jandex-deploy branch 5 times, most recently from bdfa809 to aa27959 Compare February 12, 2025 00:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enhancement: Payara should use Jandex to speed up CDI deployments
2 participants