Skip to content
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

Different performance optimizations #466

Merged
merged 5 commits into from
Dec 8, 2023
Merged

Different performance optimizations #466

merged 5 commits into from
Dec 8, 2023

Conversation

ahamlat
Copy link
Contributor

@ahamlat ahamlat commented Dec 6, 2023

The primary enhancement in this PR pertains to StackedSet, where we've replaced the underlying data structure, Stack, with Deque. This change significantly improves performance by eliminating the need for synchronization.

Additionally, we've revamped the construction of the collapsed stack. Rather than using an isDirty flag and rebuilding the entire collapsed set each time there's a modification, we've opted for an incremental approach. Now, the collapsed set is built each time the stacked set is altered, thereby avoiding the need to recreate the collapsed stack entirely.

We've also optimized the 'lineCount' method in some modules. Instead of using a stream and calling the 'mapToInt' method, which carries a significant overhead, we've chosen to use a simple 'for' loop. This change enhances performance by reducing unnecessary complexity.

We can find below the CPU profiling before and after this PR

Before this PR
image

After this PR
image

@ahamlat ahamlat marked this pull request as draft December 6, 2023 15:38
@ahamlat ahamlat requested a review from delehef December 8, 2023 13:01
@ahamlat ahamlat marked this pull request as ready for review December 8, 2023 13:01
@delehef delehef force-pushed the perf-optimizations branch from 31c1459 to d7d9b75 Compare December 8, 2023 13:18
@delehef delehef enabled auto-merge (squash) December 8, 2023 13:19
@delehef delehef force-pushed the perf-optimizations branch from d7d9b75 to 7f2255e Compare December 8, 2023 15:31
@delehef delehef merged commit c72d1ab into main Dec 8, 2023
@delehef delehef deleted the perf-optimizations branch December 8, 2023 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants