How Kavach Is Fast
● Advanced4 min
Kavach is fast because it does less work: no interpreter, no garbage collector, no copies it can avoid, and every core when a loop allows it.
| How | What it saves |
|---|---|
| Native machine code | programs compile to machine code through LLVM or Cranelift, with no interpreter and no virtual machine in between |
| No garbage collector | memory is freed the moment its last use ends, so a program never stops for a collector |
| Values never alias | a list has one owner, so the compiler can keep values in registers and run loops on every core safely |
| Loops on all cores | a plain loop is split over every core, with the one-core result exactly |
| Packed small numbers | a list of bytes or Bools takes one byte per item, so eight times as many fit in the fast caches |
| Radix sort | whole numbers sort in a few passes by digit, not by comparing pairs |
| Fused pipelines | a chain of map, filter and sum runs as one loop, with no list built between the steps |
| The GPU | a map with a gpu fn runs on thousands of GPU threads |
None of these change what a program prints. A loop on all cores gives the one-core answer, the GPU gives the CPU's, and a sum of floats keeps its order: speed never changes a result.
Every speed claim on this site comes from a benchmark you can run yourself, against C++ and Python, with the exact commands: see Benchmarks.