Skip to content

arrow-buffer: ops on empty buffer values slow on x86-64 with AVX-512 #12269

Description

@azecevic000

Is your feature request related to a problem or challenge?

When all values of a string or binary array are empty, its values buffer has no allocation. Its pointer is then a dangling address in the unmapped first page: 0x80 (ALIGNMENT on x86-64) for a MutableBuffer, or 0x1 for a buffer from an empty Vec<u8>.

glibc >=2.35 use __memcmp_evex_movbe as a memcmp implementation on x86 AVX-512 machine. For lengths <=32, it uses masked vector loads, with no branch for length 0. Even though the result is correct, the CPU still translates the address. On the machine on which I measured the diff is ~90ns without the fix vs ~2ns with the fix.

Describe the solution you'd like

Give all buffers without an allocation one real, aligned static address, as Arrow C++ does with zero_size_area. This is fairly common technique which guards against UB like the one just described.

Describe alternatives you've considered

  • Fix individual ops like eq, lt etc. There are many of them, and it's hard to get a proper coverage.
  • Fix in either rustc and glibc. This can be considered an issue in both of those projects, but the proposed solution is still valuable regardless of a potential fix in either of those dependencies.

Additional context

No response

Willingness to contribute

I plan to contribute to this feature independently

Activity

  1. added
    enhancement
    on Nov 16, 2026
  2. azecevic000 commented on Nov 16, 2026

    @azecevic000
    ContributorAuthor

    proposed solution: #12141

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancement

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions