[Performance Enhancements] Lambda expressions format change & Multi-level exploration logic changes#1535
Merged
bulldozer-bot[bot] merged 14 commits intodevelopfrom Feb 23, 2026
Merged
[Performance Enhancements] Lambda expressions format change & Multi-level exploration logic changes#1535bulldozer-bot[bot] merged 14 commits intodevelopfrom
bulldozer-bot[bot] merged 14 commits intodevelopfrom
Conversation
Generate changelog in
|
Invalidated by push of b3de33c
Contributor
|
👍 |
[skip ci]
8f76341 to
8761f21
Compare
Contributor
|
👍 |
relative symlink? comment sptless comments
LAST_LEVELS_TO_EXPLORE levels
Contributor
|
👍 |
[skip ci]
right comment comment
[skip ci]
Invalidated by push of de3b8eb
LAST_LEVELS_TO_EXPLORE levels
✅ Successfully generated changelog entry!Need to regenerate?Simply interact with the changelog bot comment again to regenerate these entries. 📋Changelog Preview💡 Improvements
|
Contributor
|
👍 |
|
Released 2.89.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Before this PR
Some repos would take 5 - 9 mins to be formatted. This is because we were exploring both
preferBreakingLastInnerLevel&breakNormallyfor each level, with the branching coefficient capped to 20. The exploration is exponential. See below the Benchmark for the before implementation:After this PR
Performance dashboards here. Internal excavator runs here
Example of the new diff: here or here
Most of the times we prefer
preferBreakingLastInnerLevelin order to keep as compact as possible. I changed the logic that started the exploration top-down (with a branching coefficient capped at 20) to an exploration of the lastLAST_LEVELS_TO_EXPLORElevels. For the lastLAST_LEVELS_TO_EXPLOREI am exploring bothpreferBreakingLastInnerLevel&breakNormallyand I will pick the formatted text that minimises the number of lines.In order to keep the formatting as compact as possible, I am defaulting to
preferBreakingLastInnerLevelfor all the upper levels. If no such formatting was found, then I am falling back tobreakNormally.with
LAST_LEVELS_TO_EXPLORE=8Because the number of exploration is substantially decreased, just changing the above setup would end up in some cases looking like here. I've noticed that most of the time the setup was wrong was for lambda expressions.
I changed the logic for lambda expressions (lambda body with no curly braces), to instead of trying to inline as much as possible the inner levels of the lambda body (code here) to defaulting to
breakNormally:lambda expressionfits completely on the same line as the parent, it will be inlinedlambda bodygets split in multiple lines.Other things that I tried:
LAST_LEVELS_TO_EXPLORE = 12, noticed some perf regression for some repos.==COMMIT_MSG==
Improve perf by inspecting both breaking & not-breaking for the
LAST_LEVELS_TO_EXPLORElevels==COMMIT_MSG==
LAST_LEVELS_TO_EXPLORE = 7, however the formatting would regress in some cases (internal link here). Setting level = 12 fixed the issue.fj.Setto using a normalHashSet, however this ended up being (more than 10x) slower. This is because the State is immutable and every time we create a new State, we need to copy & edit eachSetfield, which is much more optimal to do with thefjlibrary than using a normalHashSet.See image below from the jfr.
Possible downsides?