Skip to content
Snippets Groups Projects
  • Vladislav Shpilevoy's avatar
    94345e4d
    tuple: use unaligned store-load for field map · 94345e4d
    Vladislav Shpilevoy authored
    A tuple can have a field map. It is an array of uint32_t values,
    stored right after 'struct tuple' object in the same memory block.
    
    'struct tuple' is 10 byte size, and is aligned by 4 bytes (even
    though it is 'PACKED', so does not need an alignment). It means,
    that field map is stored by an address like this: 4*N + 10.
    
    This address is never aligned by 4, needed for uint32_t field map
    array. So the array members should be accessed using operations
    aware of unaligned nature of the addresses.
    
    Unfortunately, it is impossible to make the field map aligned,
    because that requires + 2 bytes for each tuple. It is unaffordable
    luxury, since tuple count can be millions and even billions. Every
    new byte may result in gigabytes of memory in a cluster.
    
    The patch makes field map accessed using unaligned store-load
    operations.
    
    Part of #4609
    94345e4d
    History
    tuple: use unaligned store-load for field map
    Vladislav Shpilevoy authored
    A tuple can have a field map. It is an array of uint32_t values,
    stored right after 'struct tuple' object in the same memory block.
    
    'struct tuple' is 10 byte size, and is aligned by 4 bytes (even
    though it is 'PACKED', so does not need an alignment). It means,
    that field map is stored by an address like this: 4*N + 10.
    
    This address is never aligned by 4, needed for uint32_t field map
    array. So the array members should be accessed using operations
    aware of unaligned nature of the addresses.
    
    Unfortunately, it is impossible to make the field map aligned,
    because that requires + 2 bytes for each tuple. It is unaffordable
    luxury, since tuple count can be millions and even billions. Every
    new byte may result in gigabytes of memory in a cluster.
    
    The patch makes field map accessed using unaligned store-load
    operations.
    
    Part of #4609