blog.rust.gay

ANKAA brings SVE2 to stable Rust in an Arm-first time-series engine

ANKAA 0.2 appeared on the Rust users forum on November 13. It describes itself as a real-time time-series engine for aarch64 Linux, with a build that also runs on x86-64. It ingests MQTT, Kafka, NATS, exchange feeds, and files; keeps recent data in columnar chunks behind a write-ahead log; compresses history with Vortex; and serves SQL through Apache DataFusion over Arrow Flight, Flight SQL, and the Postgres protocol. It is Apache-2.0, pre-alpha, and openly AI-assisted.

The headline feature is not the ingestion pipeline or the query layer. It is the way ANKAA reaches Arm's SVE2 vector instructions from stable Rust. The SVE intrinsics in Rust are nightly-only, so the project uses global_asm! to write the kernels directly. That is a pragmatic workaround with real costs, and the author is unusually candid about them. The kernels are vector-length agnostic, differential-tested against scalar and NEON implementations under QEMU at 128, 256, and 512 bits, and checked on real Neoverse V2 hardware. At 128-bit vectors, NEON was faster for every kernel but one, so the engine chooses per kernel at run time.

That last sentence is the most interesting part of the announcement. A project that was built to showcase SVE2 is willing to say that, on the hardware most people have, the older SIMD extension is often faster. That is the kind of result that makes a performance claim credible.

Why SVE2 on stable Rust is awkward

Arm's Scalable Vector Extension is different from NEON in a way that matters to compiler writers and library authors. NEON has fixed-width vectors: 128 bits on most implementations. SVE has scalable vectors: the hardware chooses a length, and the same binary can run on a machine with 128-bit, 256-bit, or 512-bit vectors. The code is written in terms of a vector length that is not known at compile time. That is the "vector-length agnostic" model, and it is the reason SVE code can be portable across Arm server generations without recompilation.

In C and C++, the ACLE intrinsics expose SVE operations with types like svfloat32_t whose size is determined at run time. In Rust, the equivalent intrinsics exist, but they are unstable. They are behind a nightly feature gate, and the API is not stabilized. A project that wants to ship on stable Rust cannot use them directly. It can wait, use a nightly toolchain, or find another way.

ANKAA chose another way. global_asm! lets a Rust program embed assembly in a global assembly block. The project uses it to write the SVE2 kernels as assembly, with the Rust side calling into them. That gives stable-Rust users access to the instructions without requiring a nightly compiler. It also means the kernels are written in assembly rather than in intrinsics, which changes who can maintain them and how they are tested.

The cost is real. Assembly is harder to read, harder to port, and harder to verify than intrinsics. The compiler cannot optimize across the boundary as easily. The code has to handle the vector-length-agnostic model explicitly, using predicate registers and runtime vector length rather than fixed-width loops. The project has to maintain a separate implementation for each kernel, and it has to test that implementation against a scalar reference on multiple vector lengths.

The benefit is that the code works on stable Rust today. For a pre-alpha project that wants users to try it, that matters. A library that requires nightly is a library that many teams will not adopt, even if the performance is better. The global_asm! approach is a bridge between the stable compiler and hardware features that the stable compiler does not yet expose. It is not the final answer, but it is a reasonable answer for the current state of the toolchain.

The engine: ingest, WAL, Vortex, DataFusion

The SIMD work sits inside a larger system, and the system is worth describing because it explains why the vector kernels matter.

ANKAA ingests live streams. MQTT, Kafka, NATS, exchange feeds, and files are all sources. The data arrives continuously, and the engine has to make it queryable quickly. It keeps recent data in columnar chunks behind a write-ahead log. The WAL is the durability boundary: a record is acknowledged only after it is safely recorded, and the columnar chunks are the queryable representation. Compressing history with Vortex reduces the storage footprint and the I/O cost of scanning old data.

On the query side, ANKAA uses Apache DataFusion. DataFusion is a Rust query engine that operates on Arrow data. It provides SQL planning and execution, and it fits naturally with a columnar storage layer. ANKAA exposes SQL through Arrow Flight, Flight SQL, and the Postgres protocol. That is a deliberate choice: Arrow Flight is a high-throughput binary protocol for Arrow data, Flight SQL is a SQL interface over it, and the Postgres protocol is the lingua franca of database clients. A time-series engine that speaks all three can fit into different toolchains without requiring a custom client.

The architecture is a reasonable one for the problem. Time-series workloads are append-heavy and scan-heavy. Columnar storage is good for scanning, compression is good for old data, and a WAL is good for durability. DataFusion gives the engine a mature query layer without requiring the project to write its own SQL planner. The SIMD kernels sit underneath, accelerating the operations that dominate the query: filtering, aggregation, and arithmetic over columns.

That is where SVE2 comes in. A time-series query often processes a column of values with the same operation: compare against a threshold, sum a window, compute a difference, apply a filter. Those are vectorizable operations. A wider vector can process more values per instruction, which is exactly the kind of gain that Arm servers with SVE2 are designed to deliver. Whether the gain materializes depends on the kernel, the data, and the vector length, which is why the project's honest benchmark matters.

NEON beat SVE2 at 128 bits, and that is fine

The announcement says the kernels are differential-tested against scalar and NEON under QEMU at 128, 256, and 512 bits, and on real Neoverse V2 hardware. At 128-bit vectors, NEON was faster for all kernels but one, so the engine picks per kernel at run time.

This is a useful result for several reasons. The first is that it shows the testing was real. It is easy to claim that a new instruction set is faster. It is harder to test it across vector lengths, compare it against the older implementation, and report that the older implementation wins in the common case. The project did the harder thing.

The second is that it explains why runtime dispatch is necessary. If SVE2 were uniformly faster, the engine could always use it. If it were uniformly slower, the engine could ignore it. The interesting case is mixed: some kernels benefit, some do not, and the right choice depends on the hardware and the data. A per-kernel runtime choice is the correct response to that reality.

The third is that it illustrates the difference between theoretical and practical vector performance. SVE2 has a richer instruction set and a scalable vector model. NEON has a fixed 128-bit width and a mature compiler story. On a machine with 128-bit vectors, SVE2's scalability does not buy anything, and the overhead of predicate handling or the assembly implementation may cost more than the wider instructions save. On a machine with 256-bit or 512-bit vectors, the calculus changes. The benchmark is a reminder that "newer" is not the same as "faster for this workload on this hardware."

The fourth is that it makes the project's claims more trustworthy. A vendor or a hobbyist announcing a new engine might be tempted to report only the cases where the new approach wins. ANKAA reports the case where it loses, and explains the mitigation. That is the behavior of a project that expects to be tested by strangers.

Testing storage like it will lose power

The most interesting engineering detail in the announcement is not the SIMD work. It is the write-ahead log test.

ANKAA's WAL went through 1,000 simulated power cuts using dm-flakey. The goal was to verify that no acknowledged record is lost. The first version of the test rig passed instantly, and that was the bug. drop_writes makes writes succeed without reaching the device. The test was simulating a failure mode that the storage stack was silently absorbing, so the WAL appeared to be durable when it had never been exercised.

That is a classic testing trap, and it is worth spelling out. A power-cut test is supposed to verify what happens when a write is lost or torn. If the test harness drops writes in a way that the file system or the block layer hides, the test is not testing the WAL. It is testing the harness. The fact that the first rig passed instantly was a signal that something was wrong, not a signal that the WAL was perfect.

The fix was presumably to configure the failure injection so that the writes actually fail or disappear at the right layer, and then to run the test 1,000 times. The result is a stronger claim: the WAL survived 1,000 simulated power cuts without losing an acknowledged record. That is still a simulation, not a real power loss, but it is a meaningful test. It exercises the recovery path repeatedly, and it gives the author confidence that the durability boundary is where it claims to be.

The lesson generalizes beyond ANKAA. Storage tests are easy to write in a way that passes for the wrong reason. A test that injects failures at the wrong layer, or that uses a mock which does not reproduce the real failure semantics, can give false confidence. The right approach is to inject failures at the boundary you care about, verify that the injection actually happens, and run enough iterations to catch rare orderings. ANKAA's first-rig failure is a good example of why that discipline matters.

Unsafe policy and concurrency testing

Rust's safety guarantees are only as strong as the code that uses unsafe. ANKAA confines unsafe to four crates: the SIMD code, the single-producer single-consumer ring, and two small syscall wrappers. Every other crate is #![forbid(unsafe_code)]. That is a clear policy, and the project documents it in docs/unsafe-policy.md.

The policy is backed by testing. The ring is checked with loom models and a herd7 litmus test. Loom is a concurrency testing tool that explores interleavings of concurrent Rust code; herd7 is a memory-model tool that checks litmus tests against a formal model. The rest of the code is checked under Miri, which interprets Rust's mid-level IR and catches undefined behavior that ordinary tests miss. The project also uses proptest to verify that parallel ingest produces the same result as single-threaded ingest: the same messages go through N mapping workers and through one thread, and the test compares rows, refusals, and dictionary IDs.

That combination is more rigorous than most pre-alpha projects. It is also well matched to the risks. A SPSC ring is exactly the kind of code where a subtle ordering bug can corrupt data without crashing. Loom and herd7 are the right tools for that. SIMD code is exactly the kind of code where an out-of-bounds access or an alignment assumption can produce undefined behavior. Miri and differential testing are the right tools for that. Parallel ingest is exactly the kind of code where a race can produce a result that looks plausible but is wrong. A proptest that compares against a single-threaded reference is the right tool for that.

The forbid(unsafe_code) boundary is also a useful design choice. It means that a reviewer can focus on four crates instead of the whole codebase. It means that a bug in the safe code is a logic bug, not a memory-safety bug. It means that the project can make a credible claim about its safety posture without claiming that the entire engine is proven correct. That is a mature way to talk about safety in a systems project.

Pre-alpha, AI-assisted, and honest about it

ANKAA is version 0.2. It is pre-alpha. The author describes it as openly AI-assisted, and says that he designs it, reviews every change, writes the tests that gate it, and owns the result. He describes himself as a telecommunications engineer with more than 15 years in product development, firmware, and software engineering. The measurements exist only as single-VM runs published with their scripts, and the project makes no general performance claim.

That framing is unusually careful, and it is the right one for the stage of the project. A pre-alpha time-series engine is not competing with mature databases on production workloads. It is exploring a design: Arm-first, columnar, WAL-backed, DataFusion-based, with hand-written SVE2 kernels. The single-VM measurements are enough to show that the design is viable and that the kernels work. They are not enough to claim that the engine is faster than alternatives in general, and the project does not make that claim.

The AI-assisted disclosure is also worth noting. The author does not hide it, and he does not use it as a excuse. He says he reviews every change and writes the tests. That is the right posture: the tool can help produce code, but the human is responsible for the result. In a project that uses unsafe, hand-written assembly, and concurrent data structures, that responsibility is not a formality.

The examples/factory demo runs a simulated MQTT plant with Grafana via docker compose up -d. That is a small thing, but it matters for adoption. A time-series engine is hard to evaluate without data, and a demo that produces a realistic stream and a dashboard lowers the barrier to trying it. The project is asking for feedback on the global_asm! approach and on whether the unsafe policy has a hole. Those are the right questions to ask at this stage.

What to watch

The first thing to watch is the stabilization of SVE intrinsics in Rust. If the intrinsics become stable, projects like ANKAA can replace hand-written assembly with portable, compiler-optimized code. That would lower the maintenance burden and make SVE2 accessible to a much larger group of Rust developers. Until then, global_asm! is a useful bridge, but it is not a long-term foundation for the ecosystem.

The second is independent benchmarking. The current measurements are single-VM runs by the author. The interesting question is how the engine performs on real time-series workloads, on different Arm server generations, and against established engines. The project is honest that it does not have that data yet. If it publishes reproducible benchmarks and invites others to run them, the claims will become more useful.

The third is the unsafe policy. The four-crate boundary is a good start, but the SIMD code and the SPSC ring are exactly where subtle bugs hide. External review of those crates, and of the loom and herd7 models, would strengthen the project. The author is asking for that review, which is a good sign.

The fourth is production readiness. A pre-alpha engine with a WAL, a query layer, and a compression format has a long road to production. Durability, recovery, schema evolution, backpressure, and operational tooling all have to be built and tested. The 1,000 power-cut runs are a good beginning, not an end.

The fifth is the broader Arm-first trend. ANKAA is part of a growing set of projects that treat aarch64 as the primary target rather than a port. If Arm servers continue to gain share, the tooling and libraries that assume x86 will have to adapt. A project that starts on Arm, uses SVE2 where it helps, and reports honestly where NEON wins is a useful data point in that transition.

ANKAA 0.2 is not a database you should deploy. It is a well-documented experiment in combining stable Rust, Arm SIMD, columnar storage, and a modern query engine. The most valuable thing about it is not any single benchmark. It is the honesty: the project reports where SVE2 loses, tests the WAL by actually injecting failures, confines unsafe and tests the boundary, and states the limits of its measurements. That is the kind of engineering culture that makes a pre-alpha project worth watching.

Sources


← back to posts