-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Speedup Hibernate ORM's enhancement of large models #40329
Conversation
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.
Thanks!
Seems safe to me, and it's great if it speeds things up so much, but could you please add a few comments? I'm afraid it's not as obvious for us as it is for you :)
...t/src/main/java/io/quarkus/hibernate/orm/deployment/integration/QuarkusClassFileLocator.java
Outdated
Show resolved
Hide resolved
...src/main/java/io/quarkus/hibernate/orm/deployment/integration/QuarkusEnhancementContext.java
Outdated
Show resolved
Hide resolved
...rm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateEntityEnhancer.java
Outdated
Show resolved
Hide resolved
Updated to add the suggested comments; also now registering the Panache super types as "core types" so they'd also benefit from caching, if used. |
Note to self: this implies that if we have live-reload tests in Panache which have entities using the same package name as Panache itself they might fail now for the silly reason of us skipping the work on such classes. |
...rm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateEntityEnhancer.java
Outdated
Show resolved
Hide resolved
c51be54
to
e1bb761
Compare
We decided to use: TODO: check this doesn't break Panache integration tests as they might be running under the same package name. |
Rebased: simplified implementation taking advantage of eb69d59 |
Ok this is ready now, it was waiting for ORM |
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.
Thanks. LGTM, just a small doubt that there might be an obsolete comment.
...t/src/main/java/io/quarkus/hibernate/orm/deployment/integration/QuarkusClassFileLocator.java
Show resolved
Hide resolved
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Please don't merge - I've pushed an experiment and need CI feedback. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@yrodiere I understand what's going on now, unfortunatley sharing the ByteBuddy caches would require much more work - and is tricky. So I suggest we merge this version: it shares the caches of "core types" (which we know are not being modified) but isolates the caches used for bytecode enhancement in threadlocals to ensure independent interactions. It also shared the Enhancer implementation across runs, and makes its initialization lazy. It's taking the safer approach - there's room for improvement as this forces each thread to repeat quite some work, and also allocate large structures w/o sharing those, but that would require much more work to share them safely, so I'd rather take the 80% improvement now and keep it safe until we have time to add more stricter integration tests. Ok to merge? I'd hit the button as it's already approved, but since several changes were made... |
This comment has been minimized.
This comment has been minimized.
offtopic: @Sanne could you please take a look at this issue? It is kindof related to what you are doing here :) I tried to reproduce problem with this branch, there is still a bug. |
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'm really not sure using threadlocals without ever clearing them is safe in dev mode, but I'll let you check that, and merge if you are confident.
...rm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateEntityEnhancer.java
Outdated
Show resolved
Hide resolved
...rm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateEntityEnhancer.java
Show resolved
Hide resolved
Pushed a rebase, as I plan to resume this work this weekend. |
This comment has been minimized.
This comment has been minimized.
@@ -29,44 +33,37 @@ | |||
*/ | |||
public final class HibernateEntityEnhancer implements BiFunction<String, ClassVisitor, ClassVisitor> { | |||
|
|||
private static final BytecodeProvider PROVIDER = new org.hibernate.bytecode.internal.bytebuddy.BytecodeProviderImpl( | |||
private static final BytecodeProviderImpl PROVIDER = new org.hibernate.bytecode.internal.bytebuddy.BytecodeProviderImpl( |
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.
Shouldn't we use JAVA_V17
now? (line just below)
I would create a separate PR to do it but it's going to be in your way so I will let you address it :).
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 point :)
Amended
Status for workflow
|
Nice work @Sanne , looking forward to trying this out in a next quarkus release! |
This works far better, in my local tests.
I feel it's ready, but it will require a fix on the ORM side to be merged first:
This brings enhancement times of the large model provided as benchmark down to ~1 second, without enabling Quarkus's caching capabilities of caching enhancement of unmodified classes (which we should also enable, but it's a separate aspect)