-
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
Avoid MethodTooLargeException when too many classes to register for reflection #29694
Avoid MethodTooLargeException when too many classes to register for reflection #29694
Conversation
Thanks for your pull request! The title of your pull request does not follow our editorial rules. Could you have a look?
|
2570657
to
17ba88a
Compare
17ba88a
to
0490835
Compare
This comment has been minimized.
This comment has been minimized.
Pinging @mkouba as he did a lot of these splits. |
Well, this is something we'd probably want to avoid. But I'll need to check the reproducer first...
@essobedo You did not mention the |
@mkouba let me write an integration test
If you have too many methods in a class, you get a |
I see. Well, we do generate one |
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.
Hi @essobedo , thank you for the contribution.
I have added a couple of suggestions on how to improve this, please have a look and either implement the suggestions or let me know if you disagree.
core/deployment/src/main/java/io/quarkus/deployment/steps/NativeImageFeatureStep.java
Outdated
Show resolved
Hide resolved
core/deployment/src/main/java/io/quarkus/deployment/steps/NativeImageFeatureStep.java
Outdated
Show resolved
Hide resolved
core/deployment/src/main/java/io/quarkus/deployment/steps/NativeImageFeatureStep.java
Outdated
Show resolved
Hide resolved
core/deployment/src/main/java/io/quarkus/deployment/steps/NativeImageFeatureStep.java
Outdated
Show resolved
Hide resolved
core/deployment/src/main/java/io/quarkus/deployment/steps/NativeImageFeatureStep.java
Outdated
Show resolved
Hide resolved
Any idea in which module I can add an integration test? |
Unless you know a better place to add my IT, by default I will add it to integration-tests/maven |
Do you plan to add the dependency to the swift library or what exactly would you like to test? I mean do you intend to test a use case with thousands of classes registered for reflection? |
Yes I plan to test a use case with thousands of classes registered for reflection but ideally without adding the swift library for the sake of simplicity if possible |
That sounds like something that should go outside of the quarkus core. Maybe https://github.com/quarkus-qe/beefy-scenarios or similar? |
a5a88a9
to
43fc80e
Compare
43fc80e
to
d7c9c1e
Compare
@mkouba I have proposed a PR with the test case to reproduce quarkus-qe/beefy-scenarios#324 |
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.
LGTM, other than the suggestion I added.
Still not convinced we need to make the invocations to registerClasses*
through reflection, but it's not a blocker for me.
core/deployment/src/main/java/io/quarkus/deployment/steps/NativeImageFeatureStep.java
Outdated
Show resolved
Hide resolved
d7c9c1e
to
ff1eeb4
Compare
Feature.BeforeAnalysisAccess.class); | ||
currentRegisterClass.setModifiers(Modifier.PRIVATE | Modifier.STATIC); | ||
} | ||
boolean hasConstructorsToHandle = !entry.getValue().weak && !entry.getValue().constructors |
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.
@essobedo you still have the weak check in hasConstructorsToHandle
. Why? If it is weak
then we should immediately skip the tryBlock
no matter if it hasMethodsToHandle
etc., no?
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.
No, if you check the original code, you will see that tryBlock
is needed if entry.getValue().serialization
is true
whatever the value of entry.getValue().weak
This comment has been minimized.
This comment has been minimized.
ff1eeb4
to
aa2b78d
Compare
e197c3f
to
b039562
Compare
b039562
to
e043b10
Compare
@mkouba I've just proposed a 3rd approach that generates the JSON files directly in the format expected by GraalVM, except for the "weak reflection" that is more or less specific to Quarkus so I need to keep an internal format for it and a dedicated Feature to load and process it. Is it what you had in mind? |
This comment has been minimized.
This comment has been minimized.
e043b10
to
25f8d59
Compare
This comment has been minimized.
This comment has been minimized.
6c8ae50
to
faa5949
Compare
Failing Jobs - Building faa5949
Full information is available in the Build summary check run. Failures⚙️ Gradle Tests - JDK 11 #- Failing: integration-tests/gradle
📦 integration-tests/gradle✖ ✖ 📦 integration-tests/gradle/target/classes/basic-java-library-module/application✖ ⚙️ Gradle Tests - JDK 11 Windows #- Failing: integration-tests/gradle
📦 integration-tests/gradle✖ ✖ 📦 integration-tests/gradle/target/classes/basic-java-library-module/application✖ ⚙️ JVM Tests - JDK 11 #- Failing: integration-tests/kubernetes-client integration-tests/kubernetes-client-devservices integration-tests/kubernetes/quarkus-standard-way and 1 more
📦 integration-tests/kubernetes-client✖ ✖ ✖ ✖ ✖ ✖ ✖ ✖ 📦 integration-tests/kubernetes-client-devservices✖ 📦 integration-tests/kubernetes/quarkus-standard-way✖ ✖ ✖ ✖ ✖ ✖ ✖ ✖ 📦 integration-tests/openshift-client✖ ⚙️ JVM Tests - JDK 11 Windows #- Failing: integration-tests/kubernetes-client integration-tests/kubernetes-client-devservices integration-tests/kubernetes/quarkus-standard-way and 1 more
📦 integration-tests/kubernetes-client✖ ✖ ✖ ✖ ✖ ✖ ✖ ✖ 📦 integration-tests/kubernetes-client-devservices✖ 📦 integration-tests/kubernetes/quarkus-standard-way✖ ✖ ✖ ✖ ✖ ✖ ✖ ✖ 📦 integration-tests/openshift-client✖ ⚙️ JVM Tests - JDK 17 #- Failing: integration-tests/kubernetes-client integration-tests/kubernetes-client-devservices integration-tests/kubernetes/quarkus-standard-way and 1 more
📦 integration-tests/kubernetes-client✖ ✖ ✖ ✖ ✖ ✖ ✖ ✖ 📦 integration-tests/kubernetes-client-devservices✖ 📦 integration-tests/kubernetes/quarkus-standard-way✖ ✖ ✖ ✖ ✖ ✖ ✖ ✖ 📦 integration-tests/openshift-client✖ ⚙️ JVM Tests - JDK 17 MacOS M1 #- Failing: extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment integration-tests/kubernetes-client integration-tests/kubernetes-client-devservices and 1 more
! Skipped: extensions/avro/deployment extensions/csrf-reactive/deployment extensions/grpc/deployment and 131 more 📦 extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment✖ 📦 integration-tests/kubernetes-client✖ ✖ ✖ ✖ ✖ ✖ ✖ ✖ 📦 integration-tests/kubernetes-client-devservices✖ 📦 integration-tests/openshift-client✖ ⚙️ JVM Tests - JDK 18 #- Failing: integration-tests/kubernetes-client integration-tests/kubernetes-client-devservices integration-tests/kubernetes/quarkus-standard-way and 1 more
📦 integration-tests/kubernetes-client✖ ✖ ✖ ✖ ✖ ✖ ✖ ✖ 📦 integration-tests/kubernetes-client-devservices✖ 📦 integration-tests/kubernetes/quarkus-standard-way✖ ✖ ✖ ✖ ✖ ✖ ✖ ✖ 📦 integration-tests/openshift-client✖ ⚙️ Native Tests - HTTP #- Failing: integration-tests/resteasy-reactive-kotlin/standard
📦 integration-tests/resteasy-reactive-kotlin/standard✖ ⚙️ Native Tests - Messaging1 #- Failing: integration-tests/kafka integration-tests/kafka-avro integration-tests/kafka-avro-apicurio2 and 6 more
📦 integration-tests/kafka✖ 📦 integration-tests/kafka-avro✖ 📦 integration-tests/kafka-avro-apicurio2✖ 📦 integration-tests/kafka-oauth-keycloak✖ 📦 integration-tests/kafka-sasl✖ 📦 integration-tests/kafka-snappy✖ 📦 integration-tests/kafka-ssl✖ 📦 integration-tests/kafka-streams✖ 📦 integration-tests/reactive-messaging-kafka✖ ⚙️ Native Tests - Misc3 #- Failing: integration-tests/kubernetes-client integration-tests/openshift-client integration-tests/smallrye-graphql and 1 more
📦 integration-tests/kubernetes-client✖ 📦 integration-tests/openshift-client✖ 📦 integration-tests/smallrye-graphql✖ 📦 integration-tests/smallrye-graphql-client✖ ⚙️ Quickstarts Compilation - JDK 17 #- Failing: stork-kubernetes-quickstart
📦 stork-kubernetes-quickstart✖ |
Yes, something like this. I like this idea but I think that we need more eyes because it's an important change. CC @gsmet @geoand @zakkak @maxandersen. There are a lot of test failures though. Could it be related? |
I am pretty sure that @zakkak already has something in the works |
Indeed, I can see that he is already working on it and his approach is even better so let's close this PR |
Hi folks, sorry for coming back to this late (and especially @essobedo for having you duplicating work) but I was very sick and couldn't even go though email. I indeed have something in the works. It still needs some polishing and I need to confirm it doesn't register more things than before (not sure if the json API is more inclusive than the API). I will try to get it ready for review before the end of the year but I can't promise anything at this point. @essobedo if this is pressing for you feel free to take my branch and work with it. |
just so if others see this in future - generating json is not a complete solution for this. we should still try and make gizmo generation more efficient and smarter so we aren't reliant only on external json configuration imo. |
fixes #29693
Motivation
When we have too many classes to register for reflection, we get an error indicating that
Feature.registerForReflection
is too large.Modifications:
registerClasses
by reflection to limit the size of the method_registerClass
CLASSES_TO_REGISTER_BATCH_SIZE
(100) classes to limit the size of methods and the number of constant pool items of the class that causesClassTooLargeException
Result
The extension can be built as expected and the integration tests of the scenario quarkus-qe/beefy-scenarios#324 works even in native mode