Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lazily allocate and eagerly free unpacker stack #376

Merged
merged 1 commit into from
Nov 13, 2024

Conversation

casperisfine
Copy link

Applications may have numerous unpacker instances allocated with different configurations, but are very unlikely to have more than one or a handful active concurrently.

As such eagerly allocating the 4kiB parsing stack is using more memory than necessary.

Additionally, when only a few arena pages are in use, allocating a chunk from a first page is very cheap.

The only complexity in this patch is the Unpacker#each API that requires not to free the stack on EOF as parsing may be resumed afterwards.

@peterzhu2118

Applications may have numerous unpacker instances allocated with
different configurations, but are very unlikely to have more than
one or a handful active concurrently.

As such eagerly allocating the 4kiB parsing stack is using more
memory than necessary.

Additionally, when only a few arena pages are in use, allocating
a chunk from a first page is very cheap.

The only complexity in this patch is the `Unpacker#each` API that
requires not to free the stack on EOF as parsing may be resumed
afterwards.
@byroot byroot merged commit 83a2600 into msgpack:master Nov 13, 2024
17 checks passed
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