Skip to content

Conversation

@tobiemh
Copy link
Member

@tobiemh tobiemh commented Dec 4, 2025

Summary

This PR adds support for serializing and deserializing imbl immutable data structures, with optimized deserialization using bulk construction patterns.

Changes

  • Add new optional imbl feature and dependency
  • Implement Revisioned, SerializeRevisioned, and DeserializeRevisioned traits for:
    • imbl::Vector<T>
    • imbl::OrdMap<K, V>
    • imbl::OrdSet<T>
    • imbl::HashMap<K, V>
    • imbl::HashSet<T>
  • Add comprehensive benchmarks comparing imbl::OrdMap vs std::collections::BTreeMap for building, cloning, clone+modify, serialization, and deserialization

Implementation Details

The deserialization implementation uses an optimized pattern that:

  1. Pre-allocates a Vec with the known capacity for better cache locality during reads
  2. Uses compiler hints (std::hint::assert_unchecked) to optimize bounds checking
  3. Converts to the imbl type via FromIterator for efficient bulk construction

This approach is significantly faster than inserting elements one-by-one into the persistent data structures.

Testing

  • Unit tests for all supported types (including empty collection edge cases)
  • Performance benchmarks demonstrate the serialization/deserialization characteristics

@tobiemh tobiemh merged commit 6ba3831 into main Dec 4, 2025
7 checks passed
@tobiemh tobiemh deleted the tobiemh/imbl branch December 4, 2025 20:59
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.

2 participants