graph-arena 0.1.0

Collection type to store immutable graph structures efficiently
Documentation
  • Coverage
  • 0%
    0 out of 5 items documented0 out of 4 items with examples
  • Size
  • Source code size: 4.12 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.28 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 9s Average build duration of successful builds.
  • all releases: 9s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • nilsmartel/graph-arena
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • nilsmartel

Graph Arena

Collection type to store immutable graph data efficiently. Avoids heap clusturing, enforces locality and reduces the need for copying all together.

When should I use this?

In recursive data structures, one often encounters code like this:

struct Expression {
    Add(Box<Expression>, Box<Expression>),
    // ...
}

In the long run one encounters several problems with this approach:

  • Most data lives on the heap, but related data aren't necessarily near each other.
  • A lot of allocations are required to build these structures.
  • Cloning becomes really expensive.

Now, allocations are something we'd like to avoid as much as possible; alloc is an expensive operation. That's why a Vec<T> allocates more memory, than it (might) use. So no reallocation of data is required each time we push more data.

Furthermore we desire related data to live in near by memory locations: Modern CPUs are heavily modified to take advantage of locality, that makes Vec<T> an insanely fast data strucutre!