Skip to content

Significant performance improvement across tagGalleriesFromImages#721

Open
DogmaDragon wants to merge 3 commits into
stashapp:mainfrom
DogmaDragon:tagGalleriesFromImages-update
Open

Significant performance improvement across tagGalleriesFromImages#721
DogmaDragon wants to merge 3 commits into
stashapp:mainfrom
DogmaDragon:tagGalleriesFromImages-update

Conversation

@DogmaDragon
Copy link
Copy Markdown
Contributor

@DogmaDragon DogmaDragon commented May 30, 2026

Related PR #718

@DogmaDragon DogmaDragon added the type:plugin Plugins label May 30, 2026
@discourse-stashapp
Copy link
Copy Markdown

This pull request has been mentioned on Stash Forum. There might be relevant details there:

https://discourse.stashapp.cc/t/tag-galleries-from-images/3904/3

Copy link
Copy Markdown
Contributor

@spaceyuck spaceyuck left a comment

Choose a reason for hiding this comment

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

This seems like a lot of code change noise for a few smallish actual changes:

  • paged gallery loading (fair enough, didn't expect people to have that many galleries)
  • studio gets pushed to gallery too
  • hook into image changes (incomplete)

if exclussion_marker_tag is not None:
exclusion_marker_tag_id = exclussion_marker_tag['id']
if settings["excludeWithTag"]:
if settings["excludeWithTag"] in tag_cache:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I really don't get the point of the tag_cache. processAll() gets invoked once, so there are no repeat lookups of the same thing to cache. And even then, it's a single tag lookup by name at worst. Should be removed if pointless, just added complexity.

processed = 0
page = 1

while True:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Not a huge fan of while loops without an explicit abort condition if there's an option to have one. Any reason processed < total_count is not feasible anymore?

missing_perfs = all_found_performer_ids - existing_perf_ids

target_studio_id = list(all_found_studio_ids)[0] if all_found_studio_ids else None
studio_missing = bool(target_studio_id and (target_studio_id != existing_studio_id))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Performers and tags are additive changes (so manually added tags and performers remain unchanged), but the studio gets overwritten if already set (manually or otherwise). This seems worth talking about, and maybe should be a setting to be enabled if wanted behavior by user.


update_data = {"ids": [gallery_id]}
if missing_tags and all_found_tag_ids:
update_data["tag_ids"] = {"mode": "ADD", "ids": list(all_found_tag_ids)}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why are all tags and performers added again, if the missing IDs are already in missing_tags and missing_tags? Seems like pointless extra work for the server.

processGallery(gallery)

# --- IMAGE HOOK HANDLER ---
elif hook_type in ["Image.Update.Post", "Image.Create.Post"]:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

These image hooks are not declared in the manifest, and will never be called.

Also, should these be active by default? Every hook invocation already makes bulk update operations slower, and the images are not the ones getting changed, so I'd probably add a setting that has to be enabled to be more than a NO-OP

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants