Skip to content

Not PR: architectural concept: compact JsonValue #1394

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

Closed
wants to merge 6 commits into from

Conversation

magicprinc
Copy link
Contributor

This is not an actual PR, because it breaks public JsonValue API πŸ€·β€β™€οΈ

The size of the current JsonValue (only object itself) is ~ 96 bytes.

The size of new JsonValue is ~ 24 bytes β‡’ 4 times smaller.
(see io.nats.client.support.JsonParsingTests#usedMemory)

The speed of working with the object does not seem to have changed (within the margin of error)
(see io.nats.client.support.JsonParsingTests#testReadSpeed)

If there can be significant amounts of objects in memory, then the difference will be noticeable.
E.g: for 50_000_000 objects
old 4.77 G
new 1.332 G

It passes the unit tests.

You might probably find this useful as a proof of concept or a source of inspiration 🀝

@magicprinc
Copy link
Contributor Author

I have a two-week vacation starting tomorrow without a laptop, so I sent this "PR" to summarize all my findings in jnats.
Unfortunately, I will be unavailable for the next few days.

Thanks again for the great project!

@scottf scottf closed this Aug 14, 2025
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