Skip to content

SS-4 Add streaming DATA message store path#279

Closed
vhafdal wants to merge 2 commits into
cosullivan:masterfrom
vhafdal:ss-4-streaming-data
Closed

SS-4 Add streaming DATA message store path#279
vhafdal wants to merge 2 commits into
cosullivan:masterfrom
vhafdal:ss-4-streaming-data

Conversation

@vhafdal

@vhafdal vhafdal commented Jul 15, 2026

Copy link
Copy Markdown

Summary

Adds an opt-in streaming message store path for SMTP DATA handling.

Why

The existing DATA flow reads the complete dot-block into a ReadOnlySequence<byte> before invoking message storage. That preserves compatibility but forces full-message buffering before custom storage can process content. This change lets storage implementations opt into streaming while leaving existing IMessageStore implementations untouched.

Changes

  • Add IStreamingMessageStore, extending IMessageStore with a PipeReader-based save method.
  • Update DataCommand to stream DATA content to stores that implement IStreamingMessageStore.
  • Keep the existing buffered IMessageStore.SaveAsync(... ReadOnlySequence<byte> ...) path for all current consumers.
  • Add a streaming dot-block pipe helper that removes dot-stuffing while preserving strict max-message-size enforcement.
  • Add pipe-level tests and a server-level test proving streaming stores are selected.

Validation

  • DOTNET_ROLL_FORWARD=Major dotnet test src/SmtpServer.Tests/SmtpServer.Tests.csproj
  • Result: 120 passed, 1 skipped.

Notes

  • This is an additive API; existing message stores do not need to change.
  • BenchmarkDotNet benchmarks were not run; validation focused on behavior and compatibility tests.

Jira

  • SS-4

@vhafdal

vhafdal commented Jul 15, 2026

Copy link
Copy Markdown
Author

Benchmark follow-up added in vhafdal:SmtpServer@5df5db2.\n\nCommand used:\nDOTNET_ROLL_FORWARD=Major dotnet run -c Release --project src/SmtpServer.Benchmarks/SmtpServer.Benchmarks.csproj -- --filter *DataStoreBenchmarks*\n\nShortRun result on Test3.eml (~2 MB):\n- BufferedMaterializing: mean 91.887 ms, allocated 2060.05 KB/op, Gen0/1/2 collections reported.\n- StreamingDrain: mean 90.000 ms, allocated 26.05 KB/op, no Gen0/1/2 collections reported.\n\nThe benchmark shows similar throughput for this local SMTP send path while avoiding roughly 2 MB of managed allocation per DATA message when the store consumes the stream directly.

@vhafdal
vhafdal marked this pull request as ready for review July 15, 2026 12:00
@vhafdal

vhafdal commented Jul 15, 2026

Copy link
Copy Markdown
Author

Superseded by consolidated PR #284.

@vhafdal vhafdal closed this Jul 15, 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