mirror of
https://github.com/discourse/discourse.git
synced 2025-05-21 18:12:32 +08:00
PERF: Memoize core svgs in memory to avoid expensive XML parsing.
The XML parsing of SVGs is done whenever the cache expires or on the first load after a reboot. In one of our production instance, parsing ranges from 30ms to 70ms which is not ideal. Instead, we've decided to make a small memory trade off here by memoizing the core SVGs once on boot to avoid parsing of the SVG files during the duration of a request. The memozied hash will take up 57440 bytes or 0.05744 megabytes in size.
This commit is contained in:
@ -914,9 +914,9 @@ module Discourse
|
||||
|
||||
schema_cache = ActiveRecord::Base.connection.schema_cache
|
||||
|
||||
# load up schema cache for all multisite assuming all dbs have
|
||||
# an identical schema
|
||||
RailsMultisite::ConnectionManagement.safe_each_connection do
|
||||
# load up schema cache for all multisite assuming all dbs have
|
||||
# an identical schema
|
||||
dup_cache = schema_cache.dup
|
||||
# this line is not really needed, but just in case the
|
||||
# underlying implementation changes lets give it a shot
|
||||
@ -948,6 +948,9 @@ module Discourse
|
||||
},
|
||||
Thread.new {
|
||||
LetterAvatar.image_magick_version
|
||||
},
|
||||
Thread.new {
|
||||
SvgSprite.core_svgs
|
||||
}
|
||||
].each(&:join)
|
||||
ensure
|
||||
|
Reference in New Issue
Block a user