linebender / linebender/peniko

Limitations of serialization implementation regarding shared references

Open
#30 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
87
Forks
28
PR merge metrics
No merged PRs in 30d

Description

With the added serde derives, in PR #26 it came up on zulip that the serialization of images is "not ideal", but useful enough to keep for now but might eventually require a breaking change.

The general issue is that Image Blobs may be shared, which when serialized will duplicate the data.
This then deserializes to multiple images each having their own unique ID.

serde

The most relevant issue I found in serde is the following involving the serde_state crate
which adds on top of serde SerializeState and DeserializeState traits, alas this is an experimental fork of serde
which is not in the maintenance goldilocks zone at 110 commits ahead and 745 commits behind serde itself.

https://github.com/serde-rs/serde/issues/881

I guess my recommendation for the current state would be if serializing shared images serialize them to a map/vector
and reference those by key or index.

Alternatives to serde

Rkyv by default does the right thing for serializing shared pointers
It isn't really comparable to serde though in that it is a fixed data format rather than a data model supporting multiple data formats.

I think it might be more ideal, because it would be both zero copy, and we don't have to work around the data model to avoid duplicating shared references.

There is one issue which gives me some pause, that I would probably want to fix/work on before integrating it https://github.com/rkyv/rkyv/issues/285 because rkyv serializes enum variants by their representation value rather than nominally. Simply reordering enums or adding variants that aren't appended to the current variants can cause compatibility hazards.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No source files or tests are identified. Start by reviewing PR #26 and the linked serde issue #881, then compare the proposed serde map/vector approach with rkyv and issue #285. Done requires an agreed serialization design that preserves shared Image Blob references and addresses compatibility concerns.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.