Conversation
Expurple
left a comment
There was a problem hiding this comment.
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 |
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. |
Expurple
left a comment
There was a problem hiding this comment.
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.