-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implementation of HistogramVec by providing LuaC bindings to Rust module prometheus #502
base: master
Are you sure you want to change the base?
Conversation
It would be cool to run |
@vasiliy-t as requested, added benchmarks for 2 and 3 labels
For 1 label was used
In fact, Rust.gather is faster, because it returns final LuaString, which is used as a response body to http client, while Lua collect will build LuaString from LuaTable.
.rocks/bin/luabench -d 3s
Tarantool version: Tarantool 3.3.0-0-g5fc82b8
Tarantool build: Darwin-arm64-RelWithDebInfo (static)
Tarantool build flags: -fexceptions -funwind-tables -fasynchronous-unwind-tables -fno-common -fmacro-prefix-map=/var/folders/8x/1m5v3n6d4mn62g9w_65vvt_r0000gn/T/tarantool_install1980638789=. -std=c11 -Wall -Wextra -Wno-gnu-alignof-expression -Wno-cast-function-type -O2 -g -DNDEBUG -ggdb -O2
CPU: Apple M1 @ 8
JIT: Disabled
Duration: 3s
Global timeout: 60
--- BENCH: histogram_bench::bench_001_no_labels_001_observe:histogram:observe --- BENCH: histogram_bench::bench_001_no_labels_001_observe:histogram_vec:observe --- BENCH: histogram_bench::bench_001_no_labels_002_collect:histogram:collect --- BENCH: histogram_bench::bench_001_no_labels_002_collect:histogram_vec:collect --- BENCH: histogram_bench::bench_001_no_labels_002_collect:histogram_vec:collect_str --- BENCH: histogram_bench::bench_002_one_label_001_observe:histogram:observe --- BENCH: histogram_bench::bench_002_one_label_001_observe:histogram_vec:observe --- BENCH: histogram_bench::bench_002_one_label_002_collect:histogram:collect --- BENCH: histogram_bench::bench_002_one_label_002_collect:histogram_vec:collect --- BENCH: histogram_bench::bench_002_one_label_002_collect:histogram_vec:collect_str --- BENCH: histogram_bench::bench_002_two_labels_001_observe:histogram:observe --- BENCH: histogram_bench::bench_002_two_labels_001_observe:histogram_vec:observe --- BENCH: histogram_bench::bench_002_two_labels_002_collect:histogram:collect --- BENCH: histogram_bench::bench_002_two_labels_002_collect:histogram_vec:collect --- BENCH: histogram_bench::bench_002_two_labels_002_collect:histogram_vec:collect_str --- BENCH: histogram_bench::bench_003_three_labels_001_observe:histogram:observe --- BENCH: histogram_bench::bench_003_three_labels_001_observe:histogram_vec:observe --- BENCH: histogram_bench::bench_003_three_labels_002_collect:histogram:collect --- BENCH: histogram_bench::bench_003_three_labels_002_collect:histogram_vec:collect --- BENCH: histogram_bench::bench_003_three_labels_002_collect:histogram_vec:collect_str --- BENCH: histogram_bench::bench_004_lua_gather --- BENCH: histogram_bench::bench_004_rust_gather |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't know a thing about rust, tests seem convincing.
The main issue will be embedding this one to the tarantool core since, after 2.11.1, tarantool has metrics
as a built-in package, and adding rust to a core build system will likely be a bother (both technically and ideologically).
Co-authored-by: Georgy Moiseev <[email protected]>
As @ligurio mentioned, benchmark was made on Apple @ M1 with disabled jit. I've rerun benchmark on VK Cloud VM (4 vCPU, 4Gb RAM, no drive used, Load-Average before benchmark ≈ 0.21). Results below. Unfortunately, I was able to install Tarantool 2.10.7
.rocks/bin/luabench -d 3s
Tarantool version: Tarantool 2.10.7-0-g60f7e18 Tarantool build: Linux-x86_64-RelWithDebInfo (static) Tarantool build flags: -static-libstdc++ -fexceptions -funwind-tables -fno-common -fopenmp -msse2 -Wformat -Wformat-security -Werror=format-security -fstack-protector-strong -fPIC -fmacro-prefix-map=/tmp/tarantool_install35630681=. -std=c11 -Wall -Wextra -Wno-strict-aliasing -Wno-char-subscripts -Wno-format-truncation -Wno-gnu-alignof-expression -fno-gnu89-inline -Wno-cast-function-type CPU: Intel Xeon Processor (Skylake, IBRS) @ 2095.076MHz JIT: Enabled Duration: 3s --- BENCH: histogram_bench::bench_001_no_labels_001_observe:histogram:observe --- BENCH: histogram_bench::bench_001_no_labels_001_observe:histogram_vec:observe --- BENCH: histogram_bench::bench_001_no_labels_002_collect:histogram:collect --- BENCH: histogram_bench::bench_001_no_labels_002_collect:histogram_vec:collect --- BENCH: histogram_bench::bench_001_no_labels_002_collect:histogram_vec:collect_str --- BENCH: histogram_bench::bench_002_one_label_001_observe:histogram:observe --- BENCH: histogram_bench::bench_002_one_label_001_observe:histogram_vec:observe --- BENCH: histogram_bench::bench_002_one_label_002_collect:histogram:collect --- BENCH: histogram_bench::bench_002_one_label_002_collect:histogram_vec:collect --- BENCH: histogram_bench::bench_002_one_label_002_collect:histogram_vec:collect_str --- BENCH: histogram_bench::bench_002_two_labels_001_observe:histogram:observe --- BENCH: histogram_bench::bench_002_two_labels_001_observe:histogram_vec:observe --- BENCH: histogram_bench::bench_002_two_labels_002_collect:histogram:collect --- BENCH: histogram_bench::bench_002_two_labels_002_collect:histogram_vec:collect --- BENCH: histogram_bench::bench_002_two_labels_002_collect:histogram_vec:collect_str --- BENCH: histogram_bench::bench_003_three_labels_001_observe:histogram:observe --- BENCH: histogram_bench::bench_003_three_labels_001_observe:histogram_vec:observe --- BENCH: histogram_bench::bench_003_three_labels_002_collect:histogram:collect --- BENCH: histogram_bench::bench_003_three_labels_002_collect:histogram_vec:collect --- BENCH: histogram_bench::bench_003_three_labels_002_collect:histogram_vec:collect_str --- BENCH: histogram_bench::bench_004_lua_gather --- BENCH: histogram_bench::bench_004_rust_gather |
I suggest you to look at PoC (IMO good enough) which demonstrates power of Lua-bindings to Rust ecosystem, and how it can be used to greatly solve our performance issues in tarantool/metrics.
I've implemented only HistogramVec with slight change of API:
label_names
on creation ofHistogramVec
(HistogramVec:new()
), and pass all of the values inHistogram:observe(value, <kv-label_pairs>)
HistogramVec:collect()
is slower thanHistogram:collect()
because it has to copy Rust-strings into LuaStrings and allocate many LuaTables.:collect()
mainly used for export metrics via http-server, and they basically are converted into String anyway. SoHistogramVec:collect_str()
can be used for that, it just builds final strings which prometheus can understand.global_label_pairs
, Rust Registry is implemented, which storesglobal_label_pairs
. Everywhere we need to resetglobal_label_pairs
we should pass a copy of them into Rust.PoC for #461
Motivation - Performance increase (Results)
No labels - means, Histogram is created without custom labels. Meaning, if User does not use labels, he must not pay for them.
1 label - means, Histogram support single label_key. Mostly used to add boolean
ok = false|true
label.Table that follows shows performance increase of overall collect of all histogram collectors.
Build of Rust part is already orchestrated using CMake, so
make test
,make .rocks
and others should work fine. You can repeat my benchmarks usingmake bench
.What's next to decide: