tarantool / tarantool/queue

Full scan in `queue.statistics()`

Open
#92 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

performance
Dominant language
Lua
Stars
244
Forks
56
PR merge metrics
No merged PRs in 30d

Description

  1 local function build_stats(space)
  2     local stats = {tasks = {}, calls = {
  3         ack  = 0, bury  = 0, delete  = 0,
  4         kick = 0, put   = 0, release = 0,
  5         take = 0, touch = 0,
  6         -- for *ttl queues only
  7         ttl  = 0, ttr   = 0, delay   = 0,
  8     }}
  9
 10     local st = rawget(queue.stat, space) or {}
 11     local idx_tube = 1
 12
 13     -- add api calls stats
 14     for name, value in pairs(st) do
 15         if type(value) ~= 'function' and name ~= 'done' then
 16             stats['calls'][name] = value
 17         end
 18     end
 19
 20     -- add total tasks count
 21     stats['tasks']['total'] = box.space[space].index[idx_tube]:count()
 22
 23     -- add tasks by state count
 24     for i, s in pairs(state) do
 25         stats['tasks'][i:lower()] = box.space[space].index[idx_tube]:count(s)
 26     end
 27     stats['tasks']['done'] = st.done or 0
 28
 29     return stats
 30 end

This function calls count() 6 times on each queue.statistics(). This could be a reason of very aggressive CPU usage if there are very many tasks in the queue.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at queue.statistics() and its local build_stats(space) implementation shown in the issue; profile the repeated index:count() calls with large queues to confirm the CPU impact. Define and verify a change that preserves total, per-state, and done task counts while addressing the reported aggressive usage.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.