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.
Scylla in-source tests.
For details on how to run the tests, see docs/dev/testing.md
Shared C++ utils, libraries are in lib/, for Python - pylib/
alternator - Python tests which connect to a single server and use the DynamoDB API unit, boost, raft - unit tests in C++ cqlpy - Python tests which connect to a single server and use CQL topology* - tests that set up clusters and add/remove nodes cql - approval tests that use CQL and pre-recorded output rest_api - tests for Scylla REST API Port 9000 scylla-gdb - tests for scylla-gdb.py helper script nodetool - tests for C++ implementation of nodetool
If you can use an existing folder, consider adding your test to it. New folders should be used for new large categories/subsystems, or when the test environment is significantly different from some existing suite, e.g. you plan to start scylladb with different configuration, and you intend to add many tests and would like them to reuse an existing Scylla cluster (clusters can be reused for tests within the same folder).
To add a new folder, create a new directory, and then
copy & edit its suite.ini.