Skip to content

RAD-17289 Add descriptor priority: keep one Android transmit slot for high priority - #59

Merged
arnonate merged 2 commits into
masterfrom
arnonate/RAD-16862-priority-lane
Oct 29, 2026
Merged

arnonate merged 2 commits into
masterfrom
arnonate/RAD-16862-priority-lane

Conversation

@arnonate

@arnonate arnonate commented Oct 28, 2026 •

Copy link
Copy Markdown

Jira: RAD-17289, follow-up to RAD-16862

On Android, at most 4 requests transmit at once across the library. Small JSON requests wait for the same 4 slots as file parts, first come, first served. Each chunked upload can keep 3 parts waiting. So with a large backlog, a session's small create request can wait behind hundreds of parts. Support sees about 10 cases a month of captures whose session never reached the server. Some of those may be this.

This adds priority: 'high' | 'normal' to the request descriptor. Normal requests now use at most 3 of the 4 slots. The fourth is kept for high-priority requests, which can also use any free slot.

Before: a session create waits in line behind every file part ahead of it.
After: a high-priority request takes the reserved slot without waiting behind file parts. It can still wait when other high-priority requests hold every slot.

iOS accepts the field and ignores it for now. Its version needs a second background URLSession and is a separate change.

What to look at

  • TransferGate in UploadTransport.kt: a normal request takes a lane permit, then a slot. A high-priority request takes a slot only.

Decisions and trade-offs

  • Normal uploads lose one slot even when no high-priority work is waiting. File uploads drop from 4 to 3 concurrent requests. A gate that lends the reserved slot to normal requests would need preemption or a priority queue. This is simpler and can't starve either side.
  • A reserved slot, not a second queue. Requests only compete for slots at transmit time. Separate WorkManager work or a second store would add cost and no benefit.
  • Two semaphores, not a priority queue. Both kinds wait in FIFO order for a slot. If high-priority requests fill all 4 slots, normal requests already waiting go first. Session requests are small and few, so this should be rare.
  • Entries saved before this change read as normal. Gson leaves the new boolean false.

Test Plan

  • ./gradlew :react-native-background-upload:testDebugUnitTest: 316 tests, 0 failures. New tests cover the 3-slot cap for normal requests, the reserved slot for a high-priority one, priority parsing, a re-enqueue that changes priority, and the flag reaching the transport.
  • yarn typecheck, yarn test (192 pass) and yarn lint:ci pass.
  • Not measured: the throughput cost of 3 slots instead of 4 on a real network.

🤖 Generated with Claude Code

@arnonate
arnonate force-pushed the arnonate/RAD-16862-priority-lane branch from 1b8bf64 to 364159e Compare October 28, 2026 21:09
@arnonate
arnonate marked this pull request as ready for review October 28, 2026 21:16
@arnonate arnonate changed the title Add descriptor priority: keep one Android transmit slot for high priority RAD-17289 Add descriptor priority: keep one Android transmit slot for high priority Oct 28, 2026

@elliottkember elliottkember left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This sounds like a great idea and probably simpler than multiple queues!!

arnonate and others added 2 commits October 29, 2026 10:25
…rity

Small requests waited for the same 4 transmit slots as file parts, so a
session create could sit behind a large backlog. Normal requests now use
at most 3 slots, and high-priority requests can use the fourth. iOS
accepts the field and ignores it for now.

RAD-16862

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@arnonate
arnonate force-pushed the arnonate/RAD-16862-priority-lane branch from 364159e to b757def Compare October 29, 2026 15:32
@arnonate
arnonate merged commit cd1cf09 into master Oct 29, 2026
5 checks passed
@arnonate arnonate mentioned this pull request Oct 29, 2026
arnonate added a commit that referenced this pull request Oct 29, 2026
Jira: [RAD-17288](https://openspaceai.atlassian.net/browse/RAD-17288),
[RAD-17289](https://openspaceai.atlassian.net/browse/RAD-17289)

Bumps the version to 11.1.0 and moves the Unreleased CHANGELOG entries
for #58 and
#59 under that version. Once
merged, tag the squash commit `v11.1.0` so openspacelabs/diana#9633 can
move off its preview branch.

🤖 Generated with [Claude Code](https://claude.com/claude-code)


[RAD-17288]:
https://openspaceai.atlassian.net/browse/RAD-17288?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
[RAD-17289]:
https://openspaceai.atlassian.net/browse/RAD-17289?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants