pub fn init()Expand description
Eagerly initializes CPC’s global decompression tables, used during serialization/deserialization.
Upstream lazily self-initializes these tables on first use via a
function-local static with a dynamic initializer; C++11 onward
guarantees this lazy path is initialized exactly once even under
concurrent access (concurrent callers block until the first caller
finishes, they don’t race), so there is no correctness hazard from
skipping init(). Calling it eagerly is a latency optimization: it
moves the one-time cost of allocating and building the tables off the
hot path, and avoids every thread that happens to hit the lazy path
first stalling behind whichever one wins the initialization race.
Examples found in repository?
examples/bench_cpc_update.rs (line 302)
298fn main() {
299 let (counts, reps) = parse_args();
300
301 // Off the hot path on purpose -- see the module docs.
302 init();
303
304 for items in counts {
305 println!("lg_k={LG_K} items={items} reps={reps}");
306 bench_distinct(items, reps);
307 bench_hot(items, reps);
308 bench_str(items, reps);
309 bench_serde(items, reps);
310 }
311}