11 Commits
Author SHA1 Message Date
Azat Khuzhin 04feb2203f Optimize Profile Events by using Per CPU counters for server-wide and users
Note, I've tried to use librseq, but looks like it does not worth it,
for read it may get up to 16%, while contended atomic vs uncontended is
30x.

Though rseq can also help with contention between write and read sides,
but it is also neglectible, it is only around 40ns win for p99+, while
complete read of all counters (for metric_log) is 2us vs 38us, yes, it
is 19x more, but it is still only 38us, and unlikely the contention is a
problem there.

v2: switch users to shared counter - 30x faster
v3: use NPROC over MAX_CPUs
v4: remove atomic pointer in ctor
v5: rename shard → per_cpu
v6: cache-line-align ProfileEvents per-CPU rows
v7: Add benchmark for ProfileEvents under 500 threads × 50 groups
v8: Drop librseq from ProfileEvents per-CPU sharding (does not give lots of benefit)

    per-cpu atomic
    ==============
    Benchmark                                               Time             CPU   Iterations UserCounters...
    ---------------------------------------------------------------------------------------------------------
    BM_ProfileEvents/1000/process_time/real_time        0.948 ms         26.1 ms          694 groups=50 incs/thread/step=1.44092 items_per_second=527.21M/s ns/inc=1.89678ns threads=500 users=1
    BM_ProfileEvents/10000/process_time/real_time        5.13 ms          213 ms          110 groups=50 incs/thread/step=90.9091 items_per_second=975.257M/s ns/inc=1025.37ps threads=500 users=1
    BM_ProfileEvents/100000/process_time/real_time       38.3 ms         1862 ms           18 groups=50 incs/thread/step=5.55556k items_per_second=1.30592G/s ns/inc=765.745ps threads=500 users=1

    rseq
    ==============
    Benchmark                                               Time             CPU   Iterations UserCounters...
    ---------------------------------------------------------------------------------------------------------
    BM_ProfileEvents/1000/process_time/real_time        0.875 ms         22.3 ms          753 groups=50 incs/thread/step=1.32802 items_per_second=571.651M/s ns/inc=1.74932ns threads=500 users=1
    BM_ProfileEvents/10000/process_time/real_time        4.64 ms          175 ms          156 groups=50 incs/thread/step=64.1026 items_per_second=1076.95M/s ns/inc=928.552ps threads=500 users=1
    BM_ProfileEvents/100000/process_time/real_time       34.6 ms         1576 ms           20 groups=50 incs/thread/step=5k items_per_second=1.44688G/s ns/inc=691.142ps threads=500 users=1

v9: Add user_profile_events_per_cpu server setting
v10: Cache-line-align the per-user ProfileEvents counter allocation
v11: Resolve sched_getcpu once per logical ProfileEvents increment
v12: More benchmarks
2026-07-02 09:40:48 +02:00
Sema Checherinda 774beb06f0 ThreadName 2025-11-11 12:14:07 +01:00
Sema Checherinda ffe7ebd505 thread name is an enumn 2025-11-10 19:02:12 +01:00
Raúl Marín d6ac63c8d2 Style: Forbid the use of quotes for includes (partial) 2025-06-24 13:20:10 +02:00
Azat Khuzhin c64f9e6f07 Use StrongTypedef for ProfileEvents
Signed-off-by: Azat Khuzhin <[email protected]>
2023-04-01 16:01:33 +02:00
Azat Khuzhin 8d0e516310 Use StrongTypedef for CurrentMetrics to avoid possible incorrect usage
Signed-off-by: Azat Khuzhin <[email protected]>
2023-04-01 16:01:33 +02:00
Antonio Andelic 96838f5be7 Merge branch 'master' into keeper-prometheus 2022-11-15 12:00:02 +00:00
Alexey Milovidov ba05b7dd2c Add documentation for AsynchronousMetrics 2022-11-13 03:36:20 +01:00
Antonio Andelic c92ae5a385 Add suport for AsyncMetrics in standalone Keeper 2022-11-09 13:46:03 +01:00
Amos Bird 4a5e4274f0 base should not depend on Common 2022-04-29 10:26:35 +08:00
IvanandGitHub 97f2a2213e Move all folders inside /dbms one level up (#9974)
* Move some code outside dbms/src folder
* Fix paths
2020-04-02 02:51:21 +03:00