collector.histogram is slow

Aperta
#461 2 commenti 0 reazioni 1 assegnatario Vedi su GitHub

@yngvar-antonsson ci sta già lavorando.

Dal 13/9/2023.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

feature

collector histogram is just bunch of counters, it is too bad for it to be slow. I've slightly rewrite collectors/histogram to speed it up:

With constant labels for each observe

127.0.0.1:3301> clock.bench(function() local lbls = {method='api.users.get',ok='true'} local prev = clock.time() for _ = 1, 1e6 do api_timings_hist:observe(clock.time()-prev, lbls) prev = clock.time() end end)
---
- - 16.211009
...

127.0.0.1:3301> clock.bench(function() local lbls = {method='api.users.get',ok='true'} local prev = clock.time() for _ = 1, 1e6 do api_timings_fast:observe(clock.time()-prev, lbls) prev = clock.time() end end)
---
- - 1.884366
...

Without labels on observe

127.0.0.1:3301> clock.bench(function() local prev = clock.time() for _ = 1, 1e6 do api_timings_hist:observe(clock.time()-prev) prev = clock.time() end end)
---
- - 10.5773
...
127.0.0.1:3301> clock.bench(function() local prev = clock.time() for _ = 1, 1e6 do api_timings_fast:observe(clock.time()-prev) prev = clock.time() end end)
---
- - 1.810581
...

Source code of FastHistogram is available on my gist: https://gist.github.com/ochaton/305e4668b41e2721b82b92217d74c9ba

Initialisation

local metrics = require 'metrics'
local metrics_fast_hist = require 'metrics.fast'

metrics.set_global_labels({
	app_name = 'bench',
	instance_name = 'bench_001',
})

local api_timings_fast = metrics_fast_hist:new('api_call', 'Histogram of API call',nil, {})
local api_timings_hist = metrics.histogram('api_call_hist', 'Histogram of API call',nil, {})

rawset(_G, 'api_timings_hist', api_timings_hist)
rawset(_G, 'api_timings_fast', api_timings_fast)

@yngvar-antonsson please take a look, and me you'll suggest better approach to increase perfomance of metrics/histogram

Lingua principale
Lua
Stelle
40
Fork
30
Merge medio
2g 14h
PR unite (30g)
3

Preparare l'ambiente

  • Nessun Dockerfile né file Docker Compose
  • Ha un modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di tarantool/metrics

Tutte le issue di tarantool/metrics

Issue simili

Altre issue su Lua

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.