[ANN] MlFront_ProgressZig - Zig-compatible progress trees

I am pleased to announce MlFront_ProgressZig. Install instructions, docs and examples further below.

TLDR: It renders a progress tree (a generalization of a progress bar). The killer feature is rendering a single progress tree with progress data fed from compatible child/grandchild/etc processes (see 2nd and 3rd examples). MlFront_ProgressZig is a port of Zig’s progress standard library, with improvements for Windows and protocol compatibility with zig processes. The motivation and algorithm is at Zig's New CLI Progress Bar Explained - Andrew Kelley. The port was initially AI-assisted; prompts for progress.zig start at line 1 here and Cabinet (government) data starts on line 218 here.

Examples: Normal Progress Tree

What Animation Link
Cabinet officials since 1975 https://asciinema.org/a/NWc2vbPeRQuOyGAa
OCaml spawns a zig build https://asciinema.org/a/Tu9ofrH3ekKUCyLk
OCaml spawns OCaml which spawns OCaml https://asciinema.org/a/Tdtt52iQqSsIXcku

Zig seems to have a bug, at least on Windows, where a zig parent can’t collect data from an OCaml/zig child. That is why there are no “zig spawns OCaml” examples.

Example: Performance Monitoring

Here is a snapshot of my single-threaded build system. The interesting parts of the call stack are added to the progress tree (basically start and end_ around a function):

$ ./dk0 distribute CommonsBase_Std-dist-win32 --library 'CommonsBase_Std@2.5.999911122233' dist-win32.u

[signify] New build key pair in t/k/build.pub and t/k/build.sec ...
[signify] Distribute key pair among trusted coworkers only!
►0/2] distribute CommonsBase_Std-dist-win32
   └─ [2/5] prepare distribution
      └─ [29/32] get-object CommonsBase_Std.Toybox@0...
         └─ dl toybox-aarch64@toybox sz 806K
            └─ landley.net/toybox...oads/binaries/0.8.9
               └─ [0/1] MiB downloaded

By seeing the “►” tree not update for more than 10 seconds, I could see that downloading a small 806K file from the landley.net/toybox webserver was killing the performance.

It is easy to identify perf bottlenecks that last longer than 0.5 seconds.

Packages

  • MlFront_Progress: The API which can be used with one of four backends. Includes the “silent” and “plain” backends.
  • MlFront_ProgressZig: The zig compatible backend (high refresh rate)
  • MlFront_ProgressPeriod: A backend which dumps the progress tree periodically to the console.

Docs are at https://dkml.gitlab.io/build-tools/MlFront/.

Installing It

I have it in the opam queue (https://github.com/ocaml/opam-repository/pull/29918) and don’t expect it to be released until the AI thread is resolved. Install the bleeding edge with:

for pkg in MlFront_Progress MlFront_Core MlFront_Lua MlFront_ZipFile UnifiedScript_Std MlFront_Thunk MlFront_Console MlFront_ProgressZig; do
  opam pin add $pkg https://gitlab.com/dkml/build-tools/MlFront/-/releases/permalink/latest/downloads/MlFront.tar.gz
done

(Even though I document “AI” in a couple files, I do it for my own benefit, apply it narrowly, and keep it under my control. Among other things, I can’t imagine there are many (American) attorneys who would say it is wise for me to proactively and quasi-permanently label packages as “AI assisted/etc.”, so I’ll keep my packages out of the opam repository if that becomes a new policy.)

Enjoy!

3 Likes