Skip to content

Simplified HashSet out of existence#309

Open
kornelski wants to merge 4 commits intomainfrom
loc
Open

Simplified HashSet out of existence#309
kornelski wants to merge 4 commits intomainfrom
loc

Conversation

@kornelski
Copy link
Contributor

@kornelski kornelski commented Mar 11, 2026

E::MatchPayload was SelectorHandlersLocator, which was getting copied all over the selector matching vm, and infected everything with a generic type.

Matches were stored in HashSet<SelectorHandlersLocator>, but the HashSet couldn't be iterated, because that wouldn't have a deterministic order. The solution for that was calling handlers eagerly, and passing match_handler: &mut dyn FnMut(MatchInfo<E::MatchPayload>), adding more args and generics.

I've made SelectorHandlersLocator 3x smaller, and realized it doesn't even have to exist in the selector vm. Instead of replacing HashSet<SelectorHandlersLocator> with HashSet<usize>, I've made a basic bitset for it, which in common case (< 184 handlers) doesn't use heap allocations and has super fast union.

The bitset can be iterated in a deterministic order, so I could also remove a bunch of match_handler: &mut dyn FnMut(MatchInfo<E::MatchPayload>) early calls, and call all handlers once in a loop, which simplifies things a lot (moving match_handler out of the bailout/resume machinery). Many DefaultHasherBuilders are gone too.

@kornelski kornelski requested review from a team, Noah-Kennedy, jasnell and orium as code owners March 11, 2026 18:50
@kornelski kornelski changed the title Smaller locator struct Simplified HashSet out of existence Mar 12, 2026
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