-
-
Notifications
You must be signed in to change notification settings - Fork 221
Value: box BigDecimal and Array #931
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I disagree that going 40->32 bytes is worth verbose user-visible boxing. What's even the reason for doing that? You don't include any benchmark results in the PR description.
My colleagues are always frustrated with SeaORM when they have to construct expressions like Value::Array(ArrayType::BigInt, Some(Box::new(foo)))
. Even the diff shows that the code is more verbose
32 is a magic power-of-two number that's more cache line friendly. such that most value variants don't get pessemisied by if you are concerned about ergonomics, we can add a few |
Yeah,
Sure, but how important is that in practice? I could only find a single open performance-related issue across SeaORM and SeaQuery repos: #259. On the other hand, ergonomics has always been a big issue for me and my team. I'm vary of micro-optimizing without representative benchmarks. And I doubt that |
Btw, the size of |
https://play.rust-lang.org/?version=stable&mode=debug&edition=2024
it's 32. it's interesting that it has enough unused bits that it's still 32 after niche field optimization.
I think a just to say I am not against 40, but inflating it to 40 here brings no additional benefit. the gain from 24 -> 32 is well worth the memory. may be we add a few more variants then it becomes 40 inevitably. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, let's move on. At least, now we have a consistent, documented, tested, and benchmarked approach
Big thanks to both of you! @Huliiiiii @Expurple |
Oh, enabling both "with-json" and "with-bigdecimal" breaks niche optimizations. I agree with Expurple's point — Value is more often used inside a Vec, and the overhead from double heap allocation may not be smaller than the benefit gained from size optimization. I’ve updated the benchmarks — for inputs with 10 |
These two types are already internally heap-allocated.
And boxing these two would bring down Value to 32 bytes.
I hope this is a fair trade off.