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

Improve RangeSet initialization performance #75089

Merged
merged 3 commits into from
Jul 12, 2024
Merged

Conversation

natecook1000
Copy link
Member

When initializing a range set with a group of overlapping, identical, or empty ranges, the initializer can exhibit poor performance due to removing the unneeded ranges during processing. This change uses a partitioning scheme instead, only removing the unnecessary ranges at the end of initialization.

When initializing a range set with a group of overlapping, identical,
or empty ranges, the initializer can exhibit poor performance due
to removing the unneeded ranges during processing. This change uses
a partitioning scheme instead, only removing the unnecessary ranges
at the end of initialization.
@natecook1000 natecook1000 requested a review from a team as a code owner July 9, 2024 00:51
@natecook1000
Copy link
Member Author

@swift-ci Please smoke test

@natecook1000
Copy link
Member Author

@swift-ci Please test

let newUpper = Swift.max(
_storage[lastValid].upperBound,
_storage[current].upperBound)
_storage[lastValid] = _storage[lastValid].lowerBound ..< newUpper
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth using Range(uncheckedBounds:) here to avoid a second bounds check since we know the if statement above has already passed? Not sure if that'll have a measurable impact, but I thought of it while reading through

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, that's what it's for!

@natecook1000
Copy link
Member Author

@swift-ci Please test

@natecook1000 natecook1000 merged commit 846a861 into main Jul 12, 2024
5 checks passed
@natecook1000 natecook1000 deleted the rangeset-init-perf branch July 12, 2024 20:01
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