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

perf(utils): further optimise subset check. #48

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from

Conversation

yuroitaki
Copy link
Member

As tlsnotary/tlsn#664 starts using is_subset checks, I implemented a small optimisation — immediately return false if the subset candidate's left and right boundaries are not within/same as the other rangeset.

Copy link
Member

@themighty1 themighty1 left a comment

Choose a reason for hiding this comment

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

lgtm

@sinui0 sinui0 changed the title (feat): further optimise subset check. feat(utils): further optimise subset check. Jan 8, 2025
@sinui0 sinui0 changed the title feat(utils): further optimise subset check. perf(utils): further optimise subset check. Jan 8, 2025
@sinui0
Copy link
Member

sinui0 commented Jan 8, 2025

Lgtm, but performance optimizations would ideally come with a benchmark proving they are faster

@yuroitaki
Copy link
Member Author

yuroitaki commented Jan 9, 2025

Lgtm, but performance optimizations would ideally come with a benchmark proving they are faster

do you mean adding a bench.rs in the code, or attaching the result of manual benching in this PR?

@yuroitaki
Copy link
Member Author

Benchmark results after optimisation in my m2 max macbook below:

image

TLDR:
(1) No impact in the worst case for subset check of range against rangeset.
(2) Significant improvement in the worst case for subset check between rangesets.

(1) most likely because each of the iteration saved by the short-circuit optimisation only does very little work, i.e. continue, which doesn't amount to any noticeable performance improvement.

@yuroitaki yuroitaki requested a review from themighty1 January 16, 2025 12:29
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.

3 participants