Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unaligned vertex accesses #175

Merged
merged 5 commits into from
Nov 9, 2023
Merged

Remove unaligned vertex accesses #175

merged 5 commits into from
Nov 9, 2023

Conversation

Maxxen
Copy link
Member

@Maxxen Maxxen commented Nov 7, 2023

This PR avoid potential unaligned reads of geometry vertices that sometimes occurs after DuckDB performs a slice operation on a blob vector, by replacing raw pointer accesses with a memcpy. In practice this only affects the functions that are natively implemented in duckdb (all GEOS based operations performs a copy anyway), and on modern CPU's the performance difference should be negligible. Although it may hinder autovectorization or impact other compiler optimizations negatively.

However, this is somewhat temporary.
I have previously looked into making changes inside DuckDB to ensure that blob heap pointers remain 8 or 16-byte aligned, and while its doable, its not trivial, so we will have to do with this for a while. But I'm also working on a rework of the native geometry structures to support 3D/4D geometry ops which will change the de/serialization logic as well, so we may also revisit this then (e.g. use raw pointers unless we detect the data to be misaligned during deserialization, in which case we do a copy of the whole geometry blob)

@Maxxen Maxxen changed the title Remove unaligned vector accesses Remove unaligned vertex accesses Nov 7, 2023
@Maxxen Maxxen merged commit afd6452 into duckdb:main Nov 9, 2023
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant