Where the memory went
Figma's multiplayer service loads files, distributes updates between collaborators and writes periodic snapshots of file state. Real-time collaboration over a Figma file's graph requires much of that file to sit in memory. After the launch of dynamic page loading, the number of files decoded server-side rose by 30%, which prompted the team to look at Rust-level optimizations for load speed and memory use.
The node map as a hotspot
A Figma file is effectively a set of nodes—triangles, squares, frames—each a bundle of properties describing color, shape, parent and so on. On the server, a node is represented as a map from property ID to value: Map<property_name (u16), property_value (u64 pointer)>, where the type parameters give the bit width of each entry.
Because this map sits in the critical path of file loading, improvements to it carry straight through to load times. Memory profiling made the case stronger: the map accounted for over 60% of a file's memory usage—a surprising result for a structure holding only metadata rather than data.
Replacing the BTreeMap with a sorted vector
The default choice had been Rust's BTreeMap, required because the serialization protocol needs ordered iteration. But the generic power of a B-tree turned out to be unnecessary given how small the keyspace is. New properties enter the schema at human speeds, so the schema holds fewer than 200 fields today, and they tend to arrive in clusters—comment fields, for instance, appear only on comment nodes. Sampling real files confirmed the clustering: the average property map held around 60 keys.
That pointed to a flat, sorted vector as a simpler and more compact layout. In-memory node representation moved from:
BTreeMap<u16, pointer>{
0: 1, // node_id
1: FRAME, // type
2: null, // parent_id
... (x, y, w, h etc.)
},
to:
Vec<u16, pointer>{
(0, 1),
(1, FRAME),
(2, null),
... (x, y, w, h)
}
A Big-O comparison of the two layouts makes the vector look strictly worse:

That analysis ignores how fast a CPU is when traversing a small amount of linear memory, which is exactly the situation here. Even with O(n) insertion in the worst case (an insert at the front of the vector), deserialization—the step that matters most for file loads—came out faster. Memory use fell by almost 25% for large files.
An experiment in pointer bit stuffing
A second optimization was investigated but never productionized. It starts from the observation that a pointer is 64 bits, addressable memory of 2^64 bytes, or 18 exabytes—far beyond anything the multiplayer system would touch. Most x86 processors use only the low 48 bits for addressing, leaving the top 16 bits free:
[0u16, pointer_u48]
Coincidentally, the field ID in the Map<u16, pointer> needs exactly 16 bits, so the ID can be packed into the pointer and both stored in one 64-bit number:
Vec<u64>{
[0_u16 type_ptr_u48],
[1_u16, FRAME_ptr_u48],
... (x, y, w, h)
}

Field ID and pointer are pulled back out with simple bit operations. Doing this in Rust means managing pointer lifecycles carefully: with reference-counted pointers, counts have to be updated correctly on insert and get to avoid memory corruption.
On the benchmark the approach was marginally faster and used slightly less memory—about 5% below the simple vector version, short of the 20% reduction the representation would naively suggest. The metric that matters here is resident set size, the memory a process consumes in RAM, which does not track allocated memory directly and depends on the allocator and the operating system. The extra win wasn't judged worth the memory pitfalls, though the team keeps the lever available.
Results
The vector layout has already paid off in production: file deserialization times improved by 20% at the 99th percentile, meaning the slowest Figma files now load faster, and memory costs across the entire multiplayer fleet dropped 20%.



