aries-cloudagent-python icon indicating copy to clipboard operation
aries-cloudagent-python copied to clipboard

⚡ Migrate to msgspec structs for faster serialization

Open ff137 opened this issue 5 months ago • 0 comments

Attaching to #3802 and #3803.

We should move away from using JSON dumps and loads in so many places.

When records get passed between different handlers, they get serialized and deserialized over and over again. And using JSON for this is notably inefficient.

I propose using a more efficient library, msgspec, for defining all the models that need serialization and validation.

Most impactful would be for how presentation exchange records get built in the proof flows, because the payloads can be so massive. But, obviously would be great for all record types. This request is mainly for exchange records, because I think it'll yield the biggest bang for buck.

msgspec has excellent benchmarks compared to other libraries - it beats orjson and Pydantic:

Image

Image

Image

Image

ff137 avatar Jun 30 '25 19:06 ff137