cucumber-eclipse
cucumber-eclipse copied to clipboard
"Invoking 'Cucumber step definitions builder'" takes a very long time and CPU intensive
After Building/Re-building a Maven project, "Invoking 'Cucumber step definitions builder'" it triggered. It consumes about 80% of CPU time(E5-2673 v3 Xeon with 2.40 GHz and 8 logical processors). In addition, it takes about 1-2 minutes to finish the process :(
Eclipse: Version: 2019-06 (4.12) Cucumber plugin: V: 1.0.0.201907020018
You can reduce the search time by adding filters on the packages or classes where your step definitions are.
This is still an issue. I added the filter as suggested, however i still am having issues with eclipse taking a long time to run the tests. What i had to do is disable the Builder for Cucumber gherkins builder via RIght Click project -> Properties -> Builders -> uncheck Cucumber gherkins builder. I left cucumber step definitions builder checked. I have only been working on this for a few hours, so i will see how things going. Not sure what this is going to do with the project.
The CucumberStepDefinitionsBuilder
creates a repository of step definitions. It lists the implementation of your steps (it searches @Given
, @When
, @Then
, etc).
While the CucumberGherkinBuilder
validates gherkin syntax, creates a repository of gherkin steps and makes glue between the gherkin steps and a compliant step definitions from the repository populated by the CucumberStepDefinitionsBuilder
.
So the CucumberStepDefinitionsBuilder
alone will not have any effect.
Only the cucumber editor will be available, but only the syntax highlight will work.
Cucumber Eclipse is mostly developed by volunteers in their spare time. You can not and should not expect anything. If you are interested in contributing a fix you'd be most welcome.
Hi , Did anyone found a workaround for this issue. I have started to observe it recently. The whole process take about 1-2 minutes after saving one line of code. I have tried to uninstall and re-install but in vain.
I have a project with a very large number of Cucumber tests (2000 features containing total of about 10,000 scenarios) and experience this issue saving. The incremenatal feature file save is not too bad, but the Step code save is unusable, the builder takes at least 5 minutes to complete.
I've been profiling a bit with Flight Recorder and VisualVM to get a feel for the issue and it seems that CucumberGherkinBuilderVisitor
triggers a lot more than expected. My guess is the over-processing is caused by the CucumberGherkinBuildCheckVisitor
which sets fullBuildRequired
required flag for modifications to any previously processed Step file. The forced full build of the CucumberGherkinBuilder
will clean and re-process every feature file, using the Gherkin parser with the MarkerFormatter
. In my project the profiler here shows a hotspot with millions of calls to ParsedExpression.matches(String)
.
So it appears the builder time is domintated by the size of the expression cache that must be searched for glue matches. I see two paths forward:
- Re-design the caching so that the full scope of features do not need to be scanned, perhaps just those currently linked to the updated glue resource, and any features that have unmatched steps.
- The processing appears to be done sequentially, potentially this could be done with Worker threads and pool size set by the plugin configuration (or some other Eclipse PDE meachnism, I'm not that familair with the APIs)
@ross-perston I'm currently completely redesign the whole cucumber-eclipse plugin. One Problem is that I don't have access to such very large projects. Do you think it is possible to share the project (e.g. its open source or you can give access to a private repository)?
Alternatively it would help if you perform the following steps:
- choose one out of your 2000 features you think that's one of the larger ones (in terms of steps to execute)
- run cucumber-cli with the following options -t
-d - report here how long it takes to run this command and if possible the number of summary of steps run
We are currently developing a new version of the cucumber-plugin with improved support for more recent cucumber versions, if you like try out the following update-site (please uninstall the old plugin before): https://cucumber.github.io/cucumber-eclipse/update-site/main/
I have tried this new version of the cucumber plugin (on branch main). Unfortunately I could not get it to link any gherkin steps to step definitions.
I did notice some things while looking at the source code:
- the target environment for this plugin is eclipse 2021-09, and there are many additional dependencies compared to v1.x What is the reason for targeting a specific release of eclipse? Do these dependencies allow tighter integration with eclipse? E.g. the Ctrl+Space functionality for suggesting step completion, ability to run a features/scenarios from eclipse editor?
- the approach to linking steps differs from v1.x, instead using the cucumber API to perform a "dry run", and collecting events for use within the plugin. I suspect cucumber itself suffers from similar performance problems for large projects as the first version of this plugin. For reference, my project of ~10000 scenarios and 3000 step definitions takes about 40 minutes to complete a dry run with cucumber 6.11, so I'm not sure we will see an improvement with this approach.
Is there an active task list for this new version? It is hard to tell how mature this version is just by looking at the source.
Thanks for the feedback.
- As Eclipse does not offer any backporting (mainly due to lack of developer resources/contributors) we constantly need to upgrade the eclipse version to get bugfixes and new features.
- Everyone that is willing to support the old approach can contribute to the v1.x line, but as cucumber evolves more and more with new features it becomes much harder to catch up given that there are quite no active contributors on this product, the step support in cucumber-eclipse was always incomplete an flawed regarding to more advanced type mappings.
- Can you share an example of an project where step-def linking is missing? Is there any background works show in eclipse?)
- regarding large projects: There is no public example of any larger project available that could serve as a test-case so there is literally no testing beyond the ones given in examples. Any contribution is welcome!
Beside that, we currently only dry-run the current open editor feature, so the number of features does not really matters and the step-search is limited to the projects dependencies so you could speed-up things by managing your dependencies. Anyways this is quite new and we might can add some options to limit the search further (e.g. only scanning certain packages) or even add an option to disable glue matching unless the feature is actually run for the first time and a like, but here we need at laest one example that demonstrates the desired use-case.
Is it possible to disable the "Cucumber steps definition builder"? I haven't written any steps yet, and my eclipse installation is unusable.
Hi @laeubi Thanks for your detailed response. I have generated a large cucumber project that can be used to profile cucumber and associated cucumber tools such as this plugin.
https://github.com/ayoung012/large-cucumber-java-stub
Some very interesting things can be seen by profiling this plugin on this stub project with VisualVM, for example, it becomes obvious that adding Java8 lambda step definition support adds an unreasonable amount of time to the step definition builder. The 'Creating Type hierarchies...' log indicates that it is spending far too much time in this area. Maybe lambda support should be a plugin preference that can be disabled. Also worrying is that a plain cucumber-jvm dry run takes 15 minutes on my machine, mostly on regex matching step definitions. I suspect more can be done in this area...
@ayoung012 thanks for the example, I'll try to take a look at it.
I think the best that one could do in such situation is to try to narrow down the scope of a feature. I suspect not all step definitions are relevant for one feature.
lamdas are especially slow as the require the java code to be executed instead of only reading the class metadata. Also lamdas are hard to manage (e.g. get reliable line information) so in general they have only basic support with the plugin.
What I can think of would be that cucumber supports some kind of aching of data (e.g. store discovered items and only update if the class file changes) but I have no idea if that actually helps much. Maybe the eclipse-plugin can also cache some state but for matching glue<->feature we still need the help of cucumber and can't really speedup things much if a regular dry-run already takes many minutes.
Cucumber Eclipse is mostly developed by volunteers in their spare time. You can not and should not expect anything. If you are interested in contributing a fix you'd be most welcome.
What is a point of your reply?! Are you suggesting that EVERYONE who has an issue with ANY open source projects they are using to just fix the ALL by THEMSELF? That is a very stupid suggestion. Look, I have created this ticket to see if someone knows how that can be resolved. If you have nothing to contribute - just keep you know what shut, as that is not helpful at all.