Skip to content
This repository was archived by the owner on Apr 29, 2026. It is now read-only.

⏺ NaN-boxing removal is complete. All CI checks passed (199 integrati…#243

Merged
navicore merged 1 commit intomainfrom
revert-nanbox
Jan 12, 2026
Merged

⏺ NaN-boxing removal is complete. All CI checks passed (199 integrati…#243
navicore merged 1 commit intomainfrom
revert-nanbox

Conversation

@navicore
Copy link
Copy Markdown
Owner

@navicore navicore commented Jan 12, 2026

…on tests, 325+ unit tests).
#188
Summary of changes:

Deleted files:

  • crates/runtime/src/nanbox.rs - Main nanbox implementation
  • crates/compiler/src/codegen/inline_nanbox/ - Entire nanbox codegen directory
  • docs/NANBOX_PLAN.md - Design document

Modified files (removed nanbox cfg blocks and kept non-nanbox code):

  • crates/runtime/Cargo.toml - Removed nanbox feature
  • crates/compiler/Cargo.toml - Removed nanbox feature forwarding
  • crates/runtime/src/lib.rs - Removed mod nanbox
  • crates/runtime/src/stack.rs - Removed duplicate nanbox functions
  • crates/runtime/src/value.rs - Removed nanbox test, cleaned comments
  • crates/runtime/src/arithmetic.rs - Removed nanbox peek functions
  • crates/runtime/src/tagged_stack.rs - Removed nanbox StackValue, tests, cleaned comments
  • crates/runtime/src/string_ops.rs - Removed nanbox string_to_cstring
  • crates/runtime/src/time_ops.rs - Cleaned comments (kept elapsed_nanos design)
  • crates/compiler/src/codegen/mod.rs - Removed inline_nanbox mod, cleaned tests
  • crates/compiler/src/codegen/words.rs - Removed nanbox float/bool literal functions
  • crates/compiler/src/codegen/program.rs - Removed nanbox Value type definition
  • crates/compiler/src/codegen/statements.rs - Removed nanbox dispatch
  • crates/compiler/src/codegen/virtual_stack.rs - Removed nanbox spill function
  • crates/compiler/src/codegen/inline/mod.rs - Cleaned doc comments
  • crates/compiler/src/codegen/inline/dispatch.rs - Cleaned doc comments
  • crates/compiler/src/codegen/inline/ops.rs - Removed nanbox peek_pop_bool

…on tests, 325+ unit tests).

  Summary of changes:

  Deleted files:
  - crates/runtime/src/nanbox.rs - Main nanbox implementation
  - crates/compiler/src/codegen/inline_nanbox/ - Entire nanbox codegen directory
  - docs/NANBOX_PLAN.md - Design document

  Modified files (removed nanbox cfg blocks and kept non-nanbox code):
  - crates/runtime/Cargo.toml - Removed nanbox feature
  - crates/compiler/Cargo.toml - Removed nanbox feature forwarding
  - crates/runtime/src/lib.rs - Removed mod nanbox
  - crates/runtime/src/stack.rs - Removed duplicate nanbox functions
  - crates/runtime/src/value.rs - Removed nanbox test, cleaned comments
  - crates/runtime/src/arithmetic.rs - Removed nanbox peek functions
  - crates/runtime/src/tagged_stack.rs - Removed nanbox StackValue, tests, cleaned comments
  - crates/runtime/src/string_ops.rs - Removed nanbox string_to_cstring
  - crates/runtime/src/time_ops.rs - Cleaned comments (kept elapsed_nanos design)
  - crates/compiler/src/codegen/mod.rs - Removed inline_nanbox mod, cleaned tests
  - crates/compiler/src/codegen/words.rs - Removed nanbox float/bool literal functions
  - crates/compiler/src/codegen/program.rs - Removed nanbox Value type definition
  - crates/compiler/src/codegen/statements.rs - Removed nanbox dispatch
  - crates/compiler/src/codegen/virtual_stack.rs - Removed nanbox spill function
  - crates/compiler/src/codegen/inline/mod.rs - Cleaned doc comments
  - crates/compiler/src/codegen/inline/dispatch.rs - Cleaned doc comments
  - crates/compiler/src/codegen/inline/ops.rs - Removed nanbox peek_pop_bool
@claude
Copy link
Copy Markdown

claude Bot commented Jan 12, 2026

Code Review - PR #243: NaN-boxing Removal

This PR successfully removes the NaN-boxing feature from the codebase, simplifying the value representation to a single 40-byte tagged union approach. The changes are extensive but well-executed.

