fix: remove incorrect debug assertion in BatchCoalescer #9508
fix: remove incorrect debug assertion in BatchCoalescer #9508alamb merged 2 commits intoapache:mainfrom
Conversation
|
This should be a change to the |
|
This should be a change to the debug_assert to be >= rather than here I think? Reserving exact will increase memory fragmentation I agree fixing the assert might be best. The idea with the assert as I recall was to ensure that the memory growth is as expected. Maybe we can find a way to write a test instead that does the check and remove the debug assert entirely 🤔 |
|
I agree, updating the debug (or even removing with the test) should be the fix. |
|
Thanks for working on this, I'm hitting it as well :( |
|
Just updated the PR to remove the I'm not sure what a meaningful replacement test would look like here, since the assertion was guarding internal memory behavior rather than observable output. Happy to add a test if someone has a good idea what to check here. |
Btw - I didn't really understand this part? In this code using |
|
The standard reservation strategy for |
Ah good one, yeah that is true. Although |
alamb
left a comment
There was a problem hiding this comment.
I agree -- this looks good to me too now. Removing the over zealous assert 👍
I think when I wrote this, I was thinking of cases where the allocation size could change over time and trigger multiple reallocations. |
Which issue does this PR close?
Rationale for this change
Vec::reserve(n)does not guarantee exact capacity, Rust'sMIN_NON_ZERO_CAPoptimization meansreserve(2)gives capacity = 4 for most numeric types, causingdebug_assert_eq!(capacity, batch_size)to panic in debug mode whenbatch_size < 4.What changes are included in this PR?
Replace
reservewithreserve_exactinensure_capacityin bothInProgressPrimitiveArrayandInProgressByteViewArray.reserve_exactskips the amortized growth optimization and allocates exactly the requested capacity, making the assertion correct.Are these changes tested?
No. This only fixes an incorrect debug assertion.
Are there any user-facing changes?
No