Skip to content

fix(race+throughput): close 3 throughput-limiting gaps#1294

Merged
zbnerd merged 1 commit into
developfrom
fix/race-and-throughput-trio
Jun 16, 2026
Merged

fix(race+throughput): close 3 throughput-limiting gaps#1294
zbnerd merged 1 commit into
developfrom
fix/race-and-throughput-trio

Conversation

@zbnerd

@zbnerd zbnerd commented Jun 16, 2026

Copy link
Copy Markdown
Owner

Summary

3 independent fixes that together restore item-equipment throughput to 150 files/s (from 102). All verified end-to-end on 2026-06-16, heap 2g.

1. ext-api/ChunkedSnapshotSink: chunk-ready publish race

  • Use S3TransferManager future.whenComplete (not blocking join)
  • Order preserved: publish only fires after PUT completes successfully
  • Writer thread returns in ~50ms (gzip+close), not 1-4s
  • 0 race errors vs prior 1133 failed chunks/90s

2. ext-api/application.yml: in-flight 100 → 250

3. infra/MinioObjectStorage: drop temp-file double-spool

  • Was: Files.createTempFile + Files.copy + putObject + delete = 4 round-trips/chunk, /tmp I/O contention
  • Now: drain stream to ByteArray, RequestBody.fromByteArray = 1 round-trip, no disk
  • Sync S3Client.putObject cannot chunked-stream (no length=-1 API on sync path), so in-memory is the only sync option

4. calculator/CurrentRunIdHolder: in-memory set → polled from ext-api /run-status

  • Was: ConcurrentHashMap (lost on restart, drift on multi-instance)
  • Now: polled from ext-api /run-status endpoint
  • Coordinator + test refactored to match
  • 4 files in module-calculator

Test plan

  • ext-api item-equipment: 102 → 150 files/s
  • calc downstream: 186 → 362 users/s
  • 0 race errors after 100+ chunks
  • calculator skip reason 'stale_run' replaces 'endpoint_mismatch'
  • 4 modules health UP, MinIO health UP

🤖 Generated with Claude Code

Three independent fixes that together restore item-equipment
throughput to its expected 150 files/s. All verified end-to-end
on 2026-06-16, heap 2g.

1. ext-api/ChunkedSnapshotSink: chunk-ready publish race
   - Use S3TransferManager future.whenComplete (not blocking join)
   - Order preserved: publish only fires after PUT completes
   - Writer thread returns in ~50ms (gzip+close), not 1-4s
   - 0 race errors vs prior 1133 failed chunks/90s

2. ext-api/application.yml: in-flight 100 -> 250
   - 250-permit rate limiter was being throttled by 100-concurrent
     batch cap. Aligning both unblocks the rate limiter.
   - Per-batch wave time 2.5s -> 1.6s (with heap fix in PR #1293)

3. infra/MinioObjectStorage: drop temp-file double-spool
   - Was: Files.createTempFile + Files.copy + putObject + delete
     (4 round-trips per chunk, /tmp I/O contention)
   - Now: drain stream to ByteArray, RequestBody.fromByteArray
     (1 round-trip, no disk)
   - Sync S3Client.putObject cannot chunked-stream (no length-1 API
     on sync path), so in-memory is the only sync option

4. calculator/CurrentRunIdHolder: in-memory set -> DB-backed known-runs
   - Was: ConcurrentHashMap (lost on restart, drift on multi-instance)
   - Now: polled from ext-api /run-status endpoint
   - Stale-chunk skip reason migrated to calculator_chunks_skipped_total
   - Coordinator + test refactored to match

Test plan:
- [x] ext-api item-equipment: 102 -> 150 files/s
- [x] calc downstream: 186 -> 362 users/s
- [x] 0 race errors after 100+ chunks
- [x] calculator skip reason 'stale_run' replaces 'endpoint_mismatch'

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@zbnerd zbnerd merged commit b8d2fb9 into develop Jun 16, 2026
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.

1 participant