Skip to content

Commit

Permalink
Give each thread a chunk of 100 keys at a time to truncate
Browse files Browse the repository at this point in the history
  • Loading branch information
noahhl committed Sep 3, 2012
1 parent 676ea23 commit cd9fbd5
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/batsd/truncator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,12 @@ def run(retention)
keys.each { |key| @redis.truncate_zset(key, min_ts) }
else
# Stored on disk
keys.each do |key|
key = "#{key}:#{retention}"
@threadpool.queue @diskstore, key, min_ts do |diskstore, key, min_ts|
diskstore.truncate(diskstore.build_filename(key), min_ts)
keys.each_slice(100) do |keys|
@threadpool.queue @diskstore, keys, retention, min_ts do |diskstore, keys, retention, min_ts|
keys.each do |key|
key = "#{key}:#{retention}"
diskstore.truncate(diskstore.build_filename(key), min_ts)
end
end
end
while @threadpool.size > 0
Expand Down

0 comments on commit cd9fbd5

Please sign in to comment.