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

Used memory #72

Open
bgranvea opened this issue Mar 30, 2023 · 1 comment
Open

Used memory #72

bgranvea opened this issue Mar 30, 2023 · 1 comment

Comments

@bgranvea
Copy link

I'm currently implementing a strategy which limits the size of my inserts based on memory constraints, because in some cases I have many parallel insert buffers in memory and I would like to be sure that they all together don't exceed some max memory setting.

My idea would be to define a method like this:

func (c *Base[T]) UsedMemory() uint64 {
	return uint64(cap(c.values) * int(c.rtype.Size()))
}

I'm using cap() instead of len() as it reflects the allocated memory. Not sure if the function should return an uint64 or another type.

From what I see in the code it shouldn't be too difficult to implement. There are some subtleties for some types (low cardinality...) but it seems doable. One point not very clear to me is that some structures seems to be used for written data, other for read data. My use case is to measure memory for writes only, but read data could be captured too.

What do you think?

@vahid-sohrabloo
Copy link
Owner

Yes. for most types it's possible.
maybe we can add something like WriterBufferSize or WriterBufferCap.
I was working on the v3. But now I am involved in a family issue. I will probably be working on this in about two weeks.
Of course, you can also make a pull request.

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

No branches or pull requests

2 participants