paravoid opened a new pull request #1091:
URL: https://github.com/apache/avro/pull/1091


   This fixes some unaligned memory access issues, which cause an immediate 
crash with SIGBUS on certain architectures (e.g. sparcv9, as the Jira ticket 
indicates), as well as performance degredation in most others. This effectively 
fixes two issues with the existing code:
   - The refcount was kept in a (32-bit) `int`, and then access to the data is 
shifted by 32-bits as well; the commit included changes this to a `long`, which 
is equal to `sizeof(void *)` on all Unices (and e.g. 32-bit on x86, but 64-bit 
on x86_64 and sparcv9).
   - Record fields are accessed using an offset (`field_offset`), which was set 
to the previous field's size. If the previous field was e.g. an `int` (i.e. 
int32_t), or a boolean (int) etc., then access past it would be unaligned (i.e. 
`int` followed by a `long` => `int` at offset 0, `long` at offset 4). This 
commit rounds up the "field size" to a multiple of pointer size. In C terms, 
Avro kept records in memory as a packed structure, while this commit modifies 
this to add paddings so that fields always start on the right boundary.
   
   This has been tested (built & ran tests, including memcheck/Valgrind) on 
both x86_64 (amd64) and sparcv9 (sparc64) on Linux/GCC. I have unfortunately 
not tested it with any real world code, or benchmarked the performance benefits 
on popular 64-bit architectures (like x86_64 or aarch64).
   
   ### Jira
   
   - [x] My PR addresses 
[AVRO-1846](https://issues.apache.org/jira/browse/AVRO-1846)
   
   ### Tests
   
   - [x] My PR does not need testing for this extremely good reason: all code 
covered by existing tests
   
   ### Commits
   
   - [x] My commits all reference Jira issues in their subject lines, with the 
exception the first one, which is a tiny define rename not associated with any 
issue.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to