Skip to content

test(api): add parallel-session stress test (I2)#92

Merged
DemchaAV merged 1 commit into
developfrom
test/parallel-session-stress
May 31, 2026
Merged

test(api): add parallel-session stress test (I2)#92
DemchaAV merged 1 commit into
developfrom
test/parallel-session-stress

Conversation

@DemchaAV

Copy link
Copy Markdown
Owner

Summary

Wires up Track I2 from the v1.6.5→1.7 readiness taskboard. Drives 32 independent DocumentSession instances on a fixed-size thread pool through 4 iterations to catch race conditions in process-wide shared state (font registry, glyph cache, built-in node definitions, shape outline cache).

Two assertions

Test What it pins
identicalSessionsInParallelProduceIdenticalLayoutGraphs Every parallel render produces the same layoutGraph().toString() as a sequential baseline. Catches any shared mutable state racing in the prepare / measure pipeline.
independentSessionsInParallelProduceValidPdfBytes Every PDF carries the %PDF magic, is at least 256 bytes, and size variance across threads is < 256 bytes — loose enough not to lock against legitimate timestamp drift, tight enough to catch corruption.

Why this scope

Each DocumentSession is single-threaded by contract — the stress test exercises a fleet of independent sessions, each owned by exactly one thread, not concurrent access to a single session. The guarantee under test is that the process-wide machinery (default font registry, glyph cache, built-in node definitions, shape outline cache) handles concurrent lookup safely.

Future-direction note: when Track I3 (DocumentSession.registry() immutable view, planned for 1.6.7) lands, this stress test will validate that the new contract continues to hold under concurrency.

Verification

$ ./mvnw -B -ntp test -pl . -Dtest=DocumentSessionParallelStressTest
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0
Time elapsed: 1.572 s

128 layout renders + 128 PDF renders = 256 concurrent operations complete in ~1.6 s. Does not bloat CI.

Full suite re-run also green:

$ ./mvnw -B -ntp test -pl .
BUILD SUCCESS (~50s)

CHANGELOG entry added to v1.6.6 — Planned under ### Build.

Test plan

  • New stress test green locally (2/2)
  • Full canonical suite still green
  • CI green on PR (including all matrix JDKs — race-condition detection works best on the higher-concurrency JDK 17/21/25 builds)
  • Reviewer skim of the harness (one Executors.newFixedThreadPool(32) + invokeAll + assertions)
  • (Out of scope) follow-up: extend the test to exercise shared-registry mutation paths once Track I3 lands the immutable registry() view

Wires up Track I2 from the v1.6.5->1.7 readiness taskboard. Drives 32 independent DocumentSession instances on a fixed-size thread pool through 4 iterations to catch race conditions in process-wide shared state (font registry, glyph cache, built-in node definitions, shape outline cache).

Two assertions:

1. identicalSessionsInParallelProduceIdenticalLayoutGraphs: every parallel render produces the same layout-graph toString() as a sequential baseline. Catches any shared mutable state racing in the prepare/measure pipeline.

2. independentSessionsInParallelProduceValidPdfBytes: every PDF carries the %PDF magic, is at least 256 bytes, and size variance across threads is <256 bytes (loose enough not to lock against legitimate timestamp drift, tight enough to catch corruption).

Each DocumentSession is single-threaded by contract; this test exercises a fleet of INDEPENDENT sessions, not concurrent access to a single session. ~1.6s locally; does not bloat CI.
@DemchaAV DemchaAV force-pushed the test/parallel-session-stress branch from 0a4237f to 554f343 Compare May 31, 2026 12:04
@DemchaAV DemchaAV merged commit 4c9d765 into develop May 31, 2026
11 checks passed
@DemchaAV DemchaAV deleted the test/parallel-session-stress branch May 31, 2026 12:07
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