Skip to content

Add serde feature - #24

Merged
alice-i-cecile merged 3 commits into
bevyengine:mainfrom
tidely:serde-support
Aug 8, 2026
Merged

Add serde feature#24
alice-i-cecile merged 3 commits into
bevyengine:mainfrom
tidely:serde-support

Conversation

@tidely

@tidely tidely commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Closes #23

Sounds simple enough! Well I'm here to make it complicated :)

Long story short, the default serde implementation for deserializing Arc<T> first allocates Box<T> followed by converting it to Arc<T> (which allocates again), this allows a blanket implementation for all ?Sized types which support deserializing into Box<T>. For Arc<str> for example, this allocates twice.

I've written our own Deserialize implementation, which now is specialized for Arc<str> and Arc<[T]>, while not supporting other !Sized types. I feel like this tradeoff is worthwhile, as we want to squeeze every last drop of performance out.

Tradeoff: Blanket Deserialize implementation which allocates twice for ?Sized vs optimized version which only works for implemented types, but only allocates once for ArcCow<'_, str>

I'd like some feedback on this!

Additionally I feel like since the serde feature adds a lot of code which is more complex than the rest of the crate, could it be time for some tests?

Comment thread RELEASES.md Outdated
@alice-i-cecile
alice-i-cecile added this pull request to the merge queue Aug 8, 2026
Merged via the queue into bevyengine:main with commit bfc3132 Aug 8, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add optional serde support

2 participants