r/ada

ais: a plain-text index in C99, no dependencies, nothing allocated on the record path
▲ 32 r/ada+2 crossposts

ais: a plain-text index in C99, no dependencies, nothing allocated on the record path

I wrote a small tool for myself. You file a path, a link or a note under keys you choose, and get it back by those keys. What I would like comment on is how it is written, not what it does.

I came to C alongside FORTRAN, Ada 83 and Pascal in the 90s, so I think in functions, data locality and streams before objects. The rule is that memory is bounded by the structs, not by the data. Records go through one at a time, on the stack, in fixed buffers. get, find, set, merge and compact allocate nothing at all, so a 10 GB store and a 10 KB store run in the same footprint. Set operations are k-way merges over sorted posting lists: keep the head of each list and advance.

Six heap sites in 18k lines, each written down with what bounds it.

Two things I know are wrong: main() is 630 lines and the HTTP handler is 520. Both are flat dispatchers, both are too long, and both are written down as debts rather than defended.

On a million records, 85 MB store, one core: building the whole index is 7.9 s in one streaming pass, a full scan is 1.8 s (cat class), and a get on the hottest key, 270k ids, is 2.2 s. That last one used to take hours, because finding a record by id meant scanning the store; an id-to-offset index fixed it. Bulk import is still O(n^(2)) and I say so in the same doc.

C99, GPLv2+, no dependencies, plain Makefile. About 5k lines of tests, run under AddressSanitizer and UBSan on every push.

Style doc: https://github.com/Anode1/ais/blob/main/doc/dev/STYLE.md
Numbers, reproducible with a seeded generator: https://github.com/Anode1/ais/blob/main/doc/performance.txt
Code: https://github.com/Anode1/ais

u/Anode1_dev — 8 days ago
▲ 20 r/ada

ANN: Flyology 0.1.0 and its ecosystem

Hi there,

A few years ago, I was pondering whether it would make sense for Ada/GNAT to have tasks that wouldn’t just map 1:1 to OS threads. But it wasn’t quite economical to try that out at the time.

Recently, I’ve decided to close this open loop by running a quick experiment over the weekend – the result is a patched RTS and additional runtime primitives that provide lightweight tasks and asynchronous I/O to Ada users. So far, the results have been promising – the overhead of individual threads can be fairly high under high task concurrency, and lightweight tasks mitigate it. Best of all, this doesn’t automatically make all tasks lightweight. Instead, by default tasks remain “native” and lightweight is an opt-in pragma.

On top of that foundation, I’ve cobbled together some I/O (sockets, files, DNS) and additional higher-level libraries for HTTP server & client, Postgres BE/FE protocol, and such. Some performance measurements are fairly encouraging.

In the process of making it, I also put together a few sibling libraries – for benchmarking, debugging, TUIs, and so on.

You can check it out at https://flyology.org – it's early (just cut v0.1.0 across the board), and the full list of crates is available at https://crates.flyology.org/

Would love your thoughts.

reddit.com
u/georgerush — 6 days ago