Matrix-Based Filtering

Request
Campaign targeting rules (14 campaigns)
Click a cell to edit: blank (no rule), + include, − exclude, both. Each campaign has a fixed ID. Bit i in every bitset below stands for campaign i. Rows fade when a filter removes them and turn green when they match.
Filter indexes, built from the rules above
Each filter keeps include_map, exclude_map and empty_include_bitset. Bold rows are the values of the current request. The purple outline marks the rows used by the current step.
One bid request, step by step
Waiting for the first request...
Campaign result
Naive loop vs bitsets, as campaigns grow (modeled counts)
Campaigns
Rules per campaign
Request attributes
Naive loop: rule checks
Bitset: 64-bit word ops
Bitset: whole-set ops
Bars use a log scale. Naive loop = campaigns x rules. Bitset = 3 operations per attribute (OR, AND NOT, AND), and each one touches campaigns / 64 words. The number of whole-set ops depends only on the request, not on the campaign count. All numbers here are modeled, not measured.