Skip to content

perf(rust): 16-byte property entries, with room for exactly what an object is made with - #87

Merged
kommander merged 1 commit into
devfrom
perf/stack-04-props
Nov 26, 2026
Merged

kommander merged 1 commit into
devfrom
perf/stack-04-props

Conversation

@hearnadam

Copy link
Copy Markdown
Contributor

A property held its value as a 16-byte Value in a 24-byte entry, and a property
list started with room for four. Prop holds its value as a Slot, as the stack
does (16 bytes), behind value() and set_value(); most of this diff is those two
at its call sites. An object literal reserves exactly the properties it names
(Op::NewObject(n)), a spread its source's count, any other list starts at two
entries, and JSON.parse at four.

Waiting run, bytes per 4-property object: 203 to 171; per 2-field class
instance: 198 to 136.
Cost: class construction about 6% more instructions, one more reallocation an
instance.


Part 4 of 11 in a stack; based on perf/stack-03-heap-chunks. Each part was built, linted and tested on its own (cargo test --release --workspace, the same under PSYCHOSCRIPT_GC_STRESS=1, and the conformance cases under PSYCHOSCRIPT_ROUNDTRIP=1). Numbers are instructions retired, from rust/bench/examples/corpus and mem_probe (part 1).

@hearnadam
hearnadam added this pull request to stack #95 November 26, 2026 17:17
Base automatically changed from perf/stack-03-heap-chunks to dev November 26, 2026 22:49
…bject is made with

A property held its value as a 16-byte Value in a 24-byte entry, and a property
list started with room for four. Prop holds its value as a Slot, as the stack
does (16 bytes), behind value() and set_value(); most of this diff is those two
at its call sites. An object literal reserves exactly the properties it names
(Op::NewObject(n)), a spread its source's count, any other list starts at two
entries, and JSON.parse at four.

Waiting run, bytes per 4-property object: 203 to 171; per 2-field class
instance: 198 to 136.
Cost: class construction about 6% more instructions, one more reallocation an
instance.
@kommander
kommander merged commit edc9be2 into dev Nov 26, 2026
1 check passed
@kommander
kommander deleted the perf/stack-04-props branch November 26, 2026 22:50
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.

2 participants