perf: parallelize resource ACL and fallback ACL fetching#2810
Open
maxleonard wants to merge 2 commits intomainfrom
Open
perf: parallelize resource ACL and fallback ACL fetching#2810maxleonard wants to merge 2 commits intomainfrom
maxleonard wants to merge 2 commits intomainfrom
Conversation
Fetch resource ACL and fallback ACL concurrently using Promise.all instead of sequentially. This reduces latency when combined with HTTP/2 multiplexing, as the speculative fallback fetch overlaps with the resource ACL fetch at minimal cost. - internal_fetchAcl now issues both fetches in parallel - Fallback wrapped in .catch(() => null) to prevent regression when speculative fetch fails - Updated tests for parallel fetch behavior Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The parallel ACL fetching now consumes mock responses that were previously unused (fallback fetch was skipped when resource ACL existed). Add a 4th mock response for the saveAclFor step in the 3 affected "ignores the fallback ACL" tests. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Parallelize the fetching of resource ACL and fallback ACL in
internal_fetchAcl, eliminating a sequential wait that adds unnecessary latency. This is complementary to the HTTP/2 multiplexing support being added in solid-client-authn-js#4213 — HTTP/2 multiplexing only helps if requests are actually issued in parallel.Detailed Changes
src/acl/acl.internal.ts—internal_fetchAclBefore (sequential):
The resource ACL was fetched first, and only if it was
nullwas the fallback ACL fetched. This serialized two independent network operations.After (parallel):
Both fetches are now issued concurrently via
Promise.all. If the resource ACL exists, the fallback result is discarded. The fallback is wrapped in.catch(() => null)to safely handle cases where the speculative fetch would fail (the original code would never have executed it in those cases).Trade-off: One extra request when the resource ACL exists (the fallback fetch is unnecessary). With HTTP/2 multiplexing, this overhead is minimal since it shares the same TCP connection. The latency improvement from parallel fetching outweighs the marginal bandwidth cost.
src/acl/acl.test.ts— Updated testsThree tests updated to accommodate parallel fetching:
toHaveLength(2)) now usetoBeGreaterThanOrEqual(2)since parallel fetching may issue additional speculative requestscalledUrlsarray withtoContaininsteadTest plan
🤖 Generated with Claude Code