At scale, tag-based user selection — the foundation of precision marketing, personalized recommendations, and risk control — requires a bitmap data structure that handles hundreds of millions of sparse entries, runs set intersections in milliseconds, and stays stable under concurrent load. Redis Open-Source Edition bitmaps hit hard limits in all three areas. TairRoaring, a roaring bitmap data structure in Tair (Enterprise Edition), removes those limits through internal optimizations that require no application-side changes.
Why native bitmaps fall short
Redis Open-Source Edition bitmaps impose three constraints that compound as data grows:
| Constraint | Impact |
|---|---|
| Keyspace size limit | Significant space waste for sparse tag data |
| String-based bitmap operations | User-side orchestration code required; round-trip time (RTT) triples |
| Large keys | Cluster instability under heavy tagging workloads |
How TairRoaring addresses these constraints
TairRoaring optimizes the roaring bitmap algorithm with three techniques that work transparently within the Tair (Enterprise Edition) engine:
Two-level indexes and dynamic containers: TairRoaring partitions bitmap data using a two-level index structure. Dense and sparse datasets are handled automatically, with no manual sharding required. This eliminates the large-key problem at the data-structure level.
SIMD, vectorization, and popcount algorithms: Single instruction, multiple data (SIMD) and vectorization parallelism, combined with popcount-based cardinality counting, accelerate set intersection (
AND), union (OR), and difference (DIFF) operations.Tair's high-performance runtime: Operations run inside the Tair (Enterprise Edition) engine, which sustains stable cluster performance under large-scale concurrent workloads.
Compared to native Redis bitmaps, TairRoaring delivers lower memory usage and faster collection operations. Compared to string-based bitmap orchestration, it delivers lower latency and higher throughput by eliminating the extra RTTs.
Select users by tag
Tag-based user selection follows a three-stage pipeline.
Stage 1: Build the tag store
Store user characteristics from relational databases using row schemas, organized by dimension (for example, demographics, behavior, and preferences).
Process raw data on demand to generate UID-to-tag mappings.
Sync updated mappings to TairRoaring. Updates typically complete within two days of the corresponding business data being generated.
Stage 2: Query users
Once the tag store is in place, TairRoaring supports three query patterns.
Check whether a user has a specific tag
To determine whether user1 has Tag-A (serial number 16161):
TR.GETBIT user1 16161Find users matching a combination of tags
To find all users who have both Tag-B and Tag-C:
TR.BITOP result AND Tag-B Tag-CTR.BITOP supports AND, OR, and DIFF operators, so you can construct arbitrary logical user groups from your tag sets.
Reverse lookup: check whether a tag maps to a specific UID
In risk control scenarios, tags represent attributes and UIDs are the values being checked. Reverse the key order to perform the lookup:
TR.GETBIT Tag-A user1Stage 3: Use query results
Pass the output bitmap or bit value to downstream systems for further processing.