mirror of
https://github.com/hibiken/asynq.git
synced 2025-04-20 07:40:19 +08:00
Fix memory_usage lua script
This commit is contained in:
parent
8a4fb71dd5
commit
0cfa7f47ba
@ -293,8 +293,9 @@ for i=3,6 do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
local group_names = redis.call("SRANDMEMBER", KEYS[7], tonumber(ARGV[3]))
|
local group_names = redis.call("SRANDMEMBER", KEYS[7], tonumber(ARGV[3]))
|
||||||
local group_sample_total = 0
|
if (table.getn(group_names) > 0) then
|
||||||
for _, gname in ipairs(group_names) do
|
local group_sample_total = 0
|
||||||
|
for _, gname in ipairs(group_names) do
|
||||||
local group_key = ARGV[4] .. gname
|
local group_key = ARGV[4] .. gname
|
||||||
local ids = redis.call("ZRANGE", group_key, 0, sample_size - 1)
|
local ids = redis.call("ZRANGE", group_key, 0, sample_size - 1)
|
||||||
local sample_total = 0
|
local sample_total = 0
|
||||||
@ -311,10 +312,11 @@ for _, gname in ipairs(group_names) do
|
|||||||
if (m) then
|
if (m) then
|
||||||
group_sample_total = group_sample_total + m
|
group_sample_total = group_sample_total + m
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
local group_size = redis.call("SCARD", KEYS[7])
|
||||||
|
local group_memusg_avg = group_sample_total / table.getn(group_names)
|
||||||
|
memusg = memusg + (group_memusg_avg * group_size)
|
||||||
end
|
end
|
||||||
local group_size = redis.call("SCARD", KEYS[7])
|
|
||||||
local group_memusg_avg = group_sample_total / table.getn(group_names)
|
|
||||||
memusg = memusg + (group_memusg_avg * group_size)
|
|
||||||
return memusg
|
return memusg
|
||||||
`)
|
`)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user