Improve image optimization run-time and memory usage #457
Labels
No Label
a11y
Backlog
Blocked
Bug
Content
Dependencies
Design
Feature Request
Good First Issue
In Progress
Performance
Priority - High
Priority - Low
Priority - Medium
Untriaged
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: www/www-new#457
Loading…
Reference in New Issue
No description provided.
Delete Branch "amy-image-optimization-quick-fix"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This PR aims to resolve the issues surrounding the optimize-images script, at least in the short term, in order to unblock other work.
Problems: Our optimize-images script was taking a very long time to run (~7 minutes in CI, when successful). This led to two problems:
Solutions:
images/events
prior to optimizing them, similar to what is done for the images inimages/team
. This solution on its own reduced the run-time of the script to ~30 seconds locally on Amy's laptop, which is comparable to the run-time of the script back when it was originally written.As a temporary fix, this PR also replaces the images inimages/events
with their resized + optimized versions. (For some unknown reason, Solution 1 is not sufficient to solve Problem 2.)This PR also adds some logging to the script so we can get a (slightly) better sense of where the script is getting stuck.
Related issue: #456
Improve image optimization run-timeto WIP: Improve image optimization run-time (quick fix)WIP: Improve image optimization run-time (quick fix)to Improve image optimization run-time (quick fix)Improve image optimization run-time (quick fix)to Improve image optimization run-time - quick fixNice catch!! Makes sense why those specific images were taking so long now… this solution is great!
I think this solution is good enough to solve our problems for now. In the future, we should consider an alternative image storage mechanism anyway...
@ -35,6 +37,8 @@ const ENCODER_OPTIONS: { [encoder: string]: Record<string, unknown> } = {
void optimizeImages();
export async function optimizeImages() {
const startTime = Date.now();
By the way, JavaScript has a built in
console.time()
https://developer.mozilla.org/en-US/docs/Web/API/console/time
Improve image optimization run-time - quick fixto Improve image optimization run-timeImprove image optimization run-timeto Improve image optimization run-time and memory usageRe-requested reviews because I made a pretty significant change - see PR description for update
"Revert "Revert "Revert
:)