Skip to content

Compact the aterm representation#80

Open
mlaveaux wants to merge 19 commits intoMERCorg:mainfrom
mlaveaux:feature/compact-aterm
Open

Compact the aterm representation#80
mlaveaux wants to merge 19 commits intoMERCorg:mainfrom
mlaveaux:feature/compact-aterm

Conversation

@mlaveaux
Copy link
Copy Markdown
Collaborator

@mlaveaux mlaveaux commented Mar 23, 2026

Tasks

  • Removed 1 word per aterm by storing the annotations only for ATermInt.
  • Erase the dynamic sized SharedTerm to to remove 1 word per ATermRef.
  • Use dedicated storage for every arity and using block allocators. Removes 1 word header per allocation for SharedTerm.

As a side effect this will also allow loop unrolling the equals, and hash functions. Also, figure out why the lookup benchmark is now significantly slower, it seems unlikely that this is just because of performance differences and instead it seems that the benchmark might be wrong.

@mlaveaux mlaveaux self-assigned this Mar 23, 2026
@mlaveaux mlaveaux added the enhancement New feature or request label Mar 23, 2026
Copilot AI review requested due to automatic review settings March 23, 2026 20:57
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to compact the ATerm memory representation by removing per-term annotation storage from the general SharedTerm representation and introducing a dedicated integer-term storage path, with associated API/doc updates across the ATerm ecosystem.

Changes:

  • Remove annotation handling from general term representations (SharedTerm, Term trait, and related macro-generated APIs), and shift integer value storage to a dedicated SharedTermInt representation.
  • Extend term storage with a separate integer-term table (int_terms) and update global pool integer creation to use it.
  • Update allocator freelist internals and strengthen tests/documentation across term/symbol/pool modules.

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
crates/unsafety/src/block_allocator.rs Switch freelist next to nullable raw pointer and improve tests for allocator reuse/aliasing.
crates/macros/src/merc_derive_terms.rs Remove generated annotation() from derived term trait delegations.
crates/data/src/data_expression.rs Update machine-number extraction to go through ATermIntRef.
crates/aterm/src/symbol.rs Doc/comment cleanups and link updates.
crates/aterm/src/storage/thread_aterm_pool.rs Doc updates around term construction and thread pool role.
crates/aterm/src/storage/symbol_pool.rs Doc/link tweaks for symbol pool.
crates/aterm/src/storage/shared_term.rs Remove annotation storage from SharedTerm; adjust layout/equality/hash/debug.
crates/aterm/src/storage/mod.rs Module-level doc link correction.
crates/aterm/src/storage/global_aterm_pool.rs Route integer-term creation through new insert_int_term path.
crates/aterm/src/storage/gc_mutex.rs Documentation clarifications for GC guard behavior.
crates/aterm/src/storage/aterm_storage.rs Add separate int_terms storage and SharedTermInt representation + insertion API.
crates/aterm/src/protected.rs Documentation clarifications for protection guards.
crates/aterm/src/markable.rs Documentation updates and typo fix.
crates/aterm/src/aterm_list.rs Documentation tweaks + remove annotation() from generated term traits.
crates/aterm/src/aterm_int.rs Rework integer value access to read from SharedTermInt via pointer cast.
crates/aterm/src/aterm_builder.rs Spelling fix in docs.
crates/aterm/src/aterm_binary_stream.rs Documentation link/name corrections.
crates/aterm/src/aterm.rs Remove annotation() from Term trait and implementations; doc improvements.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 21 out of 21 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mlaveaux mlaveaux force-pushed the feature/compact-aterm branch from 1975a5c to 665bf8e Compare March 25, 2026 17:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants