Ask anything about this article
Hi! I've read this article.
What would you like to know?
@farhan

If you work on any kind of live mapping, GIS service, or game engine, you have probably heard the recent Hacker News post titled "Faster than earcut: triangulating 3.7M map polygons in 489 ms". The claim is simple: a new implementation can process three point seven million polygons in under half a second, beating the long‑standing earcut.js library by a wide margin. In a world where latency directly translates to user churn, this is not just a brag‑ging brag; it's a signal that the performance ceiling for real‑time geometry processing is moving.
Hot take: The bottleneck is shifting from algorithmic complexity to memory bandwidth and cache friendliness. If you ignore this, your next mapping project will feel sluggish compared to competitors.
In this post we break down the benchmark, compare it to earcut, explore why it matters for developers today, and even look at a seemingly unrelated AI experiment (WorldTUI) to highlight the broader trend of speed versus intelligence.
The original Hacker News thread linked to a GitHub repo that:
The reported time: 489 ms total, including file I/O. For comparison, earcut.js on the same data (run in Node.js) took 4.8 seconds – a ten‑fold slowdown.
| Aspect | earcut.js | New Rust Triangulator |
|---|---|---|
| Language | JavaScript (interpreted) | Rust (compiled, zero‑cost abstractions) |
| Core Algorithm | Ear clipping (O(n^2) worst case) | Sweep‑line + monotone polygon decomposition (near O(n log n)) |
| Memory Layout | Array of objects (poor cache) | Flat typed arrays (contiguous) |
| Parallelism | Single‑threaded | Rayon‑based multi‑core parallelism |
| SIMD Utilization | None | AVX2 vectorized geometry ops |
The biggest win comes from data layout and parallelism. earcut.js stores each vertex as a separate JavaScript object, causing pointer chasing and cache misses. The Rust version packs all coordinates into a single Float32Array, allowing the CPU to prefetch efficiently.
Earcut is beloved for its simplicity and small bundle size, but its algorithmic complexity is quadratic in the worst case and it was never designed for massive batches. The new approach uses three tricks:
Together these bring the effective complexity down to roughly O(n log n) with a very low constant factor.
Companies like Mapbox, CARTO, and Google Maps constantly stream vector tiles to browsers. Each tile may contain dozens of polygons; on a busy city view you can easily hit thousands of vertices per second. Reducing triangulation from 5 ms per tile to 0.5 ms means:
Open‑world games often generate navigation meshes on the fly. A ten‑fold speedup allows developers to rebuild nav‑meshes in real time when terrain changes, opening up dynamic world‑altering gameplay.
Embedded devices that need to render GIS data (e.g., drones, AR glasses) benefit from the reduced memory footprint of a flat array and the ability to run the Rust library directly on ARM cores.
No technology is a silver bullet. The new triangulator has a few caveats:
Developers must weigh these against the performance needs of their product.
In the same Hacker News feed, another post titled "WorldTUI: I trained a 360M model to pretend to be a terminal" showcases a 360‑million‑parameter language model that can generate realistic terminal sessions. While impressive, it highlights a different axis of progress: intelligence vs. raw speed.
The juxtaposition of a 0.5 s triangulation and a multi‑second AI generation illustrates where the industry is: performance‑critical code still lives in low‑level, highly optimized languages, while AI tools augment developer productivity.
Float32Array instead of objects can halve memory traffic.The headline "Faster than earcut: triangulating 3.7M map polygons in 489 ms" is more than a brag; it marks a shift in how we think about real‑time geometry. By moving heavy lifting to compiled, SIMD‑aware code and embracing parallelism, developers can finally break the latency wall that has limited interactive maps and games for years. At the same time, AI experiments like WorldTUI remind us that speed and intelligence will continue to evolve side by side. The next generation of mapping apps will be both faster and smarter – if you choose the right tools today.