Skip to content

Conversation

@lidavidm
Copy link
Member

@lidavidm lidavidm commented Aug 31, 2021

Essentially, this failure boils down to: when generating the array of uniques for booleans, we pack 8 bytes at a time into one byte. The bytes are packed from what turns out to be a scratch array allocated by TempVectorStack, which does not initialize its memory. So when we have a non-multiple-of-8 number of bytes, we may end up packing initialized bytes and uninitialized bytes together into a single garbage byte, resulting in Valgrind complaining.

@github-actions
Copy link

@github-actions
Copy link

⚠️ Ticket has not been started in JIRA, please click 'Start Progress'.

@lidavidm
Copy link
Member Author

@github-actions crossbow submit test-conda-cpp-valgrind

@github-actions
Copy link

Revision: 16700058feb3a672d5187cbfbf434b556b3a2fe2

Submitted crossbow builds: ursacomputing/crossbow @ actions-807

Task Status
test-conda-cpp-valgrind Azure

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will it overflow the buffer if num_rows is multiplier of 8?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be OK (there's a typo here, it's uint32_t values so the temporary buffer is actually overallocated by a factor of 4x). But I've adjusted it anyways.

@lidavidm
Copy link
Member Author

lidavidm commented Sep 1, 2021

@github-actions crossbow submit test-conda-cpp-valgrind

@github-actions
Copy link

github-actions bot commented Sep 1, 2021

Revision: 22cbfd915497a114b45035379b842ef214cd06d8

Submitted crossbow builds: ursacomputing/crossbow @ actions-808

Task Status
test-conda-cpp-valgrind Azure

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if it wouldn't be easier to just always zero-initialize the 8 last bytes in the temp buffer?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case, since the temp buffer is reused quite a bit, we might as well just initialize the underlying buffer on allocation? It should be a fixed setup cost since one large buffer is allocated on creation of the grouper (TempVectorStack) and then slices of it (TempVectorHolder) are taken as scratch space.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 from me

@pitrou
Copy link
Member

pitrou commented Sep 1, 2021

@ursabot please benchmark

@ursabot
Copy link

ursabot commented Sep 1, 2021

Benchmark runs are scheduled for baseline = bb533fb and contender = c005c9b. Results will be available as each benchmark for each run completes.
Conbench compare runs links:
[Finished ⬇️0.0% ⬆️0.0%] ec2-t3-xlarge-us-east-2
[Finished ⬇️0.0% ⬆️0.0%] ursa-i9-9960x
[Finished ⬇️0.14% ⬆️0.0%] ursa-thinkcentre-m75q
Supported benchmarks:
ursa-i9-9960x: langs = Python, R, JavaScript
ursa-thinkcentre-m75q: langs = C++, Java
ec2-t3-xlarge-us-east-2: cloud = True

@cyb70289 cyb70289 closed this in e380c1a Sep 2, 2021
ViniciusSouzaRoque pushed a commit to s1mbi0se/arrow that referenced this pull request Oct 20, 2021
Essentially, this failure boils down to: when generating the array of uniques for booleans, we pack 8 bytes at a time into one byte. The bytes are packed from what turns out to be a scratch array allocated by TempVectorStack, which does not initialize its memory. So when we have a non-multiple-of-8 number of bytes, we may end up packing initialized bytes and uninitialized bytes together into a single garbage byte, resulting in Valgrind complaining.

Closes apache#11041 from lidavidm/arrow-13812

Authored-by: David Li <li.davidm96@gmail.com>
Signed-off-by: Yibo Cai <yibo.cai@arm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants