mirror of
https://github.com/scylladb/scylladb.git
synced 2026-05-12 19:02:12 +00:00
Before this patch, every expression in Alternator's requests was parsed from string to adequate structure. This patch enables caching, where input expression strings are mapped to parsed template structures. Every new valid (parsable) expression is added to the cache. The cache has limited (configurable) size - when it is reached, the least recently used entry is removed. When requested expression is in the cache, the copy of the template is returned - individual instances still need to be resolved (placeholders substituted with names and values). Caching is implemented for all expression types. The cache is per shard - shared for all operations, expression types, tables, users. Default cache size is 2000 entries per shard and it has configuration option `alternator_max_expression_cache_entries_per_shard` (0 means cache disabled). Basic metrics (total count of hits and misses for each expression type and number of evicted enries) are implemented. Cache features are tested in boost unit tests and overall expression caching is tested with Python tests - both mostly rely on metrics. refs #5023 `perf-alternator` test shows improvement (median): | test | throughput | instructions_per_op | cpu_cycles_per_op | allocs_per_op | | ------ | ---------------- | ----------------------------- | --------------------------- | ------------------- | | read | +6.0% | -8.5% | -7.0% | -4.9% | | write | +13.4% | -17.6% | -14.7% | -7.4% | | write(lwt) | +12.7% | -7.9% | -6.9% | -2.8% | | write_rwm | +5.4% | -10.5% | -7.3% | -4.1% | "read" had a ProjectionExpression with 10 column names, "write" had a UpdateExpression with 10 column names and "write_rmw" had both ConditionExpression and UpdateExpression. This patch also includes minor refactoring of other expressions related tests (https://github.com/scylladb/scylladb/issues/22494) - use `test_table_ss` instead of `test_table`. Fixes #25855. This is new feature - no backporting. Closes scylladb/scylladb#25176 * github.com:scylladb/scylladb: alternator: use expression caching alternator: adds expression cache implementation utils: extend lru_string_map utils: add lru_string_map alternator/expressions: error on parsing empty update expression alternator/expressions: fix single value condition expression parsing test/alternator: use `test_table_ss` instead of `test_table` in expressions related tests.