Rewrite mapsize in Rust and remove the Go implementation #1

Merged
andydixon merged 13 commits from rust-port into master 2026-10-08 19:33:31 +02:00
andydixon commented 2026-10-08 19:32:34 +02:00 (Migrated from github.com)

Rewrites mapsize in Rust and removes the Go implementation. The crate is at the repo root; cmd/, internal/, go.mod and go.sum are gone. Flags, keys, views, themes, the config file and the .msz snapshot format are unchanged: snapshots from 1.x releases load, and 1.x releases load new ones (src/snapshot/testdata/v1.2.0.msz pins that in a test).

Platforms

OS Architectures Built with
Linux amd64, arm64, 386, armv7, riscv64 (static musl) cargo-zigbuild + zig
Windows amd64, arm64 cargo-zigbuild + zig
macOS amd64, arm64 native on a macOS runner
FreeBSD, NetBSD amd64 cross

These are no longer built: OpenBSD and FreeBSD/arm64 (no supported Rust cross toolchain).

Per-OS behaviour lives in src/platform/{unix,windows}.rs:

  • Linux uses statx through the raw system call, so static musl builds link.
  • macOS uses fstatat, the Finder trash and open -R.
  • The BSDs use fstatat; they have no trash, and permanent delete is offered only on headless systems, as before.
  • Windows uses std metadata, the Recycle Bin via SHFileOperationW, and explorer /select,. Its only new dependency is windows-sys, which was already in Cargo.lock.

Build, CI and release

  • ci.yml: rustfmt and clippy with -D warnings. Tests on Linux (x86-64, ARM64), macOS (Intel, Apple silicon) and Windows. A cross-build of every non-macOS target, with the ARM and RISC-V binaries run under qemu.
  • release.yml (on a v* tag): builds every target, then scripts/release.sh produces archives, .deb/.rpm/.apk/Arch packages and SHA256SUMS. Asset names are the same as in earlier releases. It then publishes the GitHub release with the CHANGELOG section as its notes.
  • Scripts:
    • scripts/build.sh cross-builds locally.
    • scripts/nfpm.sh runs a pinned, checksummed nfpm, replacing go run.
    • packaging/repo.sh and the Homebrew formula build with cargo.
    • examples/treegen.rs replaces cmd/treegen.

Testing

  • Locally: cargo fmt --check, cargo clippy --all-targets -D warnings, and 74 tests passing on Linux.
  • cargo clippy -D warnings passes for all 11 release targets.
  • A static musl build was built and run.
  • scripts/release.sh was run locally, and its packages' filenames match the v1.2.0 release.
  • Windows, macOS and the BSDs are compile-checked only. This PR's CI is the first run of the tests on macOS and Windows.

Performance (vs 1.2.0, same machine, interleaved runs)

Scans are 1.24–1.34× faster with 35% less memory. Snapshot load is 1.48× faster, and scan + save 1.63× faster. Cold treemap frames are 3.2× faster, layout is 10× faster, and filters are 1.1–1.8× faster. Full tables are in PERFORMANCE.md.

Behaviour changes (CHANGELOG "Unreleased")

  • --log/--log-level are accepted but ignored, and --cpuprofile/--memprofile are removed.
  • A search containing text like voilà no longer hangs.
  • Huge sizes saturate rather than wrap in filters and comparisons.
  • JSON export no longer HTML-escapes <>&, and started is written in UTC.

The version stays 1.2.0 in Cargo.toml; choose the release number when tagging.

Rewrites mapsize in Rust and removes the Go implementation. The crate is at the repo root; `cmd/`, `internal/`, `go.mod` and `go.sum` are gone. Flags, keys, views, themes, the config file and the `.msz` snapshot format are unchanged: snapshots from 1.x releases load, and 1.x releases load new ones (`src/snapshot/testdata/v1.2.0.msz` pins that in a test). ## Platforms | OS | Architectures | Built with | |---|---|---| | Linux | amd64, arm64, 386, armv7, riscv64 (static musl) | cargo-zigbuild + zig | | Windows | amd64, arm64 | cargo-zigbuild + zig | | macOS | amd64, arm64 | native on a macOS runner | | FreeBSD, NetBSD | amd64 | cross | These are no longer built: OpenBSD and FreeBSD/arm64 (no supported Rust cross toolchain). Per-OS behaviour lives in `src/platform/{unix,windows}.rs`: - Linux uses `statx` through the raw system call, so static musl builds link. - macOS uses `fstatat`, the Finder trash and `open -R`. - The BSDs use `fstatat`; they have no trash, and permanent delete is offered only on headless systems, as before. - Windows uses std metadata, the Recycle Bin via `SHFileOperationW`, and `explorer /select,`. Its only new dependency is `windows-sys`, which was already in `Cargo.lock`. ## Build, CI and release - **`ci.yml`:** rustfmt and clippy with `-D warnings`. Tests on Linux (x86-64, ARM64), macOS (Intel, Apple silicon) and Windows. A cross-build of every non-macOS target, with the ARM and RISC-V binaries run under qemu. - **`release.yml` (on a `v*` tag):** builds every target, then `scripts/release.sh` produces archives, .deb/.rpm/.apk/Arch packages and SHA256SUMS. Asset names are the same as in earlier releases. It then publishes the GitHub release with the CHANGELOG section as its notes. - **Scripts:** - `scripts/build.sh` cross-builds locally. - `scripts/nfpm.sh` runs a pinned, checksummed nfpm, replacing `go run`. - `packaging/repo.sh` and the Homebrew formula build with cargo. - `examples/treegen.rs` replaces `cmd/treegen`. ## Testing - Locally: `cargo fmt --check`, `cargo clippy --all-targets -D warnings`, and 74 tests passing on Linux. - `cargo clippy -D warnings` passes for all 11 release targets. - A static musl build was built and run. - `scripts/release.sh` was run locally, and its packages' filenames match the v1.2.0 release. - Windows, macOS and the BSDs are compile-checked only. This PR's CI is the first run of the tests on macOS and Windows. ## Performance (vs 1.2.0, same machine, interleaved runs) Scans are 1.24–1.34× faster with 35% less memory. Snapshot load is 1.48× faster, and scan + save 1.63× faster. Cold treemap frames are 3.2× faster, layout is 10× faster, and filters are 1.1–1.8× faster. Full tables are in PERFORMANCE.md. ## Behaviour changes (CHANGELOG "Unreleased") - `--log`/`--log-level` are accepted but ignored, and `--cpuprofile`/`--memprofile` are removed. - A search containing text like `voilà` no longer hangs. - Huge sizes saturate rather than wrap in filters and comparisons. - JSON export no longer HTML-escapes `<>&`, and `started` is written in UTC. The version stays 1.2.0 in `Cargo.toml`; choose the release number when tagging.
Sign in to join this conversation.