perf: Lexicon response deserialization allocations #202
Labels
No labels
breaking-change
bug
documentation
duplicate
enhancement
good first issue
help wanted
performance
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Grandiras/ATProto.NET#202
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Goal
Cut allocations and CPU when deserializing Lexicon responses: a 30-item
getAuthorFeedpage allocates ~55 KB through the in-process XRPC path. Look at the model layer (LexObjectextension data, open unions,AtProtoJsonDefaultsconverters, record deserialization) without changing behaviour or public API.Scope
src/ATProtoNet/Serialization,src/ATProtoNet/Models, and the model files (*Models.cs) undersrc/ATProtoNet/Lexicon.Investigated, no change. Measured with real AppView JSON: a 30-item getAuthorFeed page (237 KB JSON) allocates ~521 KB. A raw
JsonElementparse of the same bytes allocates 423 KB, so the typed path is near the floor.About 62% of the allocation is the raw JSON held by public
JsonElementproperties:FeedReplyRef.Root/Parent,PostView.RecordandEmbeddedRecord.Value. Extension data, union cloning, converter resolution and the union double scan (fixed in #191) are all already cheap.A real reduction needs a public API decision, such as typing
FeedReplyRef.Root/Parentas the already-modelled post union instead ofJsonElement. That is a breaking change for 0.8, left to the owner.