Skip to content

Performance problem with CachingGlue / ExpressionFactory #2504

@simonstratmann

Description

@simonstratmann

👓 What did you see?

We execute cucumber scenarios with a high number of threads (> 150). We had massive problems with the tests starting slowly and needing a lot of initial CPU. Profiling the code I found the main bottleneck to be the creation of expressions in io.cucumber.cucumberexpressions.ExpressionFactory#createExpression which is called (via some other methods) by io.cucumber.core.runner.CachingGlue#prepareGlue.
For every thread all glue code classes are parsed and step definitions are created

✅ What did you expect to see?

As the glue code is the same for all scenarios I'd expect it to be parsed once beforehand. I wrote a custom implementation with copies of some of the involved classes which (very hackily) saves the created step definitions of ExpressionFactory in a static map. This reduces the startup time of the tests on our pipeline drastically.

📦 Which version are you using?

7.0.0

🔬 How could we reproduce it?

Start 150 scenarios or more in parallel. Or just two - the basic problem is always there, it's just more apparent with more threads.

🤔 Anything else?

We have more than 5000 step definitions using method annotations and use a lot of custom parameter types which makes parsing them quite heavy.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions