mirror of
https://github.com/storytold/designcraft.git
synced 2026-10-31 05:36:46 -06:00
Keeping a 1 x 1 table for every further `<Table>` was unbounded in the one direction the budget exists to close. `<Table></Table>` is fifteen bytes, so the 512 MiB a part may decompress to holds some 36 million of them, and a `Cell` is 1,360 bytes: tens of gigabytes, with every table inside both caps. The test I wrote said as much without my noticing -- its invariant was `reserved <= MAX + tables`, and `tables` had no bound. `budgeted_size` now returns `None` once the budget is spent and the table is not read at all, so the cells one import reserves are at most the budget, exactly. The invariant is now `reserved <= MAX_IMPORT_TABLE_CELLS`, with no term that grows with the file. The warnings needed the same treatment, for the same reason: a file of 400,000 tables each claiming one row and two columns got a line about every one of them. At most 20 are named, then one line saying the rest were the same, and the file is told once that its tables ran out of cells between them.