Repository navigation
dynamically get the plugin id instead of hardcoding it in the generated classes - #12038
Conversation
|
This LGTM. I've added a test to check if we experiment performance regressions future. /cc @jsvd |
|
Test has failed: |
|
@jsvd I think the cache is already warmed up by other tests |
|
good catch, @andsel can you open an issue to discuss the implementation of the cache as a static? as it is it's difficult to configure/disable the cache in testing. |
|
Added issue #12044 to improve the internal class cache |
| static { | ||
| COMPILER.setDebuggingInformation(true, true, true); | ||
| } | ||
|
|
There was a problem hiding this comment.
I don't believe this was intended to stay?
| static { | |
| COMPILER.setDebuggingInformation(true, true, true); | |
| } |
There was a problem hiding this comment.
I was thinking the same, but if the switch for Janino debug is on, probably having the right line reference on the generated sources could be helpful.
There was a problem hiding this comment.
Do you think could impact negatively the compilation part?
There was a problem hiding this comment.
I haven't tested. can't this be enabled through JAVA_OPTS?
There was a problem hiding this comment.
I found it, it's org.codehaus.janino.source_debugging.enable so removed the code fragment
| // for 7.6 | ||
| // return new FilterDelegatorExt( | ||
| // RubyUtil.RUBY, RubyUtil.FILTER_DELEGATOR_CLASS) | ||
| // .initForTesting(this.filter.get()); |
There was a problem hiding this comment.
we won't be backporting this to 7.6
| // for 7.6 | |
| // return new FilterDelegatorExt( | |
| // RubyUtil.RUBY, RubyUtil.FILTER_DELEGATOR_CLASS) | |
| // .initForTesting(this.filter.get()); |
| final CompiledPipeline compiledPipeline2 = new CompiledPipeline(pipeline2, pluginFactory); | ||
| compiledPipeline2.buildExecution(); | ||
| final int cachedAfter = ComputeStepSyntaxElement.classCacheSize(); | ||
| System.out.println("DNADBG>> cachedAfter: " + cachedAfter + ", cachedBefore: " + cachedBefore); |
6ff92cb to
f7627fc
Compare
There was a problem hiding this comment.
let's avoid these refactors, I think we benefit from having an explicit list, makes it easier to understand the dependencies. Intellij can be told to stop doing this.
3de61df to
9ac8846
Compare
…ead of hardcode Changed ComputeStepSyntaxElement to generate Java code to retrieve the plugin's id by a method instead of hardcoding the value in the generated code. This permit to share more compiled classes, that differs only by plugin.id and speed up the pipeline compilation. The change has been secured by future regression with unit test that track pipeline compilations times. Co-authored-by: Andrea Selva <andsel@users.noreply.github.com> Co-authored-by: João Duarte <jsvd@users.noreply.github.com> Fixes: elastic#12031
9ac8846 to
1a11abd
Compare
with PR elastic#11773 some configuration code part was moved from Ruby to Java, due to this move the CompiledPipelineTest.verifyRegex method changed the type of thrown exception from stricter IncompleteSourceWithMetadataException to coarse parent InvalidIRException. With changes in PR elastic#12038 some import cleanup was done and that removed the import of IncompleteSourceWithMetadataException and necessity of this fix.
with PR #11773 some configuration code part was moved from Ruby to Java, due to this move the CompiledPipelineTest.verifyRegex method changed the type of thrown exception from stricter IncompleteSourceWithMetadataException to coarse parent InvalidIRException. With changes in PR #12038 some import cleanup was done and that removed the import of IncompleteSourceWithMetadataException and necessity of this fix.
Fixes #12031
This PR fixes the regression introduced in 7.7.0 where the plugin id was set in the thread context by hard coding the unique plugin id in the generated class resulting in generating non cacheable classes that all contained a unique id.
The fix is to dynamically get the plugin id from the plugin instance field which result in non-unique generated code and thus allowing the reuse of equivalent generated classes.