Strengths

  1. Comprehensive Cleanup: The PR thoroughly removes all NaN-boxing code across:

    • Runtime implementation (nanbox.rs - 1,412 lines removed)
    • Compiler codegen for nanbox mode (inline_nanbox directory - ~1,300 lines)
    • Feature flags in both crates
    • Documentation (NANBOX_PLAN.md)
  2. Code Quality:

    • Removed complex #[cfg(feature = "nanbox")] conditional compilation blocks
    • Simplified code paths by eliminating dual implementations
    • Better maintainability with single value representation
  3. Test Coverage: According to the PR description, all 325+ unit tests and 199 integration tests pass. This is excellent validation.

  4. Good Documentation Updates:

    • Updated comments in time_ops.rs to remove nanbox-specific design notes
    • Cleaned up inline documentation in codegen modules

📝 Observations

1. time_ops.rs Changes (crates/runtime/src/time_ops.rs)

The changes to elapsed_nanos() implementation look good:

  • Uses AtomicI64 for thread-safe base time initialization
  • Proper use of compare_exchange for race-free initialization
  • Good platform-specific handling (Unix vs Windows)

Minor suggestion: The comment on line 75 says "value 0 means uninitialized" but there's a subtle edge case: if raw_monotonic_nanos() ever returns exactly 0 on the first call, the initialization logic would fail. While extremely unlikely in practice (would require nanosecond-perfect timing at boot), consider using AtomicBool + AtomicI64 or a sentinel value like i64::MIN for absolute clarity.

2. Code Removal Safety (crates/compiler/src/codegen/)

The removal of nanbox-specific code appears safe:

  • codegen_peek_pop_bool now has only one implementation (lines 831-860 in inline/ops.rs)
  • Removed duplicate implementations for literals, arithmetic operations
  • No orphaned references to nanbox features found

3. Cargo.toml Changes

Good cleanup of feature flags:

  • Removed nanbox feature from both compiler and runtime crates
  • Simplified feature documentation
  • No breaking changes to public API

🔍 Potential Issues

1. Benchmark File Update (benchmarks/LATEST_RUN.txt)

The benchmark file was updated with new timestamp and commit. This is fine, but verify:

  • Were benchmarks actually run to validate performance characteristics after nanbox removal?
  • Any significant performance changes compared to the previous nanbox implementation?

Recommendation: Include benchmark comparison data in the PR description if not already done, especially for operations that might have benefited from the 8-byte nanbox representation.

2. Missing Migration Documentation

Consider adding:

  • A note in CHANGELOG or migration guide about the removal
  • Any implications for users who might have been using the nanbox feature
  • Performance characteristics comparison (40-byte vs 8-byte values)

3. Virtual Stack Implications

The virtual stack optimization (keeping top N values in SSA registers) becomes even more important now that values are 40 bytes instead of 8. Verify:

  • Virtual stack is properly handling the 40-byte layout
  • No performance regressions in stack-heavy operations

🔒 Security Considerations

✅ No security issues identified:

  • Proper memory management in stack operations
  • Safe use of unsafe blocks in time_ops.rs with correct safety comments
  • No new unsafe code introduced

🎯 Performance Considerations

Potential concerns:

  1. Memory Usage: 40-byte values vs 8-byte nanbox values = 5x memory usage for stack values
  2. Cache Efficiency: Larger values may reduce cache effectiveness
  3. Copy Operations: More bytes to copy for stack operations like dup/swap

Mitigations already in place:

  • Virtual stack optimization reduces memory operations
  • Inline operations avoid runtime calls
  • clone_value only used for heap types

Recommendation: Monitor production workloads for any performance changes, especially in stack-intensive code.

📊 Test Coverage

Excellent: PR description indicates all tests pass (325+ unit tests, 199 integration tests)

Suggestion: Consider adding specific tests for:

  • Stack operations with 40-byte values (to prevent future regressions)
  • Edge cases in elapsed_nanos() multi-threading behavior

🎨 Code Style

✅ Consistent with existing codebase
✅ Proper use of Rust idioms
✅ Good documentation and comments

Summary

This is a high-quality refactoring PR that successfully removes technical debt by eliminating the experimental nanbox feature. The changes are comprehensive, well-tested, and improve code maintainability.

Approval Status: ✅ APPROVED with minor suggestions

The removal of ~3,500 lines of complex conditional compilation code significantly improves maintainability without introducing bugs (based on passing test suite).

Action Items (optional):

  1. Add performance comparison data to PR description
  2. Consider adding migration note to CHANGELOG
  3. Verify benchmark results show acceptable performance characteristics

Review generated by Claude Code - Automated PR Review

@navicore navicore merged commit 6ff773c into main Jan 12, 2026
2 of 3 checks passed
@navicore navicore deleted the revert-nanbox branch January 12, 2026 02:24
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant