Closed
Conversation
kiootic
reviewed
Jan 26, 2024
| ) | ||
|
|
||
| func TestGetContent(t *testing.T) { | ||
| cc, err := NewContentCache(128, true) //for some reason Set fails if size <= 60 |
Collaborator
There was a problem hiding this comment.
Why? Can we investigate the reason?
| size := contentCacheSize | ||
| cache, err := ristretto.NewCache(&ristretto.Config{ | ||
| //NumCounters is 10 times estimated max number of items in cache, as suggested in https://pkg.go.dev/github.com/dgraph-io/ristretto@v0.1.1#Config | ||
| NumCounters: 1e7, |
Collaborator
There was a problem hiding this comment.
It is calculated from number of items, not size of items. I don't think there would be 1000000 files in the cache.
|
|
||
| ce := ContentCacheCell{ | ||
| id: id, | ||
| Data: bytes.NewBuffer(bytes.Trim(b, string([]byte{0x0}))), |
Contributor
Author
There was a problem hiding this comment.
because b is initialized with max cache size, there are 0 bytes after reading
Collaborator
There was a problem hiding this comment.
This could be problematic:
- Every time we load a file, no matter how large/small it is, we will allocate the max cached file size (~10MB), which makes memory cosumption unnecessarily high.
- The file can ends with 0 bytes, and removing them would be inappropiate.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.