Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently any use of the
{% svg_icon %}
template tag loads the SVG contents from disk. This commit modifies that behavior so that SVG icons are cached in memory, to avoid the need to load from file each time.In our icon library icon files range from 220 bytes to 2.6 KB in size. The total size of all icons is 2.8 MB.
Closes internal https://github.local/CFGOV/platform/issues/3667.
How to test this PR
Everything should work the same, just slightly faster at the expense of slightly greater memory usage.
Locally,
SKIP_DJANGO_MIGRATIONS=1 tox -e unittest
takes 285s vs 291s for me on main, as an example of code that does a whole bunch of icon loads. On our production instances, we don't limit memory usage for mod_wsgi. Our prod servers are t3.2xlarge which have 32GB of RAM. By inspection each of our running Apache processes can consume ~1GB so an extra 2.8MB isn't significant.Checklist