Skip to content
Browse files

Reduce mkdir -p load.

Don't go crazy running FileUtils.mkdir_p every time we
calculate a filename -- we only really need to check that
a directory exists when we're storing a value, so only do
it there.

Also, bring a couple of workers back into the config
  • Loading branch information...
1 parent 94a94c8 commit ba8ea4799c86e17f3ab6614d3950d8013194105f @noahhl committed Mar 2, 2012
Showing with 2 additions and 2 deletions.
  1. +1 −1 config.yml
  2. +1 −1 lib/statsd_server/diskstore.rb
View
2 config.yml
@@ -11,7 +11,7 @@ cleanup_interval: 3000
#Number of aggregation and diskwriting workers to spawn.
#Default is one
-workers: 0
+workers: 2
# Redis
redis_host: localhost
View
2 lib/statsd_server/diskstore.rb
@@ -8,7 +8,6 @@ class << self
def calc_filename(statistic)
return unless statistic
file_hash = Digest::MD5.hexdigest(statistic)
- FileUtils.mkdir_p File.join($config["coalmine_data_path"], file_hash[0,2], file_hash[2,2])
File.join($config["coalmine_data_path"], file_hash[0,2], file_hash[2,2], file_hash)
end
@@ -25,6 +24,7 @@ def enqueue_gauge(type, statistic, *args)
end
def store!(filename, value)
+ FileUtils.mkdir_p filename.split("/")[0..-2].join("/")
File.open(filename, 'a+') do |file|
file.write("#{value}\n")
file.close

0 comments on commit ba8ea47

Please sign in to comment.
Something went wrong with that request. Please try again.