DEV Community

SCXR DEV
SCXR DEV

Posted on

How I Built Enzato: A Sub-Millisecond Terminal Text Editor in Safe Rust

Are you tired of command-line tools that take half a second to initialize? When did editing a quick config file in our terminals become a process that eats up hundreds of megabytes of RAM?

To solve this, I wanted to build something fast, safe, and completely transparent.

I am Ashan Imalka (scxr-dev on GitHub), and I created Enzato to bring raw, bare-metal speed back to command-line text editing. It is a minimalist terminal text editor written in 100% safe Rust, engineered specifically to tackle latency bloat and protect memory space.

The Tech Under the Hood: Why Enzato is Fast

Many modern text-rendering engines parsing large files (larger than 10 MB) rely on complex index trees or virtualized layers. This introduces pointer overhead and garbage collection pauses that slow down keyboard input.

Instead of adding heavy abstractions, Enzato implements a mathematically optimized Gap Buffer data structure.

The Layout of a Gap Buffer

A Gap Buffer maintains the active document as a single contiguous array, split into two segments by a sliding "gap" of unallocated memory space. The active cursor maps directly to the start of this gap:

Memory Layout = [C0, C1, C2, ... [ Unallocated Gap ] ... Cn-1, Cn]

This design ensures:

  1. O(1) Edit Complexity: Typing or deleting text at the cursor position performs in constant time. No matter how large the file is, the edits happen instantly because the buffer only has to slide elements when the cursor moves to a far-away line.

  2. Predictable Memory Growth: Your physical system RAM scales linearly in a 1:1 ratio with the disk file size.

Hard Performance Metrics

To prove these claims, I built a programmatic benchmark runner to stress-test Enzato under real production conditions. Running a native release build yields these elite metrics:

  • Cold Boot Latency (T_start): ~0.68 ms (virtually instantaneous).
  • Baseline Memory Footprint (M_idle): Less than 2 MB of physical RAM.
  • 50MB Stress Loading: Startup completes in less than 25 ms while preserving safe, predictable memory scaling.

Security and Trust

One of the issues custom Rust binaries face on Windows is triggering lazy heuristic warnings from anti-virus platforms due to raw Win32 system APIs (like standard clipboard hooks).

To ensure Enzato is trusted immediately by systems administrators and security analysts, I proactively submitted our binary to Microsoft Security Intelligence for a full manual review.

The binary has been officially analyzed and whitelisted as 100% safe (Not Malware) under Submission ID: 1311234b-5a50-497e-875d-f6a374ad9df4. You can run it with complete peace of mind.

Try It Out!

Enzato is completely open-source, licensed under the MIT License, and open for contributions.

If you are a systems engineer, Rust enthusiast, or terminal optimization nerd, I would love for you to try it out, audit the source code, and share your thoughts!

👉 Check out the project on GitHub:

https://github.com/scxr-dev/enzato

If you find the architecture interesting, please consider dropping a ⭐ star on the repository! It helps independent developer projects gain visibility in the open-source community.

Top comments (0)