Skip to main content

Module tiles

Module tiles 

Source
Expand description

Where each rectangle goes, and what it is allowed to claim about itself.

Two separate problems, and the second one is the whole reason this task was a spike.

§Squarifying

squarify is Bruls, Huizing and van Wijk’s algorithm: lay the weights out in rows against the shorter side of what is left, closing a row the moment adding to it would make the worst aspect ratio worse. Slice-and-dice — the obvious alternative — gives exact areas too and gives them as slivers, and a sliver is a rectangle whose area nobody can read.

§The honest map

A treemap encodes one measure as area, and pristine does not have one measure. A claim is published the moment it is judged and priced later (#618), so at any instant the tree holds bytes for some claims and nothing at all for the rest — and a directory nobody has measured is not worth zero bytes, it is worth an unknown number of them.

Laying children out by priced bytes alone would draw a 40 GB node_modules nobody has reached as a sliver, or as nothing. That is the one lie this tool must not tell, and it is not a rounding error: a default --breakdown over one real ~/repos publishes its last claim at 7.5 s and finishes pricing at 63 s, so for a minute most of the map would be a lie about most of the disk.

So the map is split in two before anything is laid out. The known region is squarified by priced bytes and every rectangle in it means exactly what it looks like. The unknown region is squarified by unpriced claim count, drawn as texture rather than as colour, and labelled in directories rather than in bytes.

The unknown region’s area is not information and is not claimed to be — there is no honest area for “we have not looked”, and the count in the label is the only thing in that half of the picture that is a fact. What its area buys is presence: the region cannot be zero-width while anything is unpriced ([MIN_UNKNOWN]), so a reader can never mistake a half-measured tree for a measured one, and it shrinks as the pool catches up — which is #621’s rule that motion should be a value the view already holds, in the one place a treemap can obey it.

This is the spatial form of the answer Roll::label and #621’s > 4.2 GiB already give in text: say what is known, and say that the rest is not known, rather than averaging the two into a number that is wrong in the direction a cleaner must never be wrong in.

Structs§

Area
A rectangle, in image pixels.
Map
A whole map: the mapped directory, its rectangles, and where the two regions meet.
Tile
One rectangle of the map.

Enums§

Kind
What a rectangle’s area is made of, which decides how it is drawn and what it may say.

Functions§

caption
The line across the top: which directory this is a map of, and what it is worth.
focus
Which directory the map is of, given where the cursor is.
mappable
Whether there is a map of root in area at all.
plan
The map of root inside area, or None when there is nothing honest to draw.
squarify
Bruls, Huizing and van Wijk’s squarified treemap.