upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/docs/world_census.md
diff options
context:
space:
mode:
authorDiesel <dev.diesel@proton.me>2026-11-21 22:44:07 +0100
committerDiesel <dev.diesel@proton.me>2026-11-21 22:44:07 +0100
commit5c1a1fbb6bf6f609eb4e61baa4961ce382743a4e (patch)
treeac8ad90058b97ab241fdc65edae3d4628d20ee1e /docs/world_census.md
parentc45309e29f21c1d5b75678db0e2dc2dd11cff25b (diff)
parent4e390e0871d7265e629b51aca8ff99a15a6a6845 (diff)
Merge main to include the compute Y/Z harness test fix
Diffstat (limited to 'docs/world_census.md')
-rw-r--r--docs/world_census.md97
1 files changed, 97 insertions, 0 deletions
diff --git a/docs/world_census.md b/docs/world_census.md
new file mode 100644
index 000000000..128151954
--- /dev/null
+++ b/docs/world_census.md
@@ -0,0 +1,97 @@
1# Census of `levels.rpf`
2
3`levels.rpf` is 76,155,065,056 bytes. Its table of contents is encrypted, so the archive cannot be
4enumerated by name. `tools/world_census.py` measures the data area directly: it inflates every zlib
5stream, validates each `0DRP` / version `0x7a` resource, joins continuation streams, and counts the
6map resources and placement entities they contain.
7
8## Result
9
10| Measure | Value |
11|---|---:|
12| Data area scanned | 76,154,954,352 bytes (start `0x1B070`) |
13| Map resources (`kind=map`) | **23,535** |
14| Placement entities | **1,670,442** |
15| Complete / validated map rows | **23,535 / 23,535** |
16| Exact entity counts | **1,670,442 / 1,670,442** |
17| Shards complete | **36 / 36** |
18| Zlib streams inflated | **1,122,614** |
19| Stored stream bytes | 75,165,813,806 |
20| Inflated bytes (all streams) | 175,587,890,693 |
21| Rejected zlib candidates | 906 |
22| Adopted continuation streams | 174 |
23| Metadata streams | 165,880 |
24| Duplicate content groups | 0 |
25| Scan time | 290.8 s |
26
27A map row is a resource whose schema includes `CMapData`. `maps_exact` means every entity block
28counted against the declared `entity_size` and no entity block was left in a graphics page.
29`entities_exact` is the same check summed over all rows. Six entities of the 23,535 maps were split
30across a continuation; the joiner adopted 174 streams in total.
31
32## Coverage
33
34| Byte class | Bytes | Share of data area |
35|---|---:|---:|
36| Accepted stream payload | 74,877,281,159 | 98.32% |
37| Raw graphics pages (`0x6`) | 2,762,232 | 0.004% |
38| Raw system continuation | 44,304 | 0.0001% |
39| Zero padding | 1,058,806,784 | 1.39% |
40| Unread non-zero bytes | 216,059,873 | 0.28% |
41| **Accounted** | **76,154,954,352** | **100%** |
42
43The unread bytes are mostly small alignment and metadata gaps between streams. The gap audit found
44**23** `0DRP` signatures in unread ranges, but none resolved to a map or metadata resource
45(`raw_maps = 0`, `raw_meta = 0`), so the census is not missing a map class. No unaligned zlib stream
46that inflates to a `0DRP` header was found in a gap (`missed_zlib_meta = 0`). The 906 rejected
47candidates are zlib streams that do not form a complete `0x7a` resource; they are ordinary archive
48payload, not counted maps.
49
50## Exactness condition
51
52`summary.json` sets `census_exact` only when all of these hold:
53
54- `complete` is true and every expected shard was written;
55- `maps_exact == maps` and `entities_exact == entities`;
56- `entity_gfx == 0` and `entity_unresolved == 0`;
57- `raw_maps == 0` and `missed_zlib_meta == 0`.
58
59The run above satisfies every condition. `accounted_ratio` is 1.0 because every byte is assigned to
60accepted payload, a raw page, zero padding or counted unread data.
61
62## Method
63
64The scan starts at the data-area offset from the `9FPR` header. It walks 16-byte-aligned zlib
65candidates in independent shards and:
66
671. inflates each stream, keeping the first bytes needed to recognize `0DRPz`;
682. validates the little-endian `0x7a` header, struct table, block table and member offsets;
693. follows a contiguous split resource, either another zlib page or a raw system page whose length
70 the resource's pointers require;
714. counts `CEntityDef` blocks against the declared entity size, and records `0x6` graphics extents;
725. merges shard rows, checks duplicate names and content hashes, and audits every gap for a missed
73 `0DRP` signature or unaligned zlib stream.
74
75Each shard is written to `shard_<index>_<start>_<end>.json`; `summary.json` and `maps.json` are
76rebuilt from the shards, so an interrupted run resumes with `--resume` or `--merge-only`.
77
78```powershell
79python -I tools\world_census.py <levels.rpf> --out work\world\census --shard-size 2147483648 --jobs 12
80python -I tools\world_census.py <levels.rpf> --out work\world\census --merge-only
81python -I tests\test_world_census.py
82```
83
84The default shard size is 2 GiB, the default job count is half the logical CPUs, and the scan is
85bounded by `--start` / `--limit` when a partial pass is wanted.
86
87## Limits
88
89- The census counts resources, not names. It does not decrypt the RPF9 TOC, so it cannot say which
90 archive entry owns a map; `docs/world.md` correlates the measured bands with the placement files
91 it could carve.
92- Only `0x7a` resources are validated. Other resource types contribute to stream and byte counts but
93 are not classified.
94- A map row proves the resource has a `CMapData` root and a self-consistent entity table. It does not
95 prove the map is reachable, loaded, or complete in the runtime.
96- Output contains resource offsets, sizes, counts and content hashes only. It is aggregate metadata;
97 keep it out of git along with the archive and carved streams.