This repository has been archived by the owner on Sep 16, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 30
Optimizing your project
joakimk edited this page Dec 6, 2010
·
4 revisions
Also see deployment optimization tips.
Set "rsync_ignores" in config/testbot.yml (or by --rsync_ignores).
To make rsync fast:
- All developer rsync copies should be about the same size.
- The rsynced directory should be as small as possible.
It's faster than the official ruby release. Also, you can experiment with GC settings.
In testbot.rake:
class CacheTool
def initialize(part)
@part = part
end
def cache
system "mkdir -p #{cache_dir}"
cache_key = yield(:generate_cache_key, cache_dir).chomp
if File.exists?(cache_file)
old_key = File.read(cache_file).chomp
if old_key != cache_key
yield(:build, cache_dir)
else
yield(:restore, cache_dir)
end
else
yield(:build, cache_dir)
end
File.open(cache_file, 'w') do |file|
file.write(cache_key)
end
end
def self.clear_all_caches!
system "rm -rf /tmp/.testbot_cache_*"
end
private
def cache_dir
cache_file + "_data"
end
def cache_file
@cache_file ||= "/tmp/.testbot_cache_#{Dir.pwd.split('/').last}_#{@part}"
end
end
# This is run on the developer box
task :before_request do
# system "git log -1 vendor/gems|grep commit > .testbot_gem_cache_key"
system "git log -1 db/schema.rb|grep commit > .testbot_db_cache_key"
end
# This is run on the runner/worker box
task :before_run do
#CacheTool.clear_all_caches!
CacheTool.new('databases').cache do |type, cache_dir|
if type == :generate_cache_key
File.read('.testbot_db_cache_key')
elsif type == :build
# Recreate your database here
elsif type == :restore
# Typically not used for DB cache. We use it to restore built gems.
end
end
end