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

"raw_metadata" is not raw after serialization #72

Open
ShuiRuTian opened this issue May 8, 2024 · 3 comments · May be fixed by #74
Open

"raw_metadata" is not raw after serialization #72

ShuiRuTian opened this issue May 8, 2024 · 3 comments · May be fixed by #74
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@ShuiRuTian
Copy link
Contributor

Under "cache/index-v5/xx/yy/zzz", I found something like "raw_metadata":[0,18,32,112,97,......]"

It is the serialization of Vec, rather than binary like format.

Is this intentional? It looks like not very efficient.

@zkat
Copy link
Owner

zkat commented May 8, 2024

https://github.com/zkat/cacache-rs/blob/main/src/index.rs#L46-L54

oh. I guess that's just how serde serializes Vec<u8>

@zkat zkat added enhancement New feature or request help wanted Extra attention is needed labels May 8, 2024
@ShuiRuTian
Copy link
Contributor Author

ShuiRuTian commented May 9, 2024

Maybe we could base64/hex encode/decode it firstly?

Base64 makes the length about 33% larger than origin bytes, but we will save a u8 with a character rather than usually 3 chars(I mean the 2 number and one extra comma, one or three number is also possible, but relatively rare.)

And hex will always use 2 characters for one u8, so it makes length 100% larger than origin bytes.

Hex might be faster to parse, Base64 is more compact.

Seems https://github.com/DaniPopes/const-hex/tree/master is an easy and fast crate for this, it uses SIMD for many archs.

@zkat
Copy link
Owner

zkat commented May 9, 2024

base64 seems like a nicer option to me in general. I don't know if the difference in performance will matter, and storage will help a lot.

@ShuiRuTian ShuiRuTian linked a pull request May 10, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants