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

[feat]: add custom allocator #29

Open
wants to merge 1 commit into
base: main-lantern
Choose a base branch
from

Conversation

broccoliSpicy
Copy link

@broccoliSpicy broccoliSpicy commented Apr 9, 2024

This PR tries to add a class custom_allocator_gt so we can pass different allocation/free function pointers to usearch.

lantern issue #147

for discussion only, just a draft to set the direction.

todo: how much performance benefits we can get if we use a aligned allocator(palloc_aligned())


// Compare two allocators for equality (always true for stateless allocators)
template<typename other_element_at>
bool operator==(const custom_allocator_gt<other_element_at>&) const noexcept {
Copy link
Author

Choose a reason for hiding this comment

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

these are just operators to conform c++'s requirement for an allocator

@broccoliSpicy
Copy link
Author

Hey @Ngalstyan4, would you be a lamb and check out this PR for me?

@Ngalstyan4
Copy link
Owner

Hi @broccoliSpicy , thanks for the contribution!
Could you share the intended API for passing the allocation functions from C as well? And whether/how postgres's palloc could fit into the allocator interface.

It might also be useful to look at pgv8 postgres extension for how to deal with cpp allocations in a postgres context

Thanks again for your contributions!

@broccoliSpicy
Copy link
Author

passing the allocation functions from C

as for checking pgv8, I am sorry that I am having final projects and final exams this week, but I will definitely check it out in next week.

@broccoliSpicy
Copy link
Author

I checked pgv8, I think their cpp allocator is more like a buffer pool, and I couldn't see their cpp allocator's relevance with postgres's palloc, it seems their cpp allocator is just using standard c malloc function and couldn't be customized.

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.

2 participants