AssetSync / asset_sync

Synchronises Assets between Rails and S3
1.88k stars 346 forks source link

Advice for performance at AWS CodeBuild? #405

Closed hopewise closed 3 years ago

hopewise commented 3 years ago

Hello

As pre-compilation takes about 20 minutes each time, is there any advice to minimize that time? As we use AWS Codebuild, which uses a compute power to build the docker image, I tried the following:

but the building time was almost the same.

If there are any advice to gain more performance at building, that would be appreciated.

PikachuEXE commented 3 years ago

If it's about asset precompile, this gem won't do anything about it. If you think it's about asset sync being slow, would be great to see some testing (like putting time used on sync vs precompile)

hopewise commented 3 years ago

I have just measured pre-compilation, its about 15 minutes, I am trying to use the previous build image for the new one, so that pre-compilation for only changed assets..

How to measure sync time?

PikachuEXE commented 3 years ago

By looking at https://medium.com/@t2013anurag/rails-adding-global-hooks-for-rake-tasks-7faf0844364

I think (not tested) it would be something like

task :assets_sync_meature_before_hook
  @assets_sync_start_time = Time.current
end
task :assets_sync_meature_after_hook
  end_time = Time.current
  duration = end_time - @assets_sync_start_time
  puts "assets_sync Duration => #{duration}"
end
Rake::Task['assets:sync'].enhance [:assets_sync_meature_before_hook, :assets_sync_meature_before_hook]
hopewise commented 3 years ago

thanks, I will try that when I can