Skip to content

Restore shared anonymous authorization lookup per object (fixes #6257 performance regression) - #6544

Open
bram-atmire wants to merge 1 commit into
DSpace:mainfrom
bram-atmire:6257-restore-anonymous-authorization-cache
Open

bram-atmire wants to merge 1 commit into
DSpace:mainfrom
bram-atmire:6257-restore-anonymous-authorization-cache

Conversation

@bram-atmire

@bram-atmire bram-atmire commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

References

Description

The final commit of #6257 (6f52262) dropped the shared per-object lookup from 3a45c31. Requests stayed the same, but every anonymous feature check resolved the object's authorizations again, which on items with many bitstreams made page loads slower than before #6257. This restores the shared lookup.

Instructions for Reviewers

  • AuthorizationDataService shares one lookup of granted feature IDs per object between all anonymous checks on it.
  • It expires with the response, is cleared on invalidateAuthorizationsRequestCache(), and failed lookups are retried. Expired entries are pruned.
  • New specs cover reuse, expiry, invalidation and retry.

Median LCP, item with 50 bitstreams (item.bitstream.pageSize: 50, showAccessStatuses: true, server-side caches off), 100 page loads per variant, headless Chromium:

Before After
main before #6257 vs after #6257 1530 ms 1716 ms
main before #6257 vs this PR 1196 ms 936 ms

Each row is a separate run with both variants interleaved, so compare within a row only. The first row was measured right after starting the backend, while it was still warming up (JIT, Hibernate and database caches); the second row ran with a warm backend. That is why the same pre-#6257 baseline measures 1530 ms in one row and 1196 ms in the other.

To test: load such an item anonymously and compare page load with current main. REST requests are unchanged.

AI Disclosure (REQUIRED)

Were AI tools used in the creation of this PR?

  • No
  • Yes

Claude Code (claude-opus-5-5) reproduced the regression, wrote the fix and specs, ran the benchmarks and drafted this description. Human review didn't reveal additional flaws or mistakes.

Checklist

  • My PR is created against the main branch of code (unless it is a backport or is fixing an issue specific to an older branch).
  • My PR is small in size (e.g. less than 1,000 lines of code, not including comments & specs/tests), or I have provided reasons as to why that's not possible.
  • My PR follows all coding best practices based on the Code Conventions Guide
  • My PR passes ESLint validation using npm run lint
  • My PR doesn't introduce circular dependencies (verified via npm run check-circ-deps)
  • My PR includes TypeDoc comments for all new (or modified) public methods and classes. It also includes TypeDoc for large or complex private methods.
  • My PR passes all specs/tests and includes new/updated specs or tests based on the Code Testing Guide.
  • My PR aligns with Accessibility guidelines if it makes changes to the user interface.
  • My PR uses i18n (internationalization) keys instead of hardcoded English text, to allow for translations.
  • My PR includes details on how to test it. I've provided clear instructions to reviewers on how to successfully test this fix or feature.
  • If my PR includes new libraries/dependencies (in package.json), I've made sure their licenses align with the DSpace BSD License based on the Licensing of Contributions documentation.
  • If my PR includes new features or configurations, I've provided basic technical documentation in the PR itself.
  • If my PR fixes an issue ticket, I've linked them together.

Since 6f52262, each anonymous feature check rebuilt the unfiltered
authorization search and resolved every embedded feature again, even
when another check on the same object had already done so. On an item
page with many bitstreams this repeated work for every feature checked
on every bitstream, making server-side rendering and hydration slower
than before DSpace#6257.

Restore the per-object shared lookup from 3a45c31 in a commented
form: all checks on an object reuse one observable of granted feature
IDs until it expires with the underlying response or the authorization
cache is invalidated. Failed lookups are dropped so the next check
retries them, and expired entries are pruned.

Assisted-by: Claude Code [claude-opus-5-5]
@lgeggleston lgeggleston added bug authorization related to authorization, permissions or groups performance / caching Related to performance, caching or embedded objects labels Nov 17, 2026
@lgeggleston lgeggleston moved this to 🙋 Needs Reviewers Assigned in DSpace 11.0 Release Nov 17, 2026
@tinsch

tinsch commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

I can confirm that this PR resolves the performance problems introduced by #6257. Response time average dropped from 2490.02ms to 1829.36ms again 👍

@lgeggleston lgeggleston moved this from 🙋 Needs Reviewers Assigned to 👍 Reviewer Approved in DSpace 11.0 Release Nov 18, 2026
@tdonohue

Copy link
Copy Markdown
Member

@artlowel or @FrancescoMolinaro : Alerting you to this PR as it's a performance fix followup to #6257 (which you both reviewed & approved). If either of you have time to give this a look, it may be good to get this merged quickly to resolve the performance issues.

@FrancescoMolinaro FrancescoMolinaro left a comment

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.

Hi @bram-atmire , thanks for your work on this, I have tested the changes and it looks good to me!

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

Labels

authorization related to authorization, permissions or groups bug high priority performance / caching Related to performance, caching or embedded objects

Projects

Status: 👍 Reviewer Approved

Development

Successfully merging this pull request may close these issues.

5 participants