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

style: Get rid of allocations in class selector matching #1146

Merged
merged 6 commits into from
Jan 5, 2025

Conversation

robinlinden
Copy link
Owner

@robinlinden robinlinden commented Jan 4, 2025

Before:

|               ns/op |                op/s |    err% |     total | is_match: class
|--------------------:|--------------------:|--------:|----------:|:----------------
|             1392.13 |           718322.70 |    1.2% |      0.01 | `match, few classes`
|             2272.80 |           439986.22 |    0.6% |      0.01 | `no match, few classes`
|             6605.88 |           151380.23 |    1.8% |      0.01 | `match, many classes`
|             5102.84 |           195969.17 |    0.2% |      0.01 | `no match, many classes`

After removing the bonus allocations:

|               ns/op |                op/s |    err% |     total | is_match: class
|--------------------:|--------------------:|--------:|----------:|:----------------
|              341.30 |          2929955.00 |    0.5% |      0.01 | `match, few classes`
|              536.39 |          1864327.70 |    0.7% |      0.01 | `no match, few classes`
|             1595.52 |           626753.07 |    1.3% |      0.01 | `match, many classes`
|             1160.63 |           861598.44 |    0.2% |      0.01 | `no match, many classes`

After also not looking up the class attribute once per class searched for:

|               ns/op |                op/s |    err% |     total | is_match: class
|--------------------:|--------------------:|--------:|----------:|:----------------
|              297.82 |          3357777.59 |    0.6% |      0.01 | `match, few classes`
|              452.88 |          2208102.43 |    1.0% |      0.01 | `no match, few classes`
|             1444.01 |           692515.43 |    0.4% |      0.01 | `match, many classes`
|             1085.37 |           921346.23 |    0.6% |      0.01 | `no match, many classes`

There's more low-hanging fruit, but dealing with that will be nicer now that there's easy access to benchmarking.

@robinlinden robinlinden changed the title Style class perf style: Get rid of allocations in class selector matching Jan 5, 2025
@robinlinden robinlinden force-pushed the style-class-perf branch 2 times, most recently from 6b11330 to cbd402f Compare January 5, 2025 01:38
@robinlinden robinlinden marked this pull request as ready for review January 5, 2025 03:20
@robinlinden robinlinden merged commit 1d405d3 into master Jan 5, 2025
21 checks passed
@robinlinden robinlinden deleted the style-class-perf branch January 5, 2025 22:13
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.

1 participant