Full scan in `queue.statistics()`
Open
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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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