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

Add microbenchmarks, improve RangeMap perf #49

Merged
merged 8 commits into from
Jul 8, 2024
Merged

Add microbenchmarks, improve RangeMap perf #49

merged 8 commits into from
Jul 8, 2024

Conversation

rbuckton
Copy link
Member

@rbuckton rbuckton commented Jul 8, 2024

This adds microbenchmarks to analyze the performance of several parts of Deopt Explorer and improves the performance of RangeMap, which is used throughout the extension to collection information related to positions and ranges, such as for producing hovers.

The key changes were to support a user-defined comparer in SplayTree, which allowed RangeMap to switch from using series of nested SplayTrees that map startLine -> startCharacter -> endLine -> endCharacter -> T to a single SplayTree whose keys are Ranges using a custom comparer. The ranges are sorted by range.start in ascending order, then range.end in descending order. This order allows us to treat subsequent ranges as if they were contained by prior ranges as long as they share the same start position, which results in more efficient traversal.

This also adds linked list-like pointers to SplayTree.Node to make in-order traversal more efficient and reliable.

The net result is a 40x improvement in calls to .findAllContaining():

image

.vscode/launch.json Outdated Show resolved Hide resolved
@jakebailey
Copy link
Member

Long-term, I wonder if you'd have it easier running vitest and its built-in benchmarking; I've found it to be pretty handy and avoids a lot of boilerplate.

@rbuckton
Copy link
Member Author

rbuckton commented Jul 8, 2024

At this point I'm pretty familiar with jest's quirks. I'm not sure I want to switch to a different test framework just for benchmarking.

My biggest issue at the moment is bit rot with my CI builds..

@rbuckton rbuckton merged commit 9a6bc23 into main Jul 8, 2024
11 checks passed
@rbuckton rbuckton deleted the range-tree branch July 8, 2024 20:03
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