Skip to content

Serialization.V2: validation returns diagnostics; one gate ladder shared by both outputs (S2, stacked on #8521) - #8522

Closed
Aaronontheweb wants to merge 1 commit into
akkadotnet:feature/serialization-v2-generator-harnessfrom
Aaronontheweb:feature/serialization-v2-generator-validator
Closed

Aaronontheweb wants to merge 1 commit into
akkadotnet:feature/serialization-v2-generator-harnessfrom
Aaronontheweb:feature/serialization-v2-generator-validator

Conversation

@Aaronontheweb

Copy link
Copy Markdown
Member

Summary

Part of #8384. Step S2 of the generator architecture pass. Stacked on #8521 (S1); this PR's base is that branch, and its diff is one commit. No behavior change: the set of diagnostics reported for any input is identical, emitted output is byte-identical, and GoldenOutput/ and WireSnapshots/ are untouched.

What changes

  • Validation returns diagnostics instead of reporting them. Every Validate* and Report* helper appends a value-equatable DiagnosticSpec to a builder. A DiagnosticSpec carries a DiagnosticKey, one enum member per descriptor field, and the message arguments. The key, not the public id, disambiguates the three ids that have two descriptor variants (AKKASG003 plain and polymorphic-hint; AKKASG007 and AKKASG015 same-assembly and cross-assembly). A private DiagnosticRegistry is the single place a key becomes a descriptor and a spec becomes a Diagnostic, still at Location.None until S6.
  • One gate ladder. EvaluateGate returns whether a serializer is emittable plus its gate diagnostics. Both the emission callback and the protocol-coverage output call it; the silent duplicate ladder in ReportProtocolCoverage is deleted.
  • The emission callback is now: gate, resolve, validate, report, emit. It emits only when no error-severity diagnostic was produced, which is exactly the rule the old isValid chain implemented; warnings and infos still allow emission.
  • Entry points for tests. Validate(SerializerInfo, ImmutableArray<MessageInfo>) and EvaluateGate(...) run on models with no generator driver. GeneratorValidatorSpec adds nine facts that assert on keys and arguments, not message substrings, covering a valid pair, AKKASG005, 006, 012, 015, 023, 029, 032, and 034.

The pipeline wiring in AkkaSerializerGenerator.cs is untouched, and the four tracked stages are unchanged. GeneratorIncrementalScenariosSpec and GeneratorIncrementalCachingSpec pass with their original pins.

Testing

dotnet test src/core/Akka.Serialization.V2.Tests -c Release: 287 passed (278 from S1 plus 9). Generator builds with warnings as errors. Akka.Remote builds.

Benchmark

The numbers below were measured while other agents were running multi-node test loops on the same machine, so they are not comparable to S1's baseline yet. They will be re-measured on a quiet machine and posted as a comment before this PR is considered for merge. Nothing in this PR touches a cached pipeline input; the change is confined to the bodies of the two RegisterSourceOutput callbacks.

Method Mean Allocated
Fresh driver, full corpus 154.0 ms 23.2 MB
Warm driver, one field renamed 142.7 ms 23.2 MB
Warm driver, comment edit 72.8 ms 7.8 MB
Warm driver, unrelated file edited 66.2 ms 7.8 MB

Stack

Base: feature/serialization-v2-generator-harness (#8521). When #8521 merges, this PR is rebased onto dev and retargeted.

@Aaronontheweb

Copy link
Copy Markdown
Member Author

Benchmark re-measured on a quiet machine (load average under 1, no other test runs), same short-run config, 5 serializers x 100 messages:

Method Mean Allocated
Fresh driver, full corpus 84.4 ms 23.2 MB
Warm driver, one field renamed 79.6 ms 23.2 MB
Warm driver, comment edit 60.1 ms 7.8 MB
Warm driver, unrelated file edited 60.6 ms 7.8 MB

Against the S1 baseline in #8521 (75 / 115 / 60 / 70 ms) this is flat within the short-run error bars, which are wide (the full-run error column reads 99 ms on this run). Allocations are identical to the byte, which is the number this PR could have moved and did not. The earlier table in the description was taken while multi-node test loops were running on the same box and should be ignored. Later PRs in this series will use a longer job for the final numbers so the error bars are meaningful.

@Aaronontheweb

Copy link
Copy Markdown
Member Author

Closing: this change is being reopened as part of a native GitHub stack with all branches in akkadotnet/akka.net (stacks cannot span a fork). Same commits, same content; the new PR will link back here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

akka.net v1.6 Akka.NET v1.6-related issues serialization

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant