Architecture

How Pinax is built: the snapshot index, checking it, querying it, the catalog, security, and measured performance.

Pinax reports on what research storage holds: how much, how old, what kind, and who owns it, for file systems of many petabytes and more than a billion files. This document describes the design, the snapshot index that makes it fast, how it is built and queried, security, and measured performance.

Goals and constraints

  1. Directory-level answers at any scale. A PI opens their lab folder and sees a treemap of its subfolders colored by age, then drills down. That must take well under a second whether the folder holds a thousand files or a hundred million.
  2. Many dimensions of the same folder. Size, file count, space on disk, age (by modification and access time), file type and category, and owner, for any folder at any depth.
  3. File-level search when needed: by name or pattern, type, size, age, and owner, scoped to what the person may see.
  4. History. Each scan is kept as a snapshot, so growth and ageing show over time.
  5. Strict scoping. People see only the top-level folders their labs own; IT sees everything.
  6. Read-only. Pinax never touches the file system it reports on. It reads fs-inventory scans.

Components

  Storage nodes or scan hosts
  ┌──────────────────────────────────────────────────┐
  │ fs-inventory scan (Rust; parallel, resumable,    │
  │ read-only) -> Parquet files and a manifest       │
  └──────────────────────────────────────────────────┘
                          │ scan folder (a shared path)
                          ▼
  Pinax server
  ┌──────────────────────────────────────────────────┐
  │ pinax ingest (DuckDB): scan -> snapshot index    │
  │   var/snapshots/<fs>/<scan>/                     │
  │     index.duckdb    directory-level tables       │
  │     files/gNNNNNN/  per-file Parquet, by group   │
  │                     of top-level folders         │
  │                                                  │
  │ catalog (SQLite, or PostgreSQL)                  │
  │   people and roles, labs, folder ownership,      │
  │   filesystems, snapshots, folder history, ...    │
  │                                                  │
  │ FastAPI /api ── read-only DuckDB cursors         │
  │ static UI (HTML, CSS, JS modules; no build)      │
  └──────────────────────────────────────────────────┘
                          ▲ HTTPS, through nginx/Caddy (passwords
                          │ or Entra ID) or oauth2-proxy
  PIs, lab members, finance, auditors, IT, and scripts
PieceChoiceWhy
Crawlerfs-inventory 1.0.0Built for this: parallel, bounded memory, resumable, lossless names, about 40 bytes per entry in Parquet (measured at 100 million files)
Index engineDuckDB (embedded)Columnar, vectorized, spills to disk, reads Parquet natively; no server to run
Per-file storeParquet, split by top-level folder and sorted by pathCompact; a lab's queries read only its files; a subfolder is a contiguous range
CatalogSQLAlchemy on SQLite by default, or PostgreSQL; Alembic migrationsSmall, transactional data: who owns what, which snapshots exist, folder history, prices, the audit log
WebFastAPI and plain JavaScript modulesSame stack and patterns as Tundra; nothing to build

What Pinax keeps

Pinax keeps three kinds of data. Only the catalog cannot be made again, so it is the one to back up.

WhereWhat it holdsSizeIf it is lost
CatalogPINAX_VAR_ROOT/pinax.db (SQLite)Filesystems; a record of every scan; folder history (each top-level folder's totals for every scan); people, their site roles, labs and departments, memberships (with when each role was given), folder ownership and who owned each folder when; local sign-in password hashes and sessions; API tokens (their SHA-256, never the token); prices and free tiers; capacities; cleanup plans, tags, and saved views; the audit log; the ingest watcher's heartbeatSmall: about one row per top-level folder per scan (2,000 folders scanned weekly add about 100,000 rows a year)Restore it from a backup. Without one, register the filesystems again, import people, labs, and folder ownership from the import files, and ingest the kept scans again; prices and free tiers, ownership history, folder history of scans no longer kept, site roles, API tokens (scripts need new ones), plans, tags, views, and the audit log are lost
Snapshot indexesPINAX_VAR_ROOT/snapshots/<filesystem>/<scan>/, one per kept snapshotindex.duckdb: every directory's totals, and its changes since the scan before, with the files new and removed since; files/: Parquet, one row per file, for searches and file listsAbout 56 bytes per file, plus about 60 per file new or removed since the scan before, for each of the newest PINAX_KEEP_SNAPSHOTS (6) snapshots of each filesystempinax rebuild SNAPSHOT_ID makes it again from its scan
ScansWhere fs-inventory wrote them: PINAX_SCAN_ROOT for pinax scan and the watcher, or anywhere for pinax ingestfs-inventory's Parquet and manifest.json: every entry's path, size, times, and ownerAbout 40 bytes per entryNothing changes in the app; that snapshot's index can no longer be rebuilt or checked

What reads what. The web app reads only the catalog and the indexes, never the scans or the filesystem. Ingest reads a scan once, builds its index, and records the snapshot and its folder history in the catalog. After that a scan is read again only by pinax rebuild (after an upgrade that changes the index format, or when an index is lost) and by pinax check (the cross-check against fs-inventory rollup, which also uses the scan before it to check the changes).

Retention. After every ingest, the indexes of all but the newest PINAX_KEEP_SNAPSHOTS ready snapshots of that filesystem are deleted, and those snapshots are marked pruned. Their folder history stays, so History for top-level folders, labs, departments, and filesystems, and every month's charges, cover every scan ever ingested. Treemaps, reports, searches, the change map, and history below the top level need a full index, so they cover the kept snapshots only. Only ready snapshots can be rebuilt, so a pruned snapshot stays pruned.

Scans are never deleted by Pinax. Keep the scan of every snapshot that still has its index, so each can be rebuilt after an upgrade and checked. Once a snapshot is pruned, Pinax has no further use for its scan, and the folder can be deleted (or kept for other analysis). pinax snapshots lists each snapshot's status and scan folder. Weekly scans of a billion-file filesystem take about 40 GB each, about 2 TB a year if none are deleted.

Names are sensitive. Scans and indexes hold every file and folder name and owner account names, and the catalog holds top-level folder names; names in research storage can carry identifiers, such as a study subject's ID in a file name. The catalog also holds people's names and emails and, with local sign-in, password hashes. Treat all three like the filesystem's own metadata: only the pinax user and group can read /var/lib/pinax (mode 0750), and backups and copies need the same protection. In the app, only storage administrators and auditors see across labs (finance sees every lab's charges, not its folders).

