<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/replacing-a-rust-enum-with-a-64-bit-word-made-my-interpreter-17-faster-vl1pbon5a" -->

---
title: Replacing a Rust Enum with a 64-bit Word Made My...
description: A deep dive into replacing a 16-byte Rust tagged enum Value type with a compact 64-bit tagged word representation in the Plush interpreter, a toy...
canonical: https://daily.dev/posts/replacing-a-rust-enum-with-a-64-bit-word-made-my-interpreter-17-faster-vl1pbon5a
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Replacing a Rust Enum with a 64-bit Word Made My Interpreter 17% Faster | daily.dev
og:description: A deep dive into replacing a 16-byte Rust tagged enum Value type with a compact 64-bit tagged word representation in the Plush interpreter, a toy...
og:url: https://daily.dev/posts/replacing-a-rust-enum-with-a-64-bit-word-made-my-interpreter-17-faster-vl1pbon5a
og:image: https://api.daily.dev/og/posts/vl1PBOn5a.png
og:image:alt: Replacing a Rust Enum with a 64-bit Word Made My Interpreter 17% Faster
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Replacing a Rust Enum with a 64-bit Word Made My Interpreter 17% Faster

**[Pointers Gone Wild](https://daily.dev/sources/pointersgonewild)** · 25 min read · 7 upvotes · 1 comments

## Summary

A deep dive into replacing a 16-byte Rust tagged enum Value type with a compact 64-bit tagged word representation in the Plush interpreter, a toy dynamically-typed language. The refactor uses low-bit tagging (fixnums, flonums via a self-tagging scheme, immediates, and two kinds of pointers) instead of NaN boxing. Benchmarks show every single test case got faster, with some memory-heavy benchmarks like binary_tree and linked_list seeing the biggest gains due to cache-friendliness from halved object sizes, while even floating-point heavy benchmarks like mlp and nbody improved despite requiring extra unboxing/reboxing work. Disassembly comparisons reveal the old Rust enum match-based dispatch generated surprisingly inefficient code with many stack spills, while the new representation fits values in a single register, producing much shorter and faster machine code.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://pointersgonewild.com/2026-08-25-replacing-a-rust-enum-with-a-64-bit-word>

## Questions this post answers

### How much faster did replacing a Rust enum Value type with a 64-bit tagged word make an interpreter?

Every benchmark got faster, with an overall gain around 17%, after replacing a 16-byte Rust tagged enum representation with a 64-bit tagged word in the Plush interpreter. Memory-heavy benchmarks like binary_tree and linked_list saw the biggest speedups due to better cache locality, while even register-resident benchmarks like fib and nbody improved because values fit in a single CPU register instead of spilling to the stack.

_Following interpreter and VM performance techniques like this helps when optimizing your own runtime; daily.dev surfaces posts like these for that work._

### What is the float self-tagging scheme used instead of NaN boxing in a low-bit tagged value representation?

Float self-tagging rotates the upper bits of an IEEE double into the tag position after adding a bias value, so the lower bits land on the desired tag with no shifting or masking needed. This scheme, from a paper by Olivier Melançon, Manuel Serrano and Marc Feeley, lets tagged flonums represent subnormals, infinity, and NaNs without heap boxing, losing only two bits of exponent range while keeping full mantissa precision.

_Developers weighing NaN boxing versus self-tagging schemes for their own language runtime can track this kind of design comparison on daily.dev._

### Why did a Rust tagged enum used for dynamic language values end up 128 bits wide instead of 64 bits?

A Rust enum with variants holding 64-bit payloads (like Int64 or a pointer) plus an 8-bit tag still ends up occupying 128 bits total because of memory alignment constraints, even though only 72 bits are logically needed. This wastes significant space in large value arrays, prompting a switch to a hand-packed 64-bit tagged word using pointer-alignment bit stealing instead.

_Anyone sizing memory layouts for a Rust interpreter can keep tabs on tagging tricks like this through daily.dev._

## Community discussion

Top comments from developers on daily.dev.

**@agustinbarrientos** · 0 upvotes

> Does the 64-bit representation keep the same lead on x86-64, where branch prediction and unaligned enum loads may behave differently?

## Similar posts on daily.dev

- [How to speed up the Rust compiler in July 2026](https://daily.dev/posts/how-to-speed-up-the-rust-compiler-in-july-2026-rsrjhr5xg) · Lobsters · 2 upvotes · 0 comments
- [Plush's New Register-Based Interpreter Is Insanely Fast](https://daily.dev/posts/plush-s-new-register-based-interpreter-is-insanely-fast-nsqme5hay) · Pointers Gone Wild · 18 upvotes · 1 comments
- [Benchmarks Are Free Now](https://daily.dev/posts/benchmarks-are-free-now-307ftwxma) · RUBYLAND · 0 upvotes · 0 comments
- [Box to save memory](https://daily.dev/posts/box-to-save-memory-foxzggogq) · Dystroy · 66 upvotes · 6 comments

---

Tags: [#performance](https://daily.dev/tags/performance), [#rust](https://daily.dev/tags/rust), [#virtual-machine](https://daily.dev/tags/virtual-machine)

[View this post on daily.dev](https://daily.dev/posts/replacing-a-rust-enum-with-a-64-bit-word-made-my-interpreter-17-faster-vl1pbon5a)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Replacing a Rust Enum with a 64-bit Word Made My Interpreter 17% Faster","url":"https://daily.dev/posts/replacing-a-rust-enum-with-a-64-bit-word-made-my-interpreter-17-faster-vl1pbon5a","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/replacing-a-rust-enum-with-a-64-bit-word-made-my-interpreter-17-faster-vl1pbon5a"},"datePublished":"2026-08-25T13:29:42.248Z","dateModified":"2026-09-14T06:55:33.846Z","description":"A deep dive into replacing a 16-byte Rust tagged enum Value type with a compact 64-bit tagged word representation in the Plush interpreter, a toy...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/3ae29931f82cddd104337f209828d8fd?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/3ae29931f82cddd104337f209828d8fd?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Pointers Gone Wild","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Pointers Gone Wild","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/ae0b966a89554ad5b6d54de550180ab0","url":"https://daily.dev/sources/pointersgonewild"},"commentCount":1,"discussionUrl":"https://daily.dev/posts/replacing-a-rust-enum-with-a-64-bit-word-made-my-interpreter-17-faster-vl1pbon5a","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":7},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":1}],"keywords":"performance,rust,virtual-machine","timeRequired":"PT25M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Pointers Gone Wild","item":"https://daily.dev/sources/pointersgonewild"},{"@type":"ListItem","position":3,"name":"Replacing a Rust Enum with a 64-bit Word Made My Interpreter 17% Faster"}]}
{"@context":"https://schema.org","@type":"WebPage","@id":"https://daily.dev/posts/replacing-a-rust-enum-with-a-64-bit-word-made-my-interpreter-17-faster-vl1pbon5a","comment":[{"@type":"Comment","text":"Does the 64-bit representation keep the same lead on x86-64, where branch prediction and unaligned enum loads may behave differently?","datePublished":"2026-08-31T21:29:17.642Z","url":"https://daily.dev/posts/vl1PBOn5a#c-nPw8CDkqO","author":{"@type":"Person","name":"Agustin Barrientos","url":"https://daily.dev/agustinbarrientos","image":"https://media.daily.dev/image/upload/s--5ayxQnqn--/f_auto/v1788281802/avatars/avatar_wQYYVe5Tbj0NJ7C7qPoa8?_a=BAMAMicg0"}}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/replacing-a-rust-enum-with-a-64-bit-word-made-my-interpreter-17-faster-vl1pbon5a#faq","mainEntity":[{"@type":"Question","name":"How much faster did replacing a Rust enum Value type with a 64-bit tagged word make an interpreter?","acceptedAnswer":{"@type":"Answer","text":"Every benchmark got faster, with an overall gain around 17%, after replacing a 16-byte Rust tagged enum representation with a 64-bit tagged word in the Plush interpreter. Memory-heavy benchmarks like binary_tree and linked_list saw the biggest speedups due to better cache locality, while even register-resident benchmarks like fib and nbody improved because values fit in a single CPU register instead of spilling to the stack. Following interpreter and VM performance techniques like this helps when optimizing your own runtime; daily.dev surfaces posts like these for that work."}},{"@type":"Question","name":"What is the float self-tagging scheme used instead of NaN boxing in a low-bit tagged value representation?","acceptedAnswer":{"@type":"Answer","text":"Float self-tagging rotates the upper bits of an IEEE double into the tag position after adding a bias value, so the lower bits land on the desired tag with no shifting or masking needed. This scheme, from a paper by Olivier Melançon, Manuel Serrano and Marc Feeley, lets tagged flonums represent subnormals, infinity, and NaNs without heap boxing, losing only two bits of exponent range while keeping full mantissa precision. Developers weighing NaN boxing versus self-tagging schemes for their own language runtime can track this kind of design comparison on daily.dev."}},{"@type":"Question","name":"Why did a Rust tagged enum used for dynamic language values end up 128 bits wide instead of 64 bits?","acceptedAnswer":{"@type":"Answer","text":"A Rust enum with variants holding 64-bit payloads (like Int64 or a pointer) plus an 8-bit tag still ends up occupying 128 bits total because of memory alignment constraints, even though only 72 bits are logically needed. This wastes significant space in large value arrays, prompting a switch to a hand-packed 64-bit tagged word using pointer-alignment bit stealing instead. Anyone sizing memory layouts for a Rust interpreter can keep tabs on tagging tricks like this through daily.dev."}}]}
```

