Part 1 of 20 in Tools we built and why. Next: heaptide: finding the memory a program forgot to give back
What this is about
A tool is a small program that does one job so you do not have to do it by hand. Most of the tools we share began the same way. We asked a question about our own work, looked for a tool that answers it, and did not find one. So we wrote a script. When the script kept being useful, we turned it into a tool and put it on GitHub.
This post is the first in a series of twenty. Each later post takes one of our tools and shows what it does, in plain words, with a way to try it. This first post explains why we build tools at all, and how we decide a script is ready to share.
Why it matters
If you use computers for more than browsing, you meet the same wall again and again. Something is slow, or a program eats memory, or a chat with an AI model gets too long to fit. You can guess at the cause. Guessing is cheap and often wrong. A tool that measures the cause is worth more than any amount of guessing.
There is a second reason to read about how tools are made. When you know how a tool was checked, you know how much to trust it. A tool that has never been compared with anything can print confident numbers that are wrong. We want you to be able to tell the difference, so we show our checking along with our tools.
How a script becomes a tool
Here is the path, in five steps. Each step comes from something we did, not from a theory.
- Start with one question. Not "build a profiler", but "why does this loop run slowly on my processor?" A narrow question keeps the first version small.
- Look at what exists. For line counting, a good tool called tokei already existed. It answers "how many lines of code are here?" very well. Our questions were different: is this change inside a size budget, and how many tokens will this code cost in a prompt? So we wrote mokei, which keeps tokei's counts and adds those answers.
- Write the smallest script that answers it. One file, one job. If it needs a long explanation, it is too big.
- Check it against something you trust. A tool that disagrees with a trusted reference is wrong until proven otherwise. Our Mojo libraries are each checked against the Python or C tool they copy. The post Why our Mojo libraries copy Python byte for byte shows how.
- Write down what it does not do. This step is the one most projects skip. We keep a plain list of limits next to every tool.
That last step deserves an example. Our post Keeping the Failures In is about one document in the mojo-baro repository whose only job is to say what the code actually does, and what it does not do just as plainly. It finds a setting that is on by default and has no effect at all on one of the two models the engine runs. A document that only listed what works would never have said so.
Four questions that became tools
Here are four of the tools in this series, each with the question behind it.
- Where did the memory go? Many leak checkers need a rebuild or a slow run. On an allocation-heavy loop in our benchmark, Valgrind's memcheck was 48 times slower than heaptide. GPU memory was the harder case, because the graphics runtime keeps its own pools. That is why we wrote heaptide.
- Why is this instruction slow? A profile that lists hot functions does not say why. corewait gives each instruction a cause: memory, branch, dependency, front end, or busy.
- How big is this change? mokei counts lines in 40 languages like tokei, then adds diff budgets, token counts and duplicated blocks.
- How do I keep a long AI session short? ctxd folds old turns of a chat into summaries and keeps the full text on disk, so nothing is lost.
None of these started as a plan to make a product. Each started as an annoyance.
The libraries come first
Under most of our tools sit small libraries. The amarbaro.com page lists thirty-eight Mojo libraries, each in its own public repository, each with tests against an oracle and a conda package. A library is a part you reuse, such as a JSON reader, a CSV reader or a way to read the temperature of a graphics card. When a tool needs a part that a library lacks, we add the part to the library and check it there, then use it in the tool. This keeps each tool short.
Two GitHub owners hold the work. Our tools live at github.com/amarbarosys. Our Mojo libraries live at github.com/amarbaro. If you are looking for one thing, those two pages are the front door.
What this does not prove
Building your own tools is not always the right choice. If a good tool already answers your question, use it. We keep tokei as the reference for line counts, and we use Python's own libraries as the reference for ours. Our tools are young, with versions from 0.1 to 1.5, and each has a Limits section that you should read before you rely on it.
Words you may not know
- Tool: a small program built to do one job.
- Library: a set of ready-made parts that other programs reuse.
- Oracle: a trusted program whose answers we compare ours with.
- Profiler: a tool that shows where a program spends its time.
- Memory leak: memory a program asked for and never gave back.
- Token: a small piece of text that an AI model reads and writes.
- Repository: a folder of code with its full history, kept on GitHub.
Try it
- Open github.com/amarbarosys. Pick any tool and read the first screen of its README. Find the "Limits" section.
- Open github.com/amarbaro. Pick any library and find the line that says what it was checked against.
- Visit the Mojo libraries page for one table with every library, what it does, and its version.
- Ask a question of your own on gllm.forum, our forum for careful talk about language models.
If a question of yours has no tool yet, write the smallest script that answers it, and check that script against something you trust.
Read next
- Keeping the Failures In: why a capability document must list what does not work.
- heaptide: finding the memory a program forgot to give back: the next post in this series.

Comentarios
Aún no hay comentarios.
Iniciar sesión para comentar.