Use memory footprint of sugardb.store to compare against max memory for eviction policies #133
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Addresses #121
So I spent a good amount of time trying to understand the nuances with various data types in go and the amount of memory they take up. I think I've come up with a strong enough solution but I'm not sure any implementation would be perfect due to some limitations within go.
Some of the more primitive data types like int64 are straight forward in the amount of bytes occupied in memory, others not so much. Slices and strings have headers, structs will include padding between their various fields, and maps have a header consisting of a pointer, but also have several other components under the hood. I couldn't find an up to date method for accurately accounting for these other components since they have apparently changed over the years. So maps will be underreported, but my understanding is that the difference would be trivial for our use case anyway.
Open to feedback and happy to make adjustments or go a different direction on the implementation if needed.