PERF: Make stylesheet max_file_mtime calculation more efficient (#12876)

Plugins always store their stylesheets under `/assets/stylesheets`, so we can make the glob pattern much more specific. In my local development environment, this increases the speed of `Stylesheet::Manager.max_file_mtime` from ~65ms to ~3ms (20x faster). This significantly improves stylesheet regeneration time, and the responsiveness of the theme admin UI.

Note that this will have negligible effect in production, because in production the value of `max_file_mtime` is aggressively cached.
This commit is contained in:
David Taylor 2021-04-28 17:27:18 +01:00 committed by GitHub
parent ced5463ffb
commit 7568c7a101
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -208,7 +208,7 @@ class Stylesheet::Manager
Discourse.plugins.map { |plugin| File.dirname(plugin.path) }.each do |path| Discourse.plugins.map { |plugin| File.dirname(plugin.path) }.each do |path|
globs << "#{path}/plugin.rb" globs << "#{path}/plugin.rb"
globs << "#{path}/**/*.*css" globs << "#{path}/assets/stylesheets/**/*.*css"
end end
globs.map do |pattern| globs.map do |pattern|