Skip to content

remove allocator and switch to immutable value boxing#22

Merged
wolfy-j merged 1 commit intomainfrom
remove-allocator-main
Mar 3, 2026
Merged

remove allocator and switch to immutable value boxing#22
wolfy-j merged 1 commit intomainfrom
remove-allocator-main

Conversation

@wolfy-j
Copy link
Contributor

@wolfy-j wolfy-j commented Mar 3, 2026

This pull request removes the custom memory allocator and related preloading logic for Lua number and integer values, simplifying the codebase and reducing complexity. All references to the allocator have been removed, and number/integer boxing is now handled by straightforward helper functions. The registry and state management code have been updated to reflect this change, and related tests and benchmarks have been refactored accordingly.

Reduction of actor size. Avg actor size is ~7kb.

Key changes include:

Removal of custom allocator and preloading logic

  • Deleted the allocator type and all related functions, including preloading arrays and memory management logic in alloc.go. ([alloc.goL1-L97](https://github.com/wippyai/go-lua/pull/22/files#diff-e85db5abe063d800fbae17d8fbc529bf6298f99072e56be699b1cce9a5d7a582L1-L97))
  • Removed the associated tests and benchmarks for the allocator from alloc_test.go. ([alloc_test.goL1-L217](https://github.com/wippyai/go-lua/pull/22/files#diff-dd924401d7e62c7a20c3d67b474354f13e5411e198d8363ad7b3d6db06e83478L1-L217))

Refactoring of registry and value boxing

  • Updated the registry struct and its constructor in registry.go to remove the allocator field and parameter. All number/integer boxing now uses helper functions instead of the allocator. ([[1]](https://github.com/wippyai/go-lua/pull/22/files#diff-638576cf5913c90c8eb77dadc04e6834ec3061ae4873d3ed7eeca0a2908a1c63L13-R17), [[2]](https://github.com/wippyai/go-lua/pull/22/files#diff-638576cf5913c90c8eb77dadc04e6834ec3061ae4873d3ed7eeca0a2908a1c63L269-R268))
  • Adjusted all usages of the allocator in the registry tests to use the new boxing helpers and updated constructor calls. ([[1]](https://github.com/wippyai/go-lua/pull/22/files#diff-edb24508617964ec78bbd08114140588702e64b9d1f8fce9540cf3162f0c38f3L17-R17), [[2]](https://github.com/wippyai/go-lua/pull/22/files#diff-edb24508617964ec78bbd08114140588702e64b9d1f8fce9540cf3162f0c38f3L54-R53), [[3]](https://github.com/wippyai/go-lua/pull/22/files#diff-edb24508617964ec78bbd08114140588702e64b9d1f8fce9540cf3162f0c38f3L83-R81), [[4]](https://github.com/wippyai/go-lua/pull/22/files#diff-edb24508617964ec78bbd08114140588702e64b9d1f8fce9540cf3162f0c38f3L104-R101), [[5]](https://github.com/wippyai/go-lua/pull/22/files#diff-edb24508617964ec78bbd08114140588702e64b9d1f8fce9540cf3162f0c38f3L126-R122), [[6]](https://github.com/wippyai/go-lua/pull/22/files#diff-edb24508617964ec78bbd08114140588702e64b9d1f8fce9540cf3162f0c38f3L150-R145), [[7]](https://github.com/wippyai/go-lua/pull/22/files#diff-edb24508617964ec78bbd08114140588702e64b9d1f8fce9540cf3162f0c38f3L179-R173), [[8]](https://github.com/wippyai/go-lua/pull/22/files#diff-edb24508617964ec78bbd08114140588702e64b9d1f8fce9540cf3162f0c38f3L203-R196), [[9]](https://github.com/wippyai/go-lua/pull/22/files#diff-edb24508617964ec78bbd08114140588702e64b9d1f8fce9540cf3162f0c38f3L228-R220), [[10]](https://github.com/wippyai/go-lua/pull/22/files#diff-edb24508617964ec78bbd08114140588702e64b9d1f8fce9540cf3162f0c38f3L252-R245), [[11]](https://github.com/wippyai/go-lua/pull/22/files#diff-edb24508617964ec78bbd08114140588702e64b9d1f8fce9540cf3162f0c38f3L269-R259), [[12]](https://github.com/wippyai/go-lua/pull/22/files#diff-edb24508617964ec78bbd08114140588702e64b9d1f8fce9540cf3162f0c38f3L284-R273), [[13]](https://github.com/wippyai/go-lua/pull/22/files#diff-edb24508617964ec78bbd08114140588702e64b9d1f8fce9540cf3162f0c38f3L298-R286))

Updates to state management

  • Removed allocator-related logic from the LState initialization and pooling logic in state.go, including the removal of allocator resets and constructor arguments. ([[1]](https://github.com/wippyai/go-lua/pull/22/files#diff-320959764bfa2277e0bdd4eaa741f02891d123c42150d4ccb76de0bdbf6e591aL448-R449), [[2]](https://github.com/wippyai/go-lua/pull/22/files#diff-320959764bfa2277e0bdd4eaa741f02891d123c42150d4ccb76de0bdbf6e591aL464-R471), [[3]](https://github.com/wippyai/go-lua/pull/22/files#diff-320959764bfa2277e0bdd4eaa741f02891d123c42150d4ccb76de0bdbf6e591aL497), [[4]](https://github.com/wippyai/go-lua/pull/22/files#diff-320959764bfa2277e0bdd4eaa741f02891d123c42150d4ccb76de0bdbf6e591aL506), [[5]](https://github.com/wippyai/go-lua/pull/22/files#diff-320959764bfa2277e0bdd4eaa741f02891d123c42150d4ccb76de0bdbf6e591aL519-R512), [[6]](https://github.com/wippyai/go-lua/pull/22/files#diff-320959764bfa2277e0bdd4eaa741f02891d123c42150d4ccb76de0bdbf6e591aL1426-R1419))

Refactoring of integer boxing in tests

  • Updated integer boxing in integer_test.go to use the new helper function instead of the allocator. ([[1]](https://github.com/wippyai/go-lua/pull/22/files#diff-b25f7f3eeaa5c29ba9b293a2901dcd671fa7df412c4ef4faf107110c1310b30fL33-R35), [[2]](https://github.com/wippyai/go-lua/pull/22/files#diff-b25f7f3eeaa5c29ba9b293a2901dcd671fa7df412c4ef4faf107110c1310b30fL48-R49))

@wolfy-j wolfy-j merged commit fdc60c6 into main Mar 3, 2026
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