Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(server): optimize mapAsset #7331

Merged
merged 1 commit into from Feb 22, 2024
Merged

perf(server): optimize mapAsset #7331

merged 1 commit into from Feb 22, 2024

Conversation

michelheusschen
Copy link
Contributor

@michelheusschen michelheusschen commented Feb 22, 2024

Noticed the mapAsset function was taking way too long. This seems to be caused by the object spread syntax, after removing it performance got much better.

Tested using AssetService.getTimeBuckets, specifically when the mapAsset(asset, { withStack: true }) case gets returned. It would be useful to know if someone else can replicate these results (only includes calls to mapAsset function, nothing else).

Assets Before After
100 3ms <1ms
1000 26ms 1ms
10000 397ms 6ms

Copy link

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: 13b2a37
Status: ✅  Deploy successful!
Preview URL: https://a274395e.immich.pages.dev
Branch Preview URL: https://perf-server-mapasset.immich.pages.dev

View logs

Copy link
Contributor

@jrasm91 jrasm91 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There have been reports of slowness in this method specifically.

@jrasm91
Copy link
Contributor

jrasm91 commented Feb 22, 2024

I was able to validate that calling mapAlbum on an album with 1,000 assets took 40ms before and 3ms after.

@jrasm91 jrasm91 merged commit ec55acc into main Feb 22, 2024
28 checks passed
@jrasm91 jrasm91 deleted the perf/server-mapasset branch February 22, 2024 13:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants