Skip to content

s1/emit: allocate each enum case at its own size (vic-e0ni) - #20

Merged
vic merged 1 commit into
mainfrom
s1-case-size
Nov 9, 2026
Merged

vic merged 1 commit into
mainfrom
s1-case-size

Conversation

@vic

@vic vic commented Nov 9, 2026

Copy link
Copy Markdown
Owner

Bead vic-e0ni: a constructor now allocates only its own case's size, not the largest case of the enum.

The emitted C includes stddef.h. A constructor allocates offsetof(struct E_T, u) + sizeof(((struct E_T*)0)->u.C_Case): the tag and the union up to that case's member, then the member. A constructor call always has fields (a nullary case takes no ()), so the member exists.

Peak memory, C -O1:

workload before after
Datalog reach chain 100k 643 MB 451 MB (IMap version: 484 MB)
tests/s2/bmap 333 MB 219 MB

bootstrap/seed.c is regenerated. Local tests/run.sh: 185 ok, 0 FAIL (the fixpoint and seed checks included).

… case

The emitted header includes stddef.h, and a constructor call allocates offsetof(struct E_T, u) +
sizeof(((struct E_T*)0)->u.C_Case): the tag and the union up to the case's member, then the member. A
call always has fields (a nullary case takes no ()), so the member exists. Before, every case took
sizeof(struct E_T), the size of the largest case: a 2-3-4 tree B2 node took the size of a B4.

Peak memory, C -O1: Datalog reach chain 100k 643 MB -> 451 MB (below the IMap version, 484 MB);
tests/s2/bmap 333 MB -> 219 MB. bootstrap/seed.c regenerated. tests/run.sh: 185 ok, 0 FAIL.
@vic
vic merged commit c4c5843 into main Nov 9, 2026
3 checks passed
@vic
vic deleted the s1-case-size branch November 9, 2026 05:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant