Skip to content

perf: use a bool vector for intset presence - #77

Merged
masklinn merged 1 commit into
ua-parser:mainfrom
masklinn:intset-boolmap
Oct 6, 2026
Merged

masklinn merged 1 commit into
ua-parser:mainfrom
masklinn:intset-boolmap

Conversation

@masklinn

@masklinn masklinn commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

The IntSet, cut down as it was from re2's SparseArray, had an unnecessary complication in the dense array being an intermediate map of value to index, in regex-filtered that is only used to know if the value is already in the set, so a bool does the job more than well enough, for 1/8th the allocation size and a simpler access pattern.

This increases throughput by about 5% on a test dataset.

Using a BitVec was also tested but it does not increase the throughput quite as much, and requires an otherwise unnecessary dependency.

The `IntSet`, cut down as it was from re2's SparseArray, had an
unnecessary complication in the dense array being an intermediate map
of value to index, in regex-filtered that is *only* used to know if
the value is already in the set, so a bool does the job more than well
enough, for 1/8th the allocation size and a simpler access pattern.

This increases throughput by about 5% on a test dataset.

Using a BitVec was also tested but it does not increase the throughput
quite as much, and requires an otherwise unnecessary dependency.
@masklinn
masklinn enabled auto-merge (rebase) October 6, 2026 18:38
@masklinn
masklinn merged commit bf03d5c into ua-parser:main Oct 6, 2026
5 checks passed
@masklinn
masklinn deleted the intset-boolmap branch October 6, 2026 18:39
@masklinn masklinn mentioned this pull request Oct 6, 2026
1 of 2 tasks
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