The catalog database

The catalog is SQLite by default: a file in PINAX_VAR_ROOT in WAL mode, opened by the Pinax processes themselves, with nothing to install and no database server to run. Many readers work at once; ingests take turns under a lock in PINAX_VAR_ROOT. That suits one server running the web app and the watcher, as DEPLOYMENT.md installs it, and every demo and trial.

For production, PINAX_DATABASE_URL can point at PostgreSQL instead (with Pinax's postgres extra installed): a database that IT runs, backs up, replicates, and monitors as it does others, and whose writers do not wait on one file's lock. Pinax is still one server: indexes and background searches are on its disk. The whole test suite runs on both.

Connections. The web app answers requests in threads, PINAX_WEB_THREADS (40) for the whole process, and runs each request's sign-in check and then its page in a thread each, one after the other. A request holds a catalog connection only while it runs in one of them: it gives it back once it knows who is signed in, and before checking a password (db.release), so threads never all wait for connections held by requests waiting for threads. With SQLite the web app keeps a connection for each thread; with PostgreSQL, PINAX_DATABASE_POOL_SIZE (10, and as many more at busy times), which costs the database server. A request that finds no connection free within 10 seconds is told Pinax is busy (503), and counted in pinax_catalog_busy_total. Measured in Many people at once.

Migrations (Alembic, in src/pinax/migrations, migrate.py) create the catalog and upgrade it in place. They run when Pinax starts, as new tables and columns were added before, unless PINAX_DB_AUTO_UPGRADE=false leaves them to pinax db upgrade, which can also print its SQL for a database administrator. Processes that start together take turns (a lock on PostgreSQL, a lock file beside a SQLite catalog), and a catalog that a newer Pinax has upgraded is refused rather than used. The first revision (0001) is the catalog as 0.9.0 left it, written out rather than taken from the models so it stays fixed; on a catalog made before migrations it adds only the tables and columns that catalog lacks, as Pinax did at start-up until then. Constraints and indexes are named by a rule (db.NAMING), so later revisions can name what they change on either database. A test compares the schema the migrations make with the models', on both.

The key idea: totals per directory, computed once per scan

Drawing a treemap of a folder needs, for each child, its total size, file count, age distribution, and category breakdown over its whole subtree. Computing that from a billion file rows per click is impossible; computing it once per scan, for every directory, is cheap. So ingest turns a scan into a snapshot index in which every directory row already carries its subtree totals, and the interface never reads file rows to draw a chart.

The age color of a folder comes from those totals: the average age is weighted by size (sum of size × modification day, divided by total size), and the last change, oldest file, and last access come from subtree minimum and maximum times. The cold share comes from the age histogram.

The snapshot index

var/snapshots/<filesystem>/<scan start>-<scan id>/:

Table or fileOne row perHoldsSorted by
dirsdirectorySubtree totals: files, folders, bytes, allocated bytes; files and bytes per age bucket by modification time; bytes per age bucket by access time; files and bytes per category; oldest and newest modification, newest access and change; size-weighted time sums for mean ages; count of folders not read completely. Plus the directory's own files (count, bytes, times), its entry count and any scan error, and its device and inode (from index version 6), and its extra hard links and their bytes (from version 7).(depth, path)
dir_extdirectory and file typeTotals over the directory's own files of that typepath
dir_ownerdirectory and owner (uid)Totals over the directory's own files of that ownerpath
top_ext, top_ownertop-level folder and type / ownerThe same, summed per top-level foldertop_id
changesdirectory of this scan or the filesystem's previous oneBoth scans' subtree totals (files, folders, bytes, allocated bytes, size-weighted time sum, files and bytes per age bucket), each scan's own ages, and whether the directory is in each: what changed, new and removed folders included. Only when there was a previous scan(depth, path)
file_changesfile new since the previous scan, or removed sincechange (new or removed), then the file's path, name, type, category, kind, size, allocated bytes, owner, group, times, links, and name flags (a removed file's from the previous scan). Only when there was a previous scan, from index version 5(change, path)
work_dirsworkflow working folder or package cacheIts path and kind: a Nextflow work/ (beside a .nextflow), Snakemake .snakemake/, Cromwell cromwell-executions/, conda pkgs/ (in a conda installation), or a Singularity or Apptainer cache/. From index version 6path
cold_unitsage threshold and cold folderFor each threshold (90 days to 10 years), the largest folders in which every file is at least that old and whose parent has a newer one: path, depth, files, bytes(bucket, path)
tops, file_partstop-level folderName, path, ID; file count and bytes
users, groupsuid / gidNames from the scan (--resolve-ids); a missing name is a deleted account
errors, name_flagsscan error / top-level folder and flagErrors with their top-level folder; counts of problem names
metakeyScan ID, root, reference time, the age buckets and categories used, totals
files/gNNNNNN/part-*.parquetnon-directory entryTop-level folder, path, name, normalized type, category, kind, size, allocated bytes, owner, group, times, links, name flags; at most 64 groups of top-level folders (file_parts says which group holds each)path within each group

Why the sort orders matter

DuckDB keeps minimum and maximum values for every block of rows (zone maps), and skips blocks that cannot match. The sort orders turn every query Pinax makes into a contiguous read:

File types and categories

A file's type is its lowercased extension, joined with the one before when the last is a compression suffix: S1_R1.fastq.gz is fastq.gz, brain.nii.gz is nii.gz. Its category comes from the inner type, so compressed sequencing data is still sequencing data.

The categories are the catalog's (file_category), so a site can change them (File categories, under Administration, ADMINISTRATION.md): the twelve built in (sequencing and genomics, imaging, tabular and array data, mass spectrometry, archives, models, code, documents, media, containers, logs and temporary, and other, last), filled the first time Pinax starts from categories.DEFAULTS, and any it adds, up to 24. Each lists extensions, and may also list patterns: regular expressions on the file's name, in RE2's syntax as DuckDB has it, so none can take exponential time, and at most 25 in all. Patterns are checked before any extension, category by category and in order, and the first match wins; then the extension (the first category to list it); then other. So ^Undetermined_.*\.fastq can be a category of its own although fastq is sequencing data's.

A file's category is decided when its index is built, not when it is read: deciding at query time would read every file for reports that now read only folders. The build joins each file's extension with a small table, as before, so a site that changes only extensions pays nothing more; with patterns, one expression of all of them together finds the few names any matches, and only those are checked pattern by pattern. Each category adds a file count and a size to every folder (cf{i} and cb{i}), summed from the folder's totals by type rather than over its files. At 10 million files, 25 patterns added 4% to a build and 24 categories 6%, and with 24 the index was 56.9 bytes a file (bench/bench_index.py --patterns 25, --categories 24). The index records the categories it was built with and a fingerprint of what decides a file's category (categories.fingerprint: keys, extensions, patterns, and their order; not labels), and reports read each index's own list: totals come back keyed by category (cat_bytes, cat_files), so totals from indexes built with different lists add up by category, a category an index was built without measures nothing in it, and the removed files of What changed keep the categories of the scan they were in. An index built with other categories than the catalog's is outdated, and pinax rebuild --outdated builds it again, or --latest only each filesystem's latest, letting older snapshots keep theirs.

