julia-script / julia-script/silk
memory: add an arena allocator behind the public Allocator contract
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 48
- Forks
- 0
- Avg merge
- 4h 49m
- Merged PRs (30d)
- 213
Description
Context
SystemAllocator is the only allocator that Silk ships. The Allocator service is
ordinary source-declared code with no compiler privilege, so another policy can join it.
The spec names an arena as future work: "A future arena or other policy may participate
only by satisfying the same public contract without compiler-known lifetime rules"
(bootstrap-owned-allocation:124-126).
Current behavior
Every allocation goes through SystemAllocator, which calls libc malloc and free on
native LLVM and the bump pointer on Wasm. A program that makes many short-lived
allocations pays the full per-allocation cost each time. There is no way to release a
group of allocations together.
Requirements
- An arena allocator must satisfy the same public
Allocatorcontract as
SystemAllocator. - The compiler must not branch on the arena's nominal type in the semantic phase, HIR,
MIR, the evaluator, or either backend. - The arena must not introduce compiler-known lifetime rules.
- Escaping allocation must stay unavailable. An
Allocationvalue must not outlive the
arena that made it. - The arena must release its whole region when it drops.
Example
pub struct Arena {
region: RawBuffer
offset: usize
}
impl Allocator for Arena {
effect fn allocate(self: &mut Arena, layout: Layout) -> Allocation ! OutOfMemory
}
Out of scope
- Escaping arenas. The spec says these "remain unavailable"
(bootstrap-owned-allocation:124-126). - Any compiler change. An arena is ordinary Silk over the existing contract.
- Arena-scoped borrow checking or lifetime parameters.
Dependencies
- #21 (bulk memory operations) helps the arena reset path, but is not mandatory.
Acceptance criteria
- An acceptance test provides an
Arenawhere a test previously provided
SystemAllocator, and the program behaves the same. - A test asserts the arena releases its whole region on drop.
- The existing
OwnedAllocationDispatchtest still shows no allocator-kind
branching.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the public Allocator contract and existing SystemAllocator, then locate the acceptance coverage and OwnedAllocationDispatch test mentioned in the issue. Add an Arena implementation without compiler changes, verify equivalent allocation behavior and whole-region release on drop, and confirm the dispatch test still shows no allocator-kind branching.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers, operating-systems
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100