Skip to content

[TASK] Do not process the 1x image twice per tag - #101

Merged
bmack merged 1 commit into
masterfrom
task/no-duplicate-1x-processing
Sep 4, 2026
Merged

[TASK] Do not process the 1x image twice per tag#101
bmack merged 1 commit into
masterfrom
task/no-duplicate-1x-processing

Conversation

@lolli42

@lolli42 lolli42 commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

buildSingleTag() processes the image once to build the tag, then hands the same instruction array to addRetina(), which processes it again to get the 1x URI. Same instructions and same file, so the second call returns the same ProcessedFile and the same URI - it only costs another processed file lookup. For a source tag the result is not even used, because addRetina() falls back to it only when the tag carries no srcset, and a source tag always does.

addRetina() takes the URI as an optional fourth argument now and only resolves it when a caller does not pass one, so overrides and external callers keep working unchanged.

That is a third of all image processing on a page with many images. It shows up most where the processed files do not exist yet: every variant then writes the sys_file_processedfile row, which flushes the runtime cache of that original, so the next variant of the same image queries again. Measured on a page with 128 image tags: 384 processing calls before, 256 after.

buildSingleTag() processes the image once to build the tag, then hands
the same instruction array to addRetina(), which processes it again to
get the 1x URI. Same instructions and same file, so the second call
returns the same ProcessedFile and the same URI - it only costs another
processed file lookup. For a source tag the result is not even used,
because addRetina() falls back to it only when the tag carries no
srcset, and a source tag always does.

addRetina() takes the URI as an optional fourth argument now and only
resolves it when a caller does not pass one, so overrides and external
callers keep working unchanged.

That is a third of all image processing on a page with many images. It
shows up most where the processed files do not exist yet: every variant
then writes the sys_file_processedfile row, which flushes the runtime
cache of that original, so the next variant of the same image queries
again. Measured on a page with 128 image tags: 384 processing calls
before, 256 after.
@bmack
bmack merged commit b2e401e into master Sep 4, 2026
5 checks passed
@bmack
bmack deleted the task/no-duplicate-1x-processing branch September 4, 2026 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants