Problems with ActiveStorage variants in Rails 6.1

I was curious if anyone else has been using ActiveStorage after an upgrade to Rails 6.1? I use it for vglist and when I turned on variant tracking the site slowed down a lot. I ended up needing to disable it and that broke some of the images that had already been converted to be tracked inside the DB.

Is there a Rake task I can use to generate the variants for all existing images in my database? And has anyone else experienced performance issues with the new track_variants option?

I saw some feedback about the n+1 potential in variant tracking: https://github.com/rails/rails/pull/37901#issuecomment-723878166

Do you think that’s the issue you had too?

I saw that as well, I think it might be relevant but I wasn’t sure. I had assumed it’d fix itself after the records were created and that the record creation was the primary source of slowdown, but I haven’t really looked into the performance details or anything.

For anyone else who runs into this problem, I ended up writing a Rake task to generate variants for all the existing images on my site all at once, which I describe/show in my answer here: ruby on rails - Rake task for creating database records for all existing ActiveStorage variants - Stack Overflow

2 Likes