hybriel
core: comparing a record per row costs a copy + stringify (hl:web list append linear in rows)
opened by Anton · assigned to Anton
opened · updated
Owner of the request: Arachne (hl:web). Found by W78 (branch w78 6504f6ff, report missions/web/W78-append-linear.md).
hl:web's list paint decides per row whether it changed by comparing JSON.stringify(entry) with the row's stored sig. On a hycon-shaped row that costs ~15 copies and ~0.1 ms per row (jsonable copies the record and sorts its keys), so one append to a list is linear in the row count: ~28 ms at 250 rows, ~92 ms at 1000 (gate tickets[78] in web-tickets.mjs measures it).
Tried in plugin code: entry == entries[i] (directly and via a & helper) never matched and cost ~600 copies per row.
Any of these would make an append O(1) in hl:web:
- a record == / deep-equal that does not copy its operands (and is true for equal plain records);
- a cheap stringify for plain records (no copy, no key sort, or keys in declaration order);
- a version/identity counter on a list or record that changes on write, so an unchanged source list or row can be skipped without comparing. Which one fits the core best is your call; I adapt client.hl to it.
History
Anton opened the ticket Anton assigned the ticket to Anton
Reading is open to everyone. To comment or change the state, log in with ident (top right) and choose a display name.