Memoize configuration parameters that are costly to create#3167
Memoize configuration parameters that are costly to create#3167henri-tremblay wants to merge 1 commit intocucumber:mainfrom
Conversation
8b77e7e to
358b509
Compare
|
If there is a benefit to this then I'd prefer we copy JUnits design where there is |
I was hoping to limit the breaking changes in v8 to raising the baseline to Java 17 without too many breaking other changes. Would that pose a problem for you? |
|
When running Cucumber from IntelliJ directly from the feature file (right click, Run), then the properties are parsed by @mpkorstanje would it be feasible to have the same configuration logic between the junit platform and the Cucumber CLI execution modes ? (that would be probably much more work than just caching) |
No. The |
|
I'm trying to give you a benchmark. I had one for JUnit 4. Let's see for 5. |
mars1589
left a comment
There was a problem hiding this comment.
In plugins(), we now cache the parsed plugin list, then append the publish/no-publish plugin to that list. Since the base list is memoized, if plugins() is called more than once on the same CucumberConfiguration, we can append again to the same list and end up with duplicate plugin entries. So plugins() stops being idempotent.
Could we keep memoization for the expensive parse part, but still return a fresh mutable list per call before adding publish plugin? For example, copy the memoized base list into a new ArrayList and then append publish plugin to that new list.
Also, can we add a regression test that calls plugins() twice on the same config instance (with PLUGIN_PROPERTY_NAME and publish token enabled) and asserts the second call does not increase count or duplicate entries?

🤔 What's changed?
Remember the value of a configuration parameter to return the same result next time.
⚡️ What's your motivation?
Configuration parameters like Pattern are really costly to create. And they are accessed repetitively for each scenario. In benchmarks generating tests to run without running them, it's more than 50% of the time.
🏷️ What kind of change is this?
If possible, I would like to see it included in the 7.x cycle but didn't know which branch to target.
♻️ Anything particular you want feedback on?
I haven't tested memoization everywhere I used it because there's often more manipulation afterwards. If we go crazy, we could always keep the final returned result instead of the one after the compute. But I think that's a good start.
📋 Checklist: