Skip to content
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

Full scan in queue.statistics() #92

Open
derElektrobesen opened this issue Jul 25, 2019 · 1 comment
Open

Full scan in queue.statistics() #92

derElektrobesen opened this issue Jul 25, 2019 · 1 comment

Comments

@derElektrobesen
Copy link

  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.

olegrok added a commit that referenced this issue Jul 25, 2019
olegrok added a commit that referenced this issue Jul 25, 2019
olegrok added a commit that referenced this issue Feb 26, 2020
@olegrok
Copy link
Contributor

olegrok commented Feb 26, 2020

In de0a346 we removed redundant fullscan from build stats

We can think about implementing a view that build stats on start and increment it then (see #93)

@Totktonada Totktonada added 5sp backlog Issues for upcoming releases (to be done soon) prio4 labels Dec 21, 2020
@Totktonada Totktonada removed backlog Issues for upcoming releases (to be done soon) prio4 labels Feb 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants