Conversation
|
shall we establish a new size bound for edit: I think reasonable max size is probably 32 bytes, then we can hold a |
|
We can just assert the current size for now. If a new variant appears, makes the enum larger and breaks the assertion, then we can benchmark and decide whether we need to box that new variant |
Expurple
left a comment
There was a problem hiding this comment.
Thank you, looks cleaner this way.
Can you also fix the CI errors and add a changelog entry?
|
I'd probably add this: const _: () = {
check_value_size();
};
const fn check_value_size() {
if std::mem::size_of::<Value>() > 32 {
panic!("the size of Value shouldn't be greater than 32 bytes")
}
} |
|
I'd also add a comment right there, next to the assertion. To document our approach and the existence of the benchmark |
646064f to
a5d42ea
Compare
|
Based on the benchmark results, I didn't see any performance impact from the size of Value (24 vs 40). I think the heap allocation would have a larger performance overhead. |
|
@Huliiiiii I agree with you. object in heap is almost always worse than on stack. but I think we should put a guard in place to prevent it growing unchecked. |
Expurple
left a comment
There was a problem hiding this comment.
Still needs a changelog entry. LGTM otherwise
Co-authored-by: Dmitrii Aleksandrov <[email protected]>
|
I'll probably make some small tweaks |
PR Info
Unbox values, benchmarks show a 10–15% performance improvement in query construction
New Features
Bug Fixes
Breaking Changes
Valueenum are no longer boxed.Changes