-
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
[MNG-6697] New fast model interpolator not using reflection #261
Conversation
Fwiw, one test is broken with this commit, so I need to find a fix before the PR can be merged. |
The test has been fixed by the latest commit. |
|
We can put a TODO comment for |
Fwiw, the changes to I believe in non-concurrent access, |
I haven't been able to gain anything using a fork/join pool... |
@gnodet |
@gnodet |
There is no concurrent access at all for the And fwiw, in a non concurrent access, the HashMap is supposed to perform better than ConcurrentHashMap because it does not need to care about locking in any way. |
new InterpolateObjectAction( obj, valueSources, postProcessors, this, problems ); | ||
InnerInterpolator innerInterpolator = createInterpolator( valueSources, postProcessors, problems ); | ||
|
||
PrivilegedAction<Object> action; |
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.
Use declaration and assignment at one line please.
If you want to improve the performance this btw, the |
|
@Tibor17 The whole point of this PR is to actually provide a completely new implementation of the Fwiw, your assumption about the performance of the Also, I haven't tried to blindy optimize things, but I did use a profile to find hot spots that were using a lot of cpu and find ways to optimize it. For the array case (which isn't a problem anymore since we're not using reflection anymore with the new interpolator). I can provide the profiling data, but I don't think there is any array in the model, so the I think, if there's a need to optimize things more, I think the next point to consider is to optimize the |
I made an analysis the yes, the domain objects in Maven should be best Immutable which avoids unnecessary cloning and avoids problems with memory visibility between Threads, and then Maven should have services with domain objects (not collections). The state of immutable objects would be valid at the time when they were read from the services. |
I've raised codehaus-plexus/plexus-utils#67 to improve the 2 costly operations on the |
Someone needs to push a new Plexus Utils release... |
@Tibor17 Because with new Xxxx[0] the JVM will skip the allocation and the zeroing of the array. |
Plexus Utils 3.2.1 should be available soon |
I've raised https://issues.apache.org/jira/browse/MNG-6718 and #271 to upgrade |
{ | ||
final Map<String, String> cache = new HashMap<>(); | ||
final StringSearchInterpolator interpolator = new StringSearchInterpolator(); | ||
interpolator.setCacheAnswers( true ); |
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.
an extra speed up could be achieved if this PR could be merged: codehaus-plexus/plexus-interpolation#17
@gnodet WARNING: An illegal reflective access operation has occurred, WARNING: Illegal reflective access by org.apache.maven.model.interpolation.StringSearchModelInterpolator$InterpolateObjectAction$CacheField (file:/home/jenkins/jenkins-slave/workspace/maven-box_maven_master/test/core-it-suite/target/apache-maven/lib/maven-model-builder-3.6.2-SNAPSHOT.jar) to field java.io.File.fs, WARNING: Please consider reporting this to the maintainers of org.apache.maven.model.interpolation.StringSearchModelInterpolator$InterpolateObjectAction$CacheField, WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations, WARNING: All illegal access operations will be denied in a future release |
In Oracle JDK, I guess that
|
@gnodet
expected:<[]> but was:<[WARNING: An illegal reflective access operation has occurred, WARNING: Illegal reflective access by org.apache.maven.model.interpolation.StringSearchModelInterpolator$InterpolateObjectAction$CacheField (file:/home/jenkins/jenkins-slave/workspace/ven-box_maven_removed-java-tools/test/core-it-suite/target/apache-maven/lib/maven-model-builder-3.6.2-SNAPSHOT.jar) to field java.io.File.fs, WARNING: Please consider reporting this to the maintainers of org.apache.maven.model.interpolation.StringSearchModelInterpolator$InterpolateObjectAction$CacheField, WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations, WARNING: All illegal access operations will be denied in a future release]>
junit.framework.AssertionFailedError: expected:<[]> but was:<[WARNING: An illegal reflective access operation has occurred, WARNING: Illegal reflective access by org.apache.maven.model.interpolation.StringSearchModelInterpolator$InterpolateObjectAction$CacheField (file:/home/jenkins/jenkins-slave/workspace/ven-box_maven_removed-java-tools/test/core-it-suite/target/apache-maven/lib/maven-model-builder-3.6.2-SNAPSHOT.jar) to field java.io.File.fs, WARNING: Please consider reporting this to the maintainers of org.apache.maven.model.interpolation.StringSearchModelInterpolator$InterpolateObjectAction$CacheField, WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations, WARNING: All illegal access operations will be denied in a future release]>
mng4387QuietLogging(it).....................................FAILURE (1.6 s) |
This likely means that CacheField( Field field )
{
this.field = field;
field.setAccessible( true );
} has to go? |
@michael-o |
We need to check the log, I thiink there was also some use of reflection before this change. BTW, this is a common problem, not just in Maven. Compiling with Maven 3.5.4 a webapp:
I think we should spawn another issue for this, continue with 3.6.2, but address this in the next release. |
@michael-o
|
Perhaps also the sanity check to introspect nested objects as well. |
@michael-o The field I think the whole problem is that the fields are eagerly introspected on Java objects in 1 which should be avoided by keeping the |
There are more issues like introspecting |
But the field |
Of course and that's the point. Because reading the field of Java File does not make sense. It's not our code. What makes sense to me regarding interpolation of |
@michael-o |
I made the change locally and the unit test |
@michael-o |
@michael-o |
The MavenITmng6562WarnDefaultBindings IT tests new Maven4 feature "fail on severity" (for WARN level). The stub core plugin maven-resources-plugin depends on maven-compat, and it emits plugin validation warning. BEFORE MNG-7788 was merged, the warnings were logged AFTER build summary and was not picked up by "fail on severity". AFTER MNG-7788 merged, it causes that warnings breaks the build, as "fail on severity" is set to WARN level. Fix: The stub maven-resources-plugin does NOT need to depend on maven-compat, what it really needs is maven-core (for MavenProject).
No description provided.