Fork me on GitHub
#babashka
<
2023-09-06
>
hlship17:09:35

A little note about Babashka performance (tl;dr; it's crazy fast). For my https://github.com/hlship/cli-tools library, I was curious ... it works great for building apps with 10 or so commands, but what if you needed 100 or 1000? So I wrote a BB script to generate an app from templates, with varying number of namespaces, each with varying number of commands (each command having a handful for options and arguments). My basic measure was how long app help took to run, since it has to load all the namespaces, massage and sort the extracted data, and format all the output. I scaled this up to a ridiculous 5000 commands (100 namespaces, 50 commands in each namespace) and app help took .... 0.9 seconds (on my M1 MacBook Pro). At NuBank, we have this central tool called nu that's a big wrapper around a tree of bash scripts for all kinds of development, deployment, and admin behavior (some of which is already written in Babashka); it has about 1500 commands, and its equivalent of nu help takes ... 4.9 seconds. For comparison, I rebuilt my template app with 250 namespaces of 6 commands (1500 commands total), and the time for app help was 0.3 seconds.

26
babashka 29
👍 8
🤯 6
2
❤️ 6
clojure-spin 1
borkdude17:09:46

And perhaps you can apply some lazy loading as well

hlship21:09:55

If I need to support 5000 commands then I'll look for some optimizations 🙂. Maybe even 1500. For a reasonable sized set of internal commands, no optimization is needed.

😃 2
hlship21:09:36

I think there's a conference talk in here, about creating a personal tool set for your work. Babashka and cli-tools adds the structure.

👍 13
💯 5
clojure-spin 1
borkdude21:09:16

go for it :)

pesterhazy07:09:54

FWIW we're building a very similar tool at Pitch, albeit at smaller scale, called pit. Of course it's written in babashka and it's super fast as well

👍 2
pithyless03:09:16

Can you share with us how you're scaling/organizing the NuBank's nu interface to ~1500 commands? Are you using subcommands or some naming/prefix conventions? Can you share examples of the hierarchy? Similarly, if someone wants to describe Pitch's pit approach or another company's similar tool, that'd be great, too. I think there is a lot of organizational knowledge here that could be beneficial to the larger community.

hlship04:09:45

Not currently intending to rewrite nu using cli-utils … I used that as an example of an upper limit on how big you could go. If you look at main branch, which will be 0.9, I’ve been adding more organization - each namespace is a category of commands, and may optionally have a command prefix.

hlship22:09:06

Thats my example of a focused, personal tool. I like having all the bells and whistles as well. Importantly I can quickly add new commands as needs evolve.

pithyless22:09:08

Thanks for the flow screenshot; I wasn't implying that nu was written in babashka, I was just asking for a feeling of what nu help prints out if I had access to it; what I'm struggling with exactly is how to organize so much organizational knowledge (deploys, testing, building, logging, monitoring, etc) that it still make sense under a single company-wide cli tool.

hlship18:09:25

nu commands is the equivalent of flow help; it gives you a shallow listing of available commands, with no break down of categories, or any form of description. Not good for discovery.