Skip to content

Cache one resolved model per serializer so one message edit regenerates one file (S3) - #8527

Merged
Aaronontheweb merged 1 commit into
devfrom
feature/serialization-v2-generator-resolve
Sep 11, 2026
Merged

Aaronontheweb merged 1 commit into
devfrom
feature/serialization-v2-generator-resolve

Conversation

@Aaronontheweb

@Aaronontheweb Aaronontheweb commented Sep 9, 2026 •

Copy link
Copy Markdown
Member

Stack, bottom to top: S1 #8525 -> S2 #8526 -> S3 #8527 -> object elements #8528 -> S4 #8530 -> S5 #8532 -> S6 #8533 -> F1 #8534 -> F2 #8536 -> F3 #8537 -> S7 #8538. Each PR is one commit on top of the one below it. This PR is S3.

What changes

Renaming a field in a message now regenerates one file, the serializer that owns that message. Before, it regenerated every serializer's file, and the unchanged ones matched byte for byte only by luck. Generated text is byte-identical. No golden, wire, or model snapshot changed. The diagnostic set is unchanged.

  • One cached model per serializer. ResolvedSerializer holds everything emission needs: the gate result, the messages this serializer can reach, the top-level set as a ClosedSet, the closed-generic registrations after resolution, formatter overrides, a typed UnionPlan in place of a string-keyed dictionary, the derived method names, and the validation diagnostics. It compares by content.
  • Emission reads only that model. No compilation, no symbols, no other serializer's data. Diagnostics that span serializers (AKKASG013, 031, 037) get their own small output and report once. The protocol-coverage output reads the gate result from the model instead of recomputing it.
  • One ClosedSet type for the top-level dispatch set and the union sets. Decision 18 later expands over this object.

Why

Roslyn reuses a step's output when its inputs compare equal. A model that holds only what one serializer needs stays equal when another serializer's message changes. A first version stored the whole message table in every serializer's model, and a probe test showed every model changing on every edit.

Savings

Short run, 5 serializers x 100 messages, machine at moderate load.

Scenario S2 S3
Fresh driver, full corpus 75.3 ms, 23.19 MB 89.8 ms, 22.61 MB
One field renamed in one message 75.8 ms, 23.17 MB 69.4 ms, 13.15 MB
Comment edit inside a message 60.2 ms, 7.82 MB 59.1 ms, 7.79 MB
Unrelated file edited 59.0 ms, 7.77 MB 57.1 ms, 7.76 MB

The rename row drops from the full-corpus figure to the no-change floor plus one serializer's emission. Wall clock carries noise at this load.

How it was checked

Scenario b in the caching tests flips: the rename runs one serializer's emit step, and the other never runs. 293 tests pass (287 plus 6): resolve tests on models with no driver, and a Verify snapshot of each serializer's resolved model over the golden corpus. Generator builds with warnings as errors. Akka.Remote builds.

Known follow-up

The protocol-coverage scan (AKKASG029) now runs once per serializer instead of once per compilation. Same output, more scanning when a project has several serializers. S5 moves it into one cached step.

@Aaronontheweb Aaronontheweb added serialization akka.net v1.6 Akka.NET v1.6-related issues labels Sep 9, 2026
@Aaronontheweb
Aaronontheweb added this pull request to stack #8531 September 9, 2026 01:53
@Aaronontheweb
Aaronontheweb force-pushed the feature/serialization-v2-generator-resolve branch from cd99ece to 6b2f11f Compare September 9, 2026 13:31
@Aaronontheweb Aaronontheweb changed the title Serialization.V2: cached per-serializer resolve stage; one message edit re-emits one serializer (S3) Cache one resolved model per serializer so one message edit regenerates one file (S3) Sep 9, 2026
@Aaronontheweb
Aaronontheweb force-pushed the feature/serialization-v2-generator-resolve branch from 6b2f11f to d5c7e33 Compare September 9, 2026 17:14
@Aaronontheweb
Aaronontheweb force-pushed the feature/serialization-v2-generator-resolve branch from d5c7e33 to 161c569 Compare September 9, 2026 18:08
Base automatically changed from feature/serialization-v2-generator-validator to dev September 9, 2026 22:52
@Aaronontheweb
Aaronontheweb force-pushed the feature/serialization-v2-generator-resolve branch 2 times, most recently from 904b82d to 52434fe Compare September 10, 2026 23:44
@Aaronontheweb
Aaronontheweb force-pushed the feature/serialization-v2-generator-resolve branch from 52434fe to 99ac592 Compare September 11, 2026 15:05
@Aaronontheweb
Aaronontheweb merged commit 3cbdf93 into dev Sep 11, 2026
15 of 16 checks passed
@Aaronontheweb
Aaronontheweb deleted the feature/serialization-v2-generator-resolve branch September 11, 2026 17:29
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