Skip to content

Speed up filterSamples by taking advantage of sortedness. #4669

Merged
mstange merged 1 commit into
firefox-devtools:mainfrom
mstange:faster-filter-samples
Jun 20, 2023
Merged

Speed up filterSamples by taking advantage of sortedness. #4669
mstange merged 1 commit into
firefox-devtools:mainfrom
mstange:faster-filter-samples

Conversation

@mstange

@mstange mstange commented Jun 16, 2023

Copy link
Copy Markdown
Contributor

On the profile from #4668 this makes filterSamples 10x faster. It changes the algorithm complexity from N * M to N + M, with N being the number of samples and M the number of ranges.

Before: https://share.firefox.dev/3Ji8qPD
After: https://share.firefox.dev/3CAtmxA

This PR includes #4670.

@mstange mstange requested a review from canova June 16, 2023 20:15
@mstange mstange self-assigned this Jun 16, 2023
@codecov

codecov Bot commented Jun 16, 2023

Copy link
Copy Markdown

Codecov Report

Patch coverage: 95.55% and project coverage change: +0.01 🎉

Comparison is base (e6fecc6) 88.47% compared to head (10d8606) 88.49%.

❗ Current head 10d8606 differs from pull request most recent head d685977. Consider uploading reports for the commit d685977 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4669      +/-   ##
==========================================
+ Coverage   88.47%   88.49%   +0.01%     
==========================================
  Files         295      296       +1     
  Lines       26300    26317      +17     
  Branches     7100     7101       +1     
==========================================
+ Hits        23270    23289      +19     
+ Misses       2818     2816       -2     
  Partials      212      212              
Impacted Files Coverage Δ
src/profile-logic/transforms.js 91.66% <91.66%> (+0.23%) ⬆️
src/profile-logic/profile-data.js 93.69% <100.00%> (ø)
src/utils/range-set.js 100.00% <100.00%> (ø)

... and 2 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@julienw

julienw commented Jun 19, 2023

Copy link
Copy Markdown
Contributor

Ah I knew we could do something better but couldn't figure out when I reviewed. Thanks!

@mstange mstange force-pushed the faster-filter-samples branch 2 times, most recently from 1319b66 to 10d8606 Compare June 19, 2023 15:42
@mstange

mstange commented Jun 19, 2023

Copy link
Copy Markdown
Contributor Author

I've pulled out canonicalizeRangeSet into a new utils/range-set.js file and added some tests.

@canova canova left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Oh nice. I knew that it wasn't great to have N * M algorithm. Thanks for making it better!

Comment thread src/utils/range-set.js
Comment thread src/test/unit/range-set.test.js
On the profile from firefox-devtools#4668 this makes filterSamples 10x faster. It changes
the algorithm complexity from N * M to N + M, N being the number of
samples and M the number of ranges.

Before: https://share.firefox.dev/3Ji8qPD
After: https://share.firefox.dev/3CAtmxA
@mstange mstange force-pushed the faster-filter-samples branch from 10d8606 to d685977 Compare June 20, 2023 16:20
@mstange mstange enabled auto-merge June 20, 2023 16:21
@mstange mstange merged commit 1dc10ea into firefox-devtools:main Jun 20, 2023
@canova canova mentioned this pull request Jun 20, 2023
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