Skip to content

Reduce Article Work parser allocations - #205

Merged
enteriaza merged 2 commits into
masterfrom
160-perf-allocation-article-work-parses-every-delivery-with-jsondocument
Oct 19, 2026
Merged

enteriaza merged 2 commits into
masterfrom
160-perf-allocation-article-work-parses-every-delivery-with-jsondocument

Conversation

@enteriaza

@enteriaza enteriaza commented Oct 19, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Replace JsonDocument-based Article Work payload parsing with Utf8JsonReader to reduce per-delivery allocations while preserving the existing validation and request identity semantics.

Closes #160.

Changes

  • Allocation-efficient parsing: Parse JSON directly from delivery.Body.Span, eliminating the per-delivery JsonDocument allocation.
  • Minimal string allocations: Extract only the values that must survive parsing, avoiding temporary strings on the common successful path.
  • Preserved request ID compatibility: Retain the stack-buffer fast path for ordinary GUIDs and fall back to the original string validation for longer or segmented values.
  • Preserved validation: Maintain the existing payload size limit, root-object validation, complete JSON consumption, duplicate-property behavior, and error-result semantics.
  • Regression coverage: Add tests for long valid GUID representations, long invalid values, whitespace-only values, and existing parsing behavior.

Testing and validation

  • Focused Article Work parser tests: 53 passed
  • Full BackFillerService test suite: 1,259 passed, 0 failed, 0 skipped
  • Release x64 solution build: passed, 0 warnings and 0 errors
  • Solution formatting verification: passed

Allocation comparison

A warmed Release-mode probe measured:

Parser Allocated bytes per parse
Utf8JsonReader implementation 200 B
Reconstructed JsonDocument comparison 368 B

This is a comparison against a reconstructed baseline, not a direct measurement of the deleted implementation. Rented document buffers are not included in the allocation count.

Notes

  • The RabbitMQ payload format and downstream processing remain unchanged.
  • CodeQL and Linux CI have not been run.

Fixes #160

Keep the allocation-efficient stack-buffer path for ordinary request IDs and fall back to the original string validation for longer or segmented values. Add regression tests for extended valid GUID formats and long invalid inputs while preserving payload size limits and existing validation semantics.
@enteriaza enteriaza self-assigned this Oct 19, 2026
@enteriaza enteriaza added the enhancement New feature or request label Oct 19, 2026
Group version and Message-ID parsing state into private structs to eliminate excessive ref parameters while preserving existing validation and duplicate-property semantics.
@enteriaza
enteriaza merged commit 528c8a4 into master Oct 19, 2026
7 checks passed
@enteriaza
enteriaza deleted the 160-perf-allocation-article-work-parses-every-delivery-with-jsondocument branch October 19, 2026 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Perf: Allocation] Article Work parses every delivery with JsonDocument

2 participants