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

Create a new bitmap structure that is value-based as opposed to interface-based #228

Open
lemire opened this issue Aug 13, 2019 · 4 comments

Comments

@lemire
Copy link
Member

lemire commented Aug 13, 2019

This incomplete PR outlined potential performance gains when replacing interface/reference containers with value-based containers. The performance difference would be particularly notable for users creating many small bitmaps. This would require a new API that could be created.

#149

@Oppen
Copy link
Contributor

Oppen commented Jun 16, 2021

Have we tried changing only the New function? I have the suspicion for the most part it's not about not passing pointers but about the escape analysis failing us, thus allocation on the heap and having the GC track the references.
Even better, we could not modify New but rather derreference on creation to allocate on the stack and let the instance die young for a simple test.
We could also just tell the compiler to inform us about the results of escape analysis before and after with the PR's code to check this possibility.

@lemire
Copy link
Member Author

lemire commented Jun 16, 2021

escape analysis failing us, thus allocation on the heap and having the GC track the references

I have not checked but I am almost certain that it gets allocated on the heap. Go is very conservative with its escape analysis. It is quite difficult to avoid heap allocation. I am not sure what you have in mind. I do invite experimentation. It is trivial in Go to find out the result of escape analysis (good!) but it is almost always the same result (heap allocation).

I'd love to be proven wrong.

@Oppen
Copy link
Contributor

Oppen commented Jun 16, 2021

Yeah, I don't remember the flags but it's quite trivial. What I thought was either making a copy of the output in the same line (the object becomes unreachable, hopefully dying soon) or, alternatively, using a new constructor that returns a value object. I do not remember if escape analysis flags function arguments in any way that let callers know they don't cause their arguments to escape, but if it does I think that should be enough help for it to know it doesn't need to keep the new instance (created as value) on the heap.

@Oppen
Copy link
Contributor

Oppen commented Jun 16, 2021

In any case, the change I propose is easy to try, and I only need the escape analysis output. I'll see if I can do it soon.

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

No branches or pull requests

2 participants