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

refactor(server): group async calls in metadata extraction #16450

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

mertalev
Copy link
Contributor

@mertalev mertalev commented Mar 1, 2025

Description

This PR refactors metadata extraction to increase concurrent asynchronous operations as well as making smaller code improvements, improving overall performance. It is based on #16390, which should be merged first.

Split off from #14277

@mertalev mertalev requested a review from danieldietzler as a code owner March 1, 2025 10:06
@mertalev mertalev force-pushed the refactor/server-metadata-extraction-group-async-calls branch 2 times, most recently from 3f9c211 to a88e6bd Compare March 1, 2025 10:17
use debugFn

no need to change mock
@mertalev mertalev force-pushed the refactor/server-metadata-extraction-group-async-calls branch from a88e6bd to ecdb914 Compare March 1, 2025 10:31
Copy link
Contributor

@alextran1502 alextran1502 left a comment

Choose a reason for hiding this comment

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

Have you run any functional tests related to the changes yet?

@mertalev
Copy link
Contributor Author

mertalev commented Mar 1, 2025

I tested #14277 and refined the different parts of it in each split PR. I haven't tested the individual PRs extensively, but did confirm they work locally with one or two assets.

Copy link
Contributor

@zackpollard zackpollard left a comment

Choose a reason for hiding this comment

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

As far as I can tell this looks good. However I do think there are a lot of changes here, so it'd be good to get some testing done with a range of assets before we merge this and check everything is still handled correctly. Specifically around geo and also tag handling for a number tag or a tag with embedded pipes and slashes

@@ -491,7 +492,7 @@ describe(MetadataService.name, () => {
});
expect(mocks.user.updateUsage).toHaveBeenCalledWith(assetStub.livePhotoMotionAsset.ownerId, 512);
expect(mocks.storage.createFile).toHaveBeenCalledWith(assetStub.livePhotoMotionAsset.originalPath, video);
expect(mocks.asset.update).toHaveBeenNthCalledWith(1, {
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the reason for changing all of these tests to remove the check that they were only called once?

Copy link
Contributor Author

@mertalev mertalev Mar 3, 2025

Choose a reason for hiding this comment

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

They don't check that they were called once, but that the e.g. 1st call looked like this. Since the calls are grouped, there's no clear order anymore. I can make it check that the total call count matches though.

private async mergeExifTags(asset: AssetEntity): Promise<ImmichTags> {
const [mediaTags, sidecarTags, videoTags] = await Promise.all([
this.metadataRepository.readTags(asset.originalPath),
asset.sidecarPath ? this.metadataRepository.readTags(asset.sidecarPath) : null,
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not have this return {} still, now we need extra handling lower down to deal with something we realistically don't care about (the null case).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call, making them null is a holdover from an earlier version of the PR.

Base automatically changed from refactor/link-live-photos-without-job to main March 3, 2025 14:19
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.

3 participants