test: perf: add --audit-rules option to perf-simple-query

Allow perf-simple-query to compare audit-rule matching
with the category/keyspace/table audit filters under
the same workload.

Register a hardcoded "tester" role with the audit cache
so rules targeting that role exercise the preprocessed
fast path.

The new option was used to measure audit-rules
performance against the category/keyspace/table audit
config. The results are as follows:

===============================================================================================================================================================================
Configuration                                     | Binary     |         throughput (tps) | insns/op                 | cpu_cycles/op            | alloc/op | logal/op | task/op
===============================================================================================================================================================================
audit=none [1]                                    | baseline   |                 206922.4 |                  36591.6 |                  15348.3 |     58.1 |      0.0 |    14.1
audit=none [1]                                    | this PR    |        207856.4  (+0.5%) |         36544.9  (-0.1%) |         15274.0  (-0.5%) |     58.1 |      0.0 |    14.1
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
audit=syslog keyspaces=ks [2]                     | baseline   |                  94871.8 |                  54163.0 |                  27172.4 |     72.0 |      0.0 |    24.0
audit=syslog keyspaces=ks [2]                     | this PR    |         96138.4  (+1.3%) |         54072.3  (-0.2%) |         26699.3  (-1.7%) |     72.0 |      0.0 |    24.0
audit=syslog audit-rules=ks [3]                   | this PR    |         95142.1  (+0.3%) |         54457.8  (+0.5%) |         26953.8  (-0.8%) |     72.0 |      0.0 |    24.0
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
audit=syslog keyspaces=ks-non-existent [4]        | baseline   |                 213997.8 |                  36735.6 |                  14848.1 |     58.1 |      0.0 |    14.1
audit=syslog keyspaces=ks-non-existent [4]        | this PR    |        219297.2  (+2.5%) |         36667.3  (-0.2%) |         14500.1  (-2.3%) |     58.1 |      0.0 |    14.1
audit=syslog audit-rules=ks-non-existent [5]      | this PR    |        211038.7  (-1.4%) |         36999.7  (+0.7%) |         15048.6  (+1.4%) |     58.1 |      0.0 |    14.1
===============================================================================================================================================================================

[1] ./scylla perf-simple-query --smp 1 --duration 100 --audit "none"
[2] ./scylla perf-simple-query --smp 1 --duration 100 --audit "syslog" --audit-keyspaces "ks" --audit-categories "DCL...
[3] ./scylla perf-simple-query --smp 1 --duration 100 --audit "syslog" --audit-rules '[{"sinks":["syslog"],"categorie...
[4] ./scylla perf-simple-query --smp 1 --duration 100 --audit "syslog" --audit-keyspaces "ks-non-existent" --audit-ca...
[5] ./scylla perf-simple-query --smp 1 --duration 100 --audit "syslog" --audit-rules '[{"sinks":["syslog"],"categorie...

audit-null.sock was created with `socat -u UNIX-RECV:/tmp/audit-null.sock,type=2 OPEN:/dev/null`

Refs SCYLLADB-1430
This commit is contained in:
Andrzej Jackowski
2026-04-09 09:12:19 +02:00
parent f4acf91949
commit f39c48648a

View File

@@ -28,6 +28,8 @@
#include "db/extensions.hh"
#include "db/tags/extension.hh"
#include "gms/gossiper.hh"
#include "audit/audit.hh"
#include "audit/audit_rule.hh"
static const sstring table_name = "cf";
@@ -347,6 +349,7 @@ int scylla_simple_query_main(int argc, char** argv) {
("audit-tables", bpo::value<std::string>(), "value for audit_tables config entry")
("audit-categories", bpo::value<std::string>(), "value for audit_categories config entry")
("audit-unix-socket-path", bpo::value<std::string>(), "value for audit_unix_socket_path config entry")
("audit-rules", bpo::value<std::string>(), "JSON value for audit_rules config entry")
;
set_abort_on_internal_error(true);
@@ -386,6 +389,9 @@ int scylla_simple_query_main(int argc, char** argv) {
set_from_cli("audit-tables", app, cfg.db_config->audit_tables);
set_from_cli("audit-categories", app, cfg.db_config->audit_categories);
set_from_cli("audit-unix-socket-path", app, cfg.db_config->audit_unix_socket_path);
if (app.configuration().contains("audit-rules")) {
cfg.db_config->audit_rules(audit::parse_audit_rules_from_json(app.configuration()["audit-rules"].as<std::string>()));
}
return do_with_cql_env_thread([&app] (auto&& env) {
auto cfg = test_config();
cfg.partitions = app.configuration()["partitions"].as<unsigned>();
@@ -427,6 +433,9 @@ int scylla_simple_query_main(int argc, char** argv) {
auto audit_storage_stop = defer([] {
audit::audit::stop_storage().get();
});
audit::audit::audit_instance().invoke_on_all([] (audit::audit& a) {
a.on_role_created("tester");
}).get();
auto results = do_cql_test(env, cfg);
aggregated_perf_results agg(results);
std::cout << agg << std::endl;