Seven age buckets run from under 90 days to ten years or more, fixed in categories.py (the interface's color ramp has seven validated steps), and recorded in each snapshot. Ages are whole microseconds from the scan's start, so a file exactly on an edge is in the older bucket, and times after the scan started count as under 90 days.

Building the index

ingest/build.py, in DuckDB, writing to a temporary folder that is renamed into place when complete:

  1. Top-level folders: the depth-1 directories of the scan.
  2. Classify and stage: one pass over the scan's entries computes each file's top-level folder, type, and category, and writes them partitioned by group of top-level folders.
  3. Per group of top-level folders, one at a time: sort the group's files by path into files/gNNNNNN/, then aggregate them by parent directory (totals, age buckets, categories, time sums), by directory and type, and by directory and owner. There are at most 64 groups, however many top-level folders there are, so the write that stages them keeps a bounded number of files open (DuckDB keeps one open and buffered per partition). Working one group at a time bounds memory by the largest group, not the file system, and DuckDB spills to disk beyond PINAX_BUILD_MEMORY_LIMIT.

Steps that read the scan itself use fewer threads than the rest when memory requires: fs-inventory writes row groups of about a million entries, and a thread decodes a whole row group (146 MB of the columns Pinax reads, in a synthetic scan), so ten threads needed more than 8 GB. The build reads the largest row group's size from the Parquet metadata and runs as many threads as fit in three quarters of the memory limit, and halves them and retries any step that still runs out. 4. Subtree totals, bottom-up one level at a time: starting from the deepest level, each directory's totals are its own files plus the sums of its children's totals (minimums and maximums for times). Each level reads only its own rows and the level below, so the whole tree costs one pass, however deep. 5. Write dirs, dir_ext, dir_owner, and the per-folder summaries in their sort orders, plus users, groups, errors, and metadata. 6. Cold folders: for each of the six age thresholds, every directory whose files are all at least that old (no files in younger buckets) while its parent's are not: one self-join of dirs per threshold. 7. Changes: when the filesystem has an earlier ready snapshot whose index is on disk, its dirs table is attached read-only and joined with the new one by path, and both scans' totals are kept in changes. A directory in only one scan is new or removed; a renamed folder is both. The comparison is done once, and survives the earlier index being pruned. Then the files: each group's files are anti-joined by path with those of the previous scan's top-level folders of the same names, both ways, and every new and removed file goes into file_changes (a top-level folder only in the previous scan is all removed files). One group at a time, like the sort, so memory is bounded by a group. A million files with a week of synthetic changes (55,000 files new or removed) adds 0.85 s to a 7 s build, and the table takes about 60 bytes per file in it.

Then ingest records the snapshot and one FolderStat row per top-level folder in the catalog: those rows are the durable history (growth, cold share, mean age per scan) and they survive when old indexes are pruned. The snapshot also records the whole filesystem's totals (info["totals"]), so a filesystem's history reads one row per scan rather than one per folder.

Ingests run one at a time, under a file lock in PINAX_VAR_ROOT, and a scan ID is recorded once. pinax ingest --watch (watch.py) polls a folder for new scans and ingests each complete one once; scans it does not ingest are recorded as skipped or failed, with why, and a heartbeat row tells Scans whether the watcher is alive (docs/DEPLOYMENT.md).

Only scans whose manifest says complete are accepted (--allow-incomplete also accepts incomplete, where stalled directories are missing). Directories the scanner could not read or did not enter (mount points, --max-depth) are counted in incomplete, so the interface can say when totals are lower bounds. A directory reached a second time under --detect-cycles is not: its contents are counted where it was first found.

Checking the totals

pinax check (crosscheck.py) compares an index with fs-inventory rollup, a separate implementation in Rust of the same subtree totals. Rollup runs on a shadow of the scan folder (a copy of the manifest and a link to the entries, so the scan itself is never written to; for a scan with hard-linked files, a copy of the entries in which every link after a file's first has no size, since rollup counts every link and Pinax counts a file once, the rule written again in crosscheck.py rather than shared), with Pinax's age bucket edges (90d,1y,2y,3y,5y,10y) and an age depth as deep as the scan, so every directory gets its own histogram. The two are then joined on dir_id and compared on 31 measures per directory: path, files, folders, bytes, allocated bytes, incomplete folders, oldest and newest modification time, newest access and change time, and files and bytes per age bucket by modification time and bytes per bucket by access time. Rollup's future bucket is part of Pinax's first. Any difference is a bug in one of them until explained.

ScanFoldersIndex buildRollupCompareResult
Demo, four scans36 to 935under 1 s0.1 sunder 0.1 sequal
Synthetic, 1 M files244 K9.2 s0.5 s0.3 sequal
Synthetic, 10 M files244 K23 s1.4 s0.3 sequal

The first run against 0.1.0 found two differences, both fixed in Pinax. Ages were fractional days, and rounding put a file exactly on a bucket edge in the younger bucket for about one scan start time in eleven (one in four at the ten-year edge). Directories revisited under --detect-cycles were counted as incomplete. The tests include a scan built to sit on those edges.

When an index holds changes, pinax check also runs fs-inventory rollup on the previous scan and compares every directory of both scans: its totals in each and whether it is in each, against the two rollups joined by path. A wrong difference cannot then come from Pinax's own totals agreeing with themselves. The previous scan's folder must still exist for this part of the check. At 100 million files (2.44 million folders), comparing takes 0.9 seconds of the build and adds 228 MB to the index, about 2.3 bytes per file; checking it takes 24 seconds, nearly all of it the two rollups, and every directory was equal (between two synthetic scans with the same contents). Between changed scans from synth_scan.py --evolve at one million files, comparing takes 0.2 seconds of a six-second build and checking it 1.1 seconds, every directory equal; changed scans at 100 million files wait for server-class hardware (wave 15).

Real filesystems

What real storage has and a model does not, and how Pinax handles it:

A real scan was checked the same way: the maintainer's documents folder on a laptop (56 K files, 4.7 K folders, 118 GB, 16 levels, 260 file types, 15 flagged names, one owner). Every directory is equal to rollup; the index builds in 0.8 s and every query takes under 25 ms. It also showed common types that were counted as other: camera photo and video formats, macro-enabled spreadsheets, diagrams, executables, and disk images, 35% of its bytes. With those added, other is 0.8% of its bytes, nearly all of it files without an extension. Production storage, with many owners and a billion files, is measured in wave 15.

Querying

index.py opens each snapshot's index.duckdb read-only and gives every request its own cursor. All values from requests are bound as parameters; the only SQL fragments built in code come from fixed lists (the size metrics, the sort orders). Recently used indexes stay open (IndexCache).

Every report takes the scan to show: the latest by default, snapshot (an ID), or at (a day: each filesystem's newest scan taken by the end of it, so a home on several filesystems stays consistent). A day whose scan is no longer kept in full answers 410, except in History, which shows every scan's folder totals; /api/scan-days lists the days a place was scanned and which are kept. The interface keeps at in the address and adds it to every place link and report request, so a chosen scan stays chosen.

A request without a filesystem and path covers the person's home: each of their labs' folders (which may be on several filesystems), or every filesystem root for an administrator. Results from each place are merged; mean ages are rebased to a common reference time.

Time limits

A request reads for at most PINAX_QUERY_TIMEOUT seconds (180 by default). limits.py gives each GET under /api a budget: when it runs out, or as soon as the browser leaves the page (the interface cancels a page's reads when another page opens), the request's running DuckDB queries are interrupted, and it answers 504 saying what to narrow. File-level queries of a whole filesystem (a search at its root, the new and removed files against an older scan, problem names) read every file in it, so at most PINAX_WIDE_QUERIES (2) run at once: the others wait for a turn within their own limit, and a query of a folder never waits. Pinax's limit is below the proxy's (oauth2-proxy waits five minutes in deploy/oauth2-proxy/pinax.cfg), so a long request ends with Pinax's explanation rather than a gateway error.

Searches in the background (jobs.py, Searches) are for what a page cannot wait for: a search of a whole filesystem (for administrators, from Find files) runs in Pinax's own worker threads, at most PINAX_WIDE_QUERIES at once, taking the same turns as those of pages, each within PINAX_JOB_TIMEOUT (an hour), and writes every match, in order, to a Parquet file under VAR_ROOT/jobs, kept for PINAX_JOB_DAYS (7). A job searches the scans the person saw when they asked; only they and administrators see it, and its CSV is written once, when first asked for. A job left queued or running when Pinax stops is marked as stopped when it starts again.

Forecasts

Every history (/api/history) comes with a forecast of its size (forecast.py): where the place is heading over the next twelve months if it keeps growing as it has. It is worked out when asked from the history's own points, so it covers whatever History covers, and nothing is stored.

Labs and departments are forecast from the folders they own now, as History shows them, so a folder moving between labs does not look like growth.

Capacity

How much each filesystem holds, and when it fills at its trend (capacity.py, Capacity):

A filesystem's history carries its capacity, drawn as a line on Size by age where it fits the scale (no more than twice the data). That chart shows the files' size, while the date it fills uses the measure above, so the two can differ by what the size does not count.

A file with several hard links is one file on disk, so totals count its size once (R7): at its first link by path, for its device and inode. Its other links are still files (each is a name someone sees), with no size, in every total: folders, ages, types, owners, folder history, and so charges. Each folder records its extra links and the bytes they would have counted again (hl_files, hl_bytes, from index version 7), shown in the age map's panel. Find files lists every link, with the file's size. Only hard-linked files are compared at build (a window over files with more than one link), so a scan with few costs nothing: 2 ms at a million files without any.

Marked folders

Cleanup plans (wave 7) and tags (wave 8) are about particular folders, which outlive any one scan, so the catalog keeps them as marked folders (marks.py, marked_folder): a filesystem, a path as the index has it, and the directory's device and inode, which every fs-inventory scan records and index version 6 keeps. With each scan of the filesystem, ingest looks for every marked folder:

Only the filesystem's latest scan changes where a mark is; an older scan found late adds to its history. A new mark's history starts with the snapshots kept in full, and from then on it has every scan, so it outlasts the indexes, as folder history does for top-level folders. An index before version 6 has no inodes, so its marked folders are found by path only. At a million files (244,000 folders), finding 1,000 marked folders by path takes 25 ms, and 100 by inode 4 ms (a pass over every folder's inode); the inodes take under 1 MB of the 126 MB index.

Cleanup plans

A lab's cleanup plan (plans.py, cleanup_item) lists folders it means to free space from, and how: delete it, move it to another filesystem (whose price sets the saving), or compress it, with a note. Pinax does none of it, and reads and changes nothing on the storage: a plan records what a lab means to do, the lab's people (or the storage team, with the plan's CSV) do it, and later scans show what happened. A planned folder is a marked folder, so it is followed across scans, and its size when it was added is kept. A lab's PI and delegates add to its plan directly, as do administrators; the folder must be in a top-level folder the lab owns; every change is audited. A folder inside another planned folder of the same lab is listed, but counted once, as part of the outermost.

What a plan saves is the fall in the lab's monthly charge, at today's prices and free tiers: on each filesystem, the lab's whole size there (its folders in the latest scan) charged as charges are, before and after. A folder deleted frees its size; one moved frees it and is charged on the filesystem it goes to; one compressed frees an estimate, from the types in it and what compressing each typically frees (plans.COMPRESSION: about three quarters of uncompressed FASTQ or SAM, half of BAM as CRAM, more of VCF and pileups). A lab within its free tier saves nothing by freeing storage there, which is why the saving is not size times price. Each folder's saving on its own is shown too; with free tiers, those need not add up to the plan's.

Progress comes from the scans after a folder was added: one gone (and not moved) is done; one compressed is done once it has shrunk by nine tenths of its estimate (recorded when it was added); one smaller than when added is partly done; one at another path with its inode freed nothing. What is done is shown with the scan that showed it, and what it saves a month now: what the freed space would cost the lab if it were back, less what a moved folder costs where it went. What a plan would still save counts only what is not done. A plan downloads as CSV, a row per folder, for the lab or the storage team.

Suggestions for a lab's plan come from the latest scan of each of its folders: workflow working folders and package caches (work_dirs, found at build: what running the workflow makes again), the largest cold folders at the cold threshold (cold_units), and the folders with the most uncompressed sequencing data (dir_ext, estimated as for compression). Each comes with what it would free and save a month on its own; a folder planned or inside one is left out, a folder suggested twice is suggested for the larger saving, and one inside another suggested folder is left to it. On a million-file synthetic scan, the three queries take 8, 38, and 9 ms for a top-level folder.

Administrators see every lab's plan (/api/plans/all, Cleanup plans without a lab chosen): what all of them would free and save, and what is done; per filesystem, what is to be freed, moved in, and freed so far; the largest folders still to do; each lab's plan; and one CSV of every folder, for the storage team.

Tags

Folders are described with tags (tags.py, tag and folder_tag). Administrators keep the standard tags on Tags: each has a type (a flag, text, a date, or a choice from the site's own list), says who may apply it (a lab's PI and delegates, or administrators only), whether a folder may have more than one value, and whether it protects a folder from cleanup plans (a flag, or a date until it). A default list is added the first time the catalog is set up, and never again, so a site's changes stay: Project, Grant or award, Data stage, Source, Data classification (administrators only), IRB protocol, Shared in a repository, Keep until, and Legal hold. A tag in use is retired rather than deleted (folders keep it; it can no longer be applied), its type cannot change, and a choice in use cannot be taken away. Every change is audited.

A tag is put on a folder (a marked folder, so it follows the folder across scans) and applies to everything below it: a folder's tags are its own and those of the folders above it, which it cannot drop. A lab's PI and delegates tag its folders with the standard tags applied by owners and with the lab's own tags (a flag or text, made by them, seen by the lab's members and administrators); administrators tag any folder with any tag, and can fold a lab's tag into a standard one from Tags (each folder gets the standard tag, with a value given or the lab tag's own, and the lab's tag is retired; in one transaction, so a value the standard tag cannot take changes nothing). A tag with one value replaces the folder's value. The age map's panel shows a folder's tags and adds them; tiles that are or hold tagged folders carry a dot, with their tags in the tooltip and the table view. pinax tags import FILE tags folders in bulk from a CSV (filesystem, path, tag, value; a lab's own tag as lab:key), as a dry run unless --apply, and changes nothing if any row is refused.

Collections find data by its tags (tags.collection, Collections): the folders that have every tag asked for (each with a value, or any), on their own or from a folder above, that the person may see. The outermost of them are the collection, each with its latest totals (recorded with each scan for marked folders), owner, tags, and monthly cost (its share of its lab's charge on its filesystem, by size). The collection's history is those totals on each day with a scan of one of its folders, from when they were marked, and its forecast is that history's (forecast.py). Only the catalog is read, each table once: with 2,000 tagged folders of 200 labs and half a year of weekly totals (bench/bench_tags.py), a collection of 34 folders takes 60–70 ms, of 100 folders 85–95 ms, and of all 2,000 about 0.6 s.

Charges by tag (charges.split_by_tag, /api/charges/split) split a lab's month by a tag's values, such as by grant: on each filesystem, each value gets the share of the lab's charge there that its folders' time-weighted average size is of the lab's (each scan's totals holding until the next, as charges are worked out), and the rest is untagged. A folder's bytes belong to its nearest tagged folder (itself, or the nearest above it), and a folder with several values splits evenly between them. Storage charges shows the split for each lab, by the grant if its folders have one, with a CSV.

Protection. A protecting tag (Legal hold; Keep until, before its date) keeps its folder, and everything below it, out of cleanup plans (tags.protection): adding such a folder is refused, and so is adding a folder that holds one, since cleaning it up would take the protected folder too. A folder planned before it was protected is flagged on the plan; suggestions leave protected folders out.

Saved views

A person saves the page they are on (views.py, saved_view): its address in the app (a report, its place, and its settings, such as /explore?fs=fast&path=...&size=files), under a name, kept to themselves or shared with one of their labs, whose members see it among their views on My data (All data for administrators). Only pages of Pinax are kept, and a view is only an address, so whoever opens it sees only what they may. Saving, changing, and deleting are audited; only whoever saved a view changes it.

Costs

What storage costs is kept in the catalog as two schedules per filesystem (costs.py):

Earlier prices and free tiers are kept, so past months keep what they had; a change to a day already past changes the charges since then, and Costs says so before removing one. Every change is audited with what it replaced. Charges are for the files' size (logical bytes, not space on disk).

Monthly charges (charges.py) are worked out from folder history, which keeps every scan's size for each top-level folder. A month (a calendar month in UTC) is charged on its time-weighted average, like a utility bill: each scan's sizes hold from that scan until the next. The month is cut wherever something changes (a scan, a folder's owner, a price, a free tier), and in each stretch a lab's charge is

max(0, size of the folders it owned then - its free tier then) x the price then x (stretch / month)

Everything is worked out exactly, as fractions, and rounded half up to the currency's minor unit (cents, or whole units for currencies such as JPY) once per lab and filesystem, so a lab's total is the sum of its lines. Before a filesystem's first scan there is nothing to charge; storage on a filesystem with no price yet is shown, not charged. Folders no lab owns, and the files directly in the root, are unbilled. The month in progress is an estimate: the latest scan holds until the month's end.

So that a past month is charged to the owners it had, the catalog keeps ownership history (folder_owner, ownership.py): a row each time a top-level folder changes owner, in the app or by pinax import. The first change of a folder also records who had it until then, from the beginning; a folder that has never changed is its current owner's throughout. /api/admin/costs/charges?month=YYYY-MM returns every lab's and department's charges for a month, by filesystem and folder, with the prices that applied, what is unbilled, and totals by filesystem; with fmt=csv, the month's statement for finance, a row for each lab or department on each filesystem and one for each filesystem's unbilled storage, marked final or estimate. Chargeback shows it.

Each line is also split into periods, runs of the month with one price and one free tier, so the charge can be shown worked out: a period's charge is its average billable size times its price times its share of the month. Storage charges (/api/charges) shows a person's own labs' lines this way, with each lab's last twelve months; its members see it whatever their role, and administrators may ask for any lab. A lab is shown the folders it was charged for, including ones it owned earlier in the month and has since given up, which it can no longer open.

Charges ahead (charges.charges_ahead) are each lab's and department's charges for the twelve calendar months after this one, per filesystem: the size of the folders it owns now, at their trend (as History forecasts it), less the free tier scheduled, at the price scheduled, for each stretch of each month in which neither changes. The trend, and the low and high ends of its range, are straight lines, so each stretch is worked out exactly (the part of the line above the free tier), with the low and high ends giving the range. A lab with no trend on a filesystem (too few scans, or soon after a step) is counted there at its size in the latest scan, and says why. These are estimates, in floating point, rounded to the currency's unit; they are not bills. Storage charges shows a lab's next twelve months, and Chargeback every lab's added up (/api/admin/costs/ahead, asked for after the month, so the month shows at once; adding up the ranges overstates the range); storage no one owns is not counted. With 2,000 folders and 200 labs, one lab's twelve months take about 15 ms, and every lab's about 100 ms.

Security

Measured performance

On an Apple M4 laptop (10 cores, 32 GB), with synthetic scans from bench/synth_scan.py that model a research file system (lab folders, projects of different ages, a realistic mix of file types and sizes), and the default 8 GB build memory:

ScanIndex buildIndex sizeTreemap (root, 2 levels)Treemap (lab folder)Types (lab)Cold folders (lab)Name search (lab)Name search (whole file system)
1 M files, 24 K folders3.4 s0.06 GB26 ms23 ms1 ms11 ms9 ms30 ms
10 M files, 244 K folders22 s0.54 GB64 ms42 ms1 ms20 ms10 ms273 ms
12.2 M files, 445 K folders, with wide and deep folders31 s0.59 GB49 ms35 ms1 ms14 ms9 ms304 ms
100 M files, 2.44 M folders, 2,000 top-level folders121 s5.56 GB49 ms30 ms1 ms13 ms22 ms2.8 s

The first two rows were measured with 0.1.0; treemaps of wide folders are faster since. The third scan adds a folder of two million files, a folder of 200,000 subfolders, and a chain 1,000 folders deep (--wide 2000000 --deep 1000): the treemap of the folder with 200,000 subfolders takes 45 ms, the deepest folder 6 ms, and the largest files in the two-million-file folder 33 ms; 10 of the 31 seconds of the build are the 1,000 levels of subtree totals. At 100 million files every directory-level query takes 50 ms or less (whole-filesystem cold folders 21 ms), and every directory is equal to fs-inventory rollup (rollup 11 s, compare 1 s).

The 100-million-file build peaks at 7.7 GB within the 8 GB limit, reading the scan with 6 of 10 threads. With 17 GB and all ten threads it took 133 s instead of 121 s and peaked at 10.5 GB: staging the scan's files does not speed up with more threads, so more memory buys nothing here.

Build time is about 1.2 seconds per million files, so a billion-file scan would take about 20 minutes on this laptop, and less on a server with more cores and faster disks; that is small next to the crawl itself. Directory-level queries depend on the number of directories in the range they read, not on file counts, so they stay in the tens of milliseconds. Searches across a whole file system scan its files' name column, so they grow linearly: 2.8 seconds at 100 million files, about 30 seconds at a billion, and about a minute at two billion, with about as long again for the count of matches (which Find files asks for separately). Scoped to a lab folder they stay fast. The new and removed files of What changed against the previous scan grow with what changed, not with the filesystem; against an older scan, a whole filesystem's comparison grows with its files (0.4 s at a million, so minutes at two billion, beyond the time limit), and is best asked of a folder. These are projections from synthetic data, which has about 41 files per folder; production filesystems often have fewer, so two billion files may mean 50 to 200 million folders, beyond anything measured so far. Reports that read every folder of a whole filesystem, like the folder lists of What changed (about 0.1 s per 250,000 folders here) and the icicle and sunburst of a filesystem's root (about 2 ms per million folders), grow with them. The pilot (wave 15) measures production storage.

Index size is about 56 bytes per file, mostly the per-file Parquet (which is kept sorted and compressed). A billion-file snapshot needs about 56 GB; keeping six snapshots per file system (the default) needs about 330 GB. file_changes adds about 60 bytes per file new or removed since the previous scan: a week in which 2% of two billion files are new or removed adds about 2.4 GB. Folder history in the catalog is tiny.

Reproduce with:

uv run python bench/synth_scan.py --files 10000000 -o /scratch/synth-10m
uv run python bench/bench_index.py /scratch/synth-10m --index /scratch/synth-10m-index

Many people at once

Measured with the load test (The load test) on the same laptop, with Pinax and the load test sharing it, against three scans of 10 million files a month apart, 200 labs, and 615 people. Each person pauses 5 to 15 seconds between pages, so 100 people open about 9.5 pages a second; five minutes measured after a minute's ramp-up:

People at onceCatalogPages a secondMedian page95th percentile99th percentileErrorsMemory at most
10SQLite0.9741 ms98 ms154 ms01.2 GB
25SQLite2.3942 ms93 ms160 ms01.3 GB
50SQLite4.7340 ms96 ms158 ms01.4 GB
100SQLite9.4838 ms106 ms168 ms02.5 GB
10PostgreSQL0.9666 ms140 ms382 ms01.1 GB
25PostgreSQL2.3864 ms174 ms385 ms01.4 GB
50PostgreSQL4.7260 ms162 ms387 ms01.5 GB
100PostgreSQL9.4755 ms146 ms377 ms02.3 GB

Times do not grow from 10 to 100 people, and the server keeps about one core busy. Folder pages stay within 143 ms at the 95th percentile (172 ms on PostgreSQL) and a lab's searches within 65 ms (85 ms), far inside wave 14's budgets of 1 and 2 seconds. A search of every filesystem takes about 0.4 s, and All data 157 ms (385 ms on PostgreSQL).

More than that. The same 100 people clicking two to five times as often, three minutes measured after half a minute's ramp-up:

ClickingPinaxCatalogPages a secondMedian page95th percentile99th percentileErrorsCores busy
Twice as often0.13.0SQLite19.037 ms132 ms278 ms00.9
3 times0.13.0SQLite28.443 ms282 ms942 ms31.3
4 times0.13.0SQLite15.31.4 s3.3 s88 s892.9
5 times0.13.0SQLite0.889 s145 s149 s1560
3 times0.14.0SQLite28.045 ms400 ms1.0 s01.4
4 times0.14.0SQLite26.1857 ms4.1 s7.2 s03.3
5 times0.14.0SQLite24.01.5 s6.6 s9.5 s03.4
4 times0.14.0PostgreSQL30.0344 ms2.6 s4.5 s02.4

The 3 errors of 0.13.0 at three times were the load test's: a request sent on a kept-alive connection just as the server closed it, unused for 5 seconds, which a browser sends again (the load test now does too). 0.13.0, at four and five times, stopped answering for 30 seconds at a time and failed requests with Internal error, its processors idle. Every thread's stack, dumped at the stall, was waiting for a catalog connection: a request took one to check who was signed in and kept it while it waited for one of the web server's 40 threads to run the page, and with 15 connections on SQLite (20 on PostgreSQL), once 40 requests were waiting for a connection, those holding them waited for a thread, until the pool gave up after 30 seconds. A request now holds a connection only while it runs in a thread (Connections), and nothing fails: one process serves about 28 pages a second on this laptop, some 300 people at the baseline's pace, and past that pages wait their turn and slow down. Those that ask the catalog many small questions wait longest (below: All data took 10 s at four times, My folders 5 s), with three or four of the ten cores busy, most likely because that work is Python's, one thread at a time. At three times the 95th percentile is higher than 0.13.0's (400 against 282 ms), with up to 40 requests running at once where the pool let 15. At the baseline's 100 people nothing changed on SQLite: run back to back with 0.13.0, the median page took 38 ms in both, and the 95th percentile 104 and 108 ms (it varies by a third between runs).

Searches of whole filesystems while others browse. Eight storage administrators each searched the whole filesystem one search after another (by name, by path, and by age, each with a count of all that match, a second pass), with a pause of 1 to 3 seconds, while the 100 people browsed at the baseline's pace (--searchers 8). Two run at once (PINAX_WIDE_QUERIES) and the others wait for a turn, so the cores stay busy (8.5 of 10). On SQLite every budget was met: the others' pages took a median 98 ms and 410 ms at the 95th percentile (folder pages at most 751 ms, What changed; a lab's searches 199 ms), and the 299 searches finished in a median 2.7 s, the longest 7.6 s, waiting included. With a time limit of 5 seconds instead of 180 (--set PINAX_QUERY_TIMEOUT=5), 33 searches of 280 did not finish, and each stopped at the limit, within a quarter of a second, with Pinax's explanation: 16 still waiting for a turn (503, "already running as many searches of whole filesystems as it allows"), 17 running (504, "stopped this after 5 seconds"). On PostgreSQL, with the database in a virtual machine on the same cores, nothing failed and the 212 searches finished, the longest in 17 s, but What changed reached 1.2 s at the 95th percentile, past the budget of 1 s, and the others' pages took a median 173 ms; the searches' DuckDB threads (every core, PINAX_QUERY_THREADS) leave the rest little.

Many sign-ins at once. 200 people signing in at the same moment (--people 200 --ramp 0): no errors, and every sign-in done within 5.7 s on SQLite and 5.9 s on PostgreSQL, with up to 40 passwords checked at once (scrypt uses 32 MB for each, so about 1.3 GB more memory while they run). On PostgreSQL, sign-ins first took up to 8.4 s, each holding one of the 20 connections while its password was checked; it is now given back first. Their first pages then waited, up to 59 s on SQLite and 19 s on PostgreSQL. The server finished about 25 requests a second with 3 of its 10 cores busy, and requests that take a few milliseconds alone, such as /api/config, waited up to half a minute for one of the 40 threads. With cores to spare, what they were most likely short of is Python's interpreter, which runs one thread's Python at a time, and which they share with the event loop that receives the requests. People arriving over a minute, as in the baseline, do not wait.

PostgreSQL is slower by its round trips, on pages that ask the catalog many small questions. In 0.13.0 an administrator's All data made 1,023 catalog queries (306 ms on PostgreSQL, 111 ms on SQLite), People and access 620 (187 and 66 ms), a lab's suggested folders 175 (91 and 46 ms), and a lab's charges 51 (56 and 10 ms); the age map, change map, and cold folders of a filesystem's root 131, 133, and 283. Most were each lab's PI, found by loading the lab's members and then each member, lab by lab, and each person's site roles, person by person. Since wave 14 every lab's PIs come in one query (models.pi_names), people come with their roles, and a lab's suggested folders look up each filesystem's price and free tier once: All data makes 24 queries, People and access 13, the root's pages 12 to 14, and the suggested folders 58. One request at a time, All data's catalog request took 69 to 129 ms on PostgreSQL instead of 400 to 576 ms, and People and access 59 to 103 instead of 252 to 447 (on SQLite, 30 to 49 instead of 125 to 161, and 31 to 45 instead of 75 to 170; measured while the laptop was in use, hence the ranges). A lab's charges still read prices once for each month of their history, 51 queries. Giving a request's connection back after the sign-in check (above) adds a few round trips, as the request takes one again for its page: about 4 ms a request here, where each round trip to the database, in its virtual machine, takes about 1.5 ms. At 100 people PostgreSQL's median page took 62 ms, against 55 ms in 0.13.0.

Memory grows as DuckDB caches the indexes' blocks: 2.5 GB after five minutes of 100 people, and over 20 minutes it rose and fell between 1.4 and 3.0 GB. Each open index is a DuckDB database with a memory limit of its own (what its queries use at once, and the blocks it keeps), and up to eight stay open: 0.13.0 gave each PINAX_QUERY_MEMORY_LIMIT (4 GB), so up to 32 GB in all, past the 16 GB of Sizing at a billion files. Since wave 14 the setting is for all of them together (8 GB), each with an equal share, set again as indexes open and close (snapshots.IndexCache), and DuckDB lets go of cached blocks when a share falls. At rest an index keeps little: 43 MB, after all of a 10-million-file index was read once; at a billion files its folders alone are gigabytes.

Threads. Measured while the laptop was in use, so each run is compared only with its neighbours. Fewer of the web app's threads (PINAX_WEB_THREADS) served more pages a second when the process was saturated: at four times the baseline's pace, 8 threads served 24.7 pages a second against 18.5 with 40 in the run before, and 18.3 against 13.4 with 16, with a 95th percentile of 2.5 s against 8.7 s; and 200 people signing in at once had their first pages within 31 s, against 40 s with 16 and 57 s with 40. Python runs one thread's code at a time, and fewer threads share it, and the event loop, among fewer. But each request waiting for a whole-filesystem turn holds a thread: with eight administrators searching, 8 threads left the others' pages a 95th percentile of 1.2 s and a lab's searches 1.7 s, against 0.5 and 0.3 s with 40. At a billion files the root's reports and the searches take seconds and hold threads longer, so the default stays 40. Fewer DuckDB threads did not help the pages beside the searches: with PINAX_QUERY_THREADS=5 of 10, on PostgreSQL with eight searching, the others' pages took 642 ms at the 95th percentile against 733 ms and 2.0 s in the runs either side with all ten, and the searches a median 5.7 s against 4.2 and 5.0 s. A search and the pages of the same index share its threads.

Charges

Monthly charges come from the catalog, not the indexes, so they depend on the number of top-level folders and scans. On the same laptop, with a synthetic year of weekly scans (bench/bench_charges.py: a tenth of the folders unowned, one in a hundred changing owner, a price change, and free tiers with exceptions):

Folders, labsEvery lab, a past monthEvery lab, this monthOne lab, a monthOne lab, twelve months
2,000, 20025 ms24 ms4 ms49 ms
20,000, 2,000488 ms521 ms42 ms566 ms

Chargeback and its statement are the first column; a lab's Storage charges is the last, and My data the one before. Time grows with folders times the scans in a month; one lab reads only the folders it ever had, but still every folder's owner.

History with its forecast, on 2,000 folders and a year of weekly scans: 4.7 ms for a lab and 1.6 ms for all data (the whole filesystem's totals recorded with each scan). The forecast itself works on at most the six months of points the history already has, a few hundred pairs of scans.

uv run python bench/bench_charges.py --folders 2000 --weeks 52

Proof of concept and production

Proof of conceptProductionNotes
pinax seed writes demo trees of sparse files and scans them with fs-inventoryScheduled fs-inventory scans on storage nodes or scan hostsPinax ingests any complete Parquet scan
Demo owners rewritten to fictional accounts, and demo scans dated a month apartReal owners and times from the scanOnly seed.py rewrites scans, only its own demo scans
SQLite catalogSQLite on one server, or PostgreSQLMigrations upgrade either in place (The catalog database)
Demo identity switcherPasswords Pinax keeps (local); sign-in with Entra ID in Pinax itself (oidc); or single sign-on through a proxy (header)oidc checked against Dex and a stand-in provider; header behind oauth2-proxy 7.15 with a stand-in identity provider
People, labs, and folder mappings managed in the appThe same, fed from the authoritative source; until then imported from CSV (pinax import)Same model as Tundra
One serverWeb and ingest can run on separate hosts sharing var/snapshotsIndexes are replaced, never changed in place; keep every ingest on one host, since the ingest lock is a file lock in PINAX_VAR_ROOT

Known limits