-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Reduce stack utilization by getting rid of outer Stream API call in TestTemplateTestDescriptor::execute #4020
Comments
If only @gunnarmorling ran JUnit on the module path, I could see the version he was using. ;-) Since 1.10, we try our best to prune such stacktraces: https://junit.org/junit5/docs/current/user-guide/#stacktrace-pruning |
@sormuras I believe the screenshot is taken from a debugging session (I recognize the Eclipse UI). I think the pruning doesn't affect the debugger behavior? |
That's true, stackframes in debugging sessions are not pruned. |
Yes, indeed this is with the Eclipse debugger. |
I think that's a reasonable refactoring. 👍
We should indeed not change this as lazily processing @amaembo Would you be interested in sending a PR for the first suggested change? |
…estTemplateTestDescriptor::execute Fixes issue junit-team#4020
…estTemplateTestDescriptor::execute Fixes issue junit-team#4020
Sure, here it is: #4024 |
I see the problem with closeable stream. Will address it. |
…estTemplateTestDescriptor::execute Fixes issue junit-team#4020
Related low-level idea: https://bugs.openjdk.org/browse/JDK-8340973 |
Hello, dear JUnit team!
Today I've noticed the following Twitter post which reports a very deep stack trace:
https://x.com/gunnarmorling/status/1838556082005807554
It includes a lot of JUnit frames, notably coming from the nested Stream API call in
TestTemplateTestDescriptor#execute
. I've noticed that a short and local patch could reduce the stack consumption by probably a couple dozens of frames without changing the code behavior:Reducing stack consumption makes the debugging experience more user-friendly, as users will be less likely confused by many frames. It may also reduce the output size if the exception is printed/logged, saving the precious screen or log file real estate and time necessary to scroll through the output. Finally, using less stack size by framework leaves more stack size to the user code, which is also user-friendly. While streams are used in other places, this one is particularly important because in the heart of it the user code is executed, so users can see this particular stack trace quite often.
A further stack consumption reduction is possible, though it requires collecting streams from
provideTestTemplateInvocationContexts
to intermediate lists, so it could be more questionable, as performance and memory consumption are not definitely better in this case:It's just a suggestion, feel free to ignore if it goes against the code standards in the JUnit project.
The text was updated successfully, but these errors were encountered: