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

Change WC size estimations #3106

Merged
merged 2 commits into from
Jan 31, 2025
Merged

Conversation

End-rey
Copy link
Contributor

@End-rey End-rey commented Jan 31, 2025

Closes #3101.

Keep object list in memory along with sizes (map address to size)

Why are we doing this? We don't use it anywhere, do we?

Also, I forgot to include tests for migration from #3091, so I did it here.

Copy link

codecov bot commented Jan 31, 2025

Codecov Report

Attention: Patch coverage is 50.84746% with 29 lines in your changes missing coverage. Please review.

Project coverage is 22.39%. Comparing base (de89b7a) to head (dfe2711).
Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
pkg/local_object_storage/blobstor/fstree/fstree.go 32.25% 18 Missing and 3 partials ⚠️
pkg/local_object_storage/writecache/state.go 73.68% 5 Missing ⚠️
pkg/local_object_storage/writecache/delete.go 0.00% 1 Missing ⚠️
pkg/local_object_storage/writecache/put.go 75.00% 0 Missing and 1 partial ⚠️
pkg/local_object_storage/writecache/storage.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3106      +/-   ##
==========================================
+ Coverage   22.33%   22.39%   +0.05%     
==========================================
  Files         751      751              
  Lines       58028    58039      +11     
==========================================
+ Hits        12962    12999      +37     
+ Misses      44181    44149      -32     
- Partials      885      891       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@roman-khimov
Copy link
Member

Why are we doing this? We don't use it anywhere, do we?

We will. It allows to answer exists or get or head faster (remember that any shard operation has to check WC first) and it'll also be useful for flushing. The presumption is that write cache is a small but highly dynamic structure (objects come and go), this list is useful for it.

cacheSz := c.estimateCacheSize()
if c.maxCacheSize < c.incSizeFS(cacheSz) {
cacheSz := c.objCounters.Size()
objSz := obj.obj.PayloadSize()
Copy link
Member

Choose a reason for hiding this comment

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

Object is a bit bigger than its payload. But if can't get its size easily it should be OK this way.

if c.maxCacheSize < c.incSizeFS(cacheSz) {
cacheSz := c.objCounters.Size()
objSz := obj.obj.PayloadSize()
if c.maxCacheSize < cacheSz+objSz {
Copy link
Member

Choose a reason for hiding this comment

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

We can go slightly above the limit due to concurrency. Also likely not a bit issue.

}

func (c *cache) initCounters() error {
inFS, err := c.fsTree.NumberOfObjects()
var objHandler = func(addr oid.Address, data []byte, _ []byte) error {
c.objCounters.Add(addr, uint64(len(data)))
Copy link
Member

Choose a reason for hiding this comment

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

Notice that you're using full object size here.

Now size of write-cache is a sum of every object currently stored in WS.

Closes #3101.

Signed-off-by: Andrey Butusov <[email protected]>
@End-rey End-rey force-pushed the 3101-fix-wc-size-estimations branch from c7b910d to dfe2711 Compare January 31, 2025 15:03
@End-rey
Copy link
Contributor Author

End-rey commented Jan 31, 2025

If I understand you correctly, I added a new sizeHandler to the iterate func to collect sizes.

@roman-khimov
Copy link
Member

iterate is more and more hairy now, but this should do the job.

@roman-khimov roman-khimov merged commit d7407d1 into master Jan 31, 2025
22 checks passed
@roman-khimov roman-khimov deleted the 3101-fix-wc-size-estimations branch January 31, 2025 16:22
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.

Fix WC size estimations
2 participants