motoko icon indicating copy to clipboard operation
motoko copied to clipboard

experiment: precise heap tags

Open crusso opened this issue 1 year ago • 5 comments

Implement precise tagging of heap allocated objects.

Splits

  • TAG_ARRAY into consecutive TAG_ARRAY_I, TAG_ARRAY_M, TAG_ARRAY_T, TAG_ARRAY_S (immutable array, array, tuple, shared function).
  • TAG_BLOB into consecutive TAG_BLOB_B , TAB_BLOB_T and TAG_BLOB_P, TAG_BLOB_A (blob, text, principal, actor reference).
  • TAG_BITS_32 into consecutive TAG_BITS32_U, TAG_BITS32_S and TAG_BITS32_F ((boxed) Nat32/Int32, Float32 (reserved for future use).
  • TAG_BITS_64 into consecutive TAG_BITS64_U, TAG_BITS64_S and TAG_BITS64_F ((boxed) Nat64/Int32, Float64).

Modifies array slicing logic to preserve the base tag of the underlying array, by stealing the top 2 bits of the slice start field, relying on the fact that array indices are < 2^30. For clarity, the tag in decompressed on each iteration. For efficiency, it could actually be maintained during slicing compressed form as a sort ( see 448962f).

TODO: ~[ ] print refined tags in debug output?~ (rts debug printing is rarely used and can be adapted later)

crusso avatar May 17 '24 15:05 crusso

Comparing from c89946270d551dd85aaa429dfc0019265b74c2ae to 0082f1db83c73ade9a4eb81f75b9e054fd4ad1ce: In terms of gas, 4 tests regressed, 1 tests improved and the mean change is -0.7%. In terms of size, 5 tests regressed and the mean change is +0.3%.

github-actions[bot] avatar May 31 '24 09:05 github-actions[bot]

I think I've addressed all the issue. PTAL @luc-blaeser

crusso avatar Jun 05 '24 16:06 crusso

@ggreif, since Luc has already merged this branch into his EOP PRs, and a squash merge of this PR to master may cause him trouble merging later, we've decide not to merge this branch directly into master but as part of larger PR. That's also why I'm not addressing the issues you found (which are mostly cosmetic).

crusso avatar Jun 21 '24 13:06 crusso

Not merging into master as already merged into Luc's EOP PRs.

crusso avatar Jun 21 '24 13:06 crusso

I now merged the PR into the EOP PR stack. I think we could probably now close this PR. @crusso: Thank you again for this great contribution!

luc-blaeser avatar Jun 24 '24 13:06 luc-blaeser

Merged with EOP

luc-blaeser avatar Dec 03 '24 09:12 luc-blaeser