Fix blobovnizca data size counter #612

Merged
fyrchik merged 3 commits from dstepanov-yadro/frostfs-node:fix/blobovnizca_perf into master 2023-08-17 19:17:37 +00:00

Relates #602

Fix blobovnicza counters:

  • Add Init call to initialize size counter.

  • Previously, to determine the blobovnizca size, a logical size was added to the physical size. Now only the logical size is used. The size is calculated as multiplying the number of records by the upper bound of the bucket.

  • blobovnizca.Close can be called multiple times, so I added a mutex to avoid changing metrics and counters multiple times.

  • I changed the name of the size metric, since this metric does not correspond to the total size of the tree, but to the size of open blobovnizcas.

Relates #602 Fix blobovnicza counters: - Add `Init` call to initialize size counter. - Previously, to determine the blobovnizca size, a logical size was added to the physical size. Now only the logical size is used. The size is calculated as multiplying the number of records by the upper bound of the bucket. - `blobovnizca.Close` can be called multiple times, so I added a mutex to avoid changing metrics and counters multiple times. - I changed the name of the `size` metric, since this metric does not correspond to the total size of the tree, but to the size of open blobovnizcas.
dstepanov-yadro force-pushed fix/blobovnizca_perf from 32d198b316 to 77aad284d0 2023-08-15 15:22:37 +00:00 Compare
dstepanov-yadro force-pushed fix/blobovnizca_perf from 77aad284d0 to e1c2bb259e 2023-08-16 08:16:17 +00:00 Compare
dstepanov-yadro reviewed 2023-08-16 10:13:43 +00:00
@ -75,0 +102,4 @@
func (b *Blobovnicza) initializeSize() error {
var size uint64
err := b.boltDB.View(func(tx *bbolt.Tx) error {
return b.iterateAllBuckets(tx, func(lower, upper uint64, b *bbolt.Bucket) (bool, error) {
Author
Member

There should be 3 buckets for objSizeLimit=128KB: 0 - 32KB, 32KB-64KB, 64KB - 128KB.

There should be 3 buckets for `objSizeLimit=128KB`: 0 - 32KB, 32KB-64KB, 64KB - 128KB.
dstepanov-yadro reviewed 2023-08-16 10:20:34 +00:00
@ -49,3 +52,3 @@
err := b.boltDB.Update(func(tx *bbolt.Tx) error {
return b.iterateBuckets(tx, func(lower, upper uint64, buck *bbolt.Bucket) (bool, error) {
return b.iterateAllBuckets(tx, func(lower, upper uint64, buck *bbolt.Bucket) (bool, error) {
Author
Member

Scenario: I set the maximum size of the object to 1MB, saved the object, changed the maximum size to 128KB, then I'm trying to delete it, but the corresponding bucket is not found because of new limit.

After this fix all bucket will be iterated, not only limited by object size.

Scenario: I set the maximum size of the object to 1MB, saved the object, changed the maximum size to 128KB, then I'm trying to delete it, but the corresponding bucket is not found because of new limit. After this fix all bucket will be iterated, not only limited by object size.
dstepanov-yadro changed title from WIP: Blobovnizca performance to Fix blobovnizca data size counter 2023-08-16 10:22:52 +00:00
dstepanov-yadro requested review from storage-core-committers 2023-08-16 10:22:57 +00:00
dstepanov-yadro requested review from storage-core-developers 2023-08-16 10:22:57 +00:00
dstepanov-yadro force-pushed fix/blobovnizca_perf from 710da5cf93 to 850f79361b 2023-08-16 10:24:12 +00:00 Compare
fyrchik approved these changes 2023-08-16 10:35:16 +00:00
@ -16,2 +16,4 @@
// If the database file does not exist, it will be created automatically.
// If blobovnizca is already open, does nothing.
func (b *Blobovnicza) Open() error {
b.controlMtx.Lock()
Owner

Open is usually something done once after creation, do we have any place where we reuse the Blobovnicza struct?

`Open` is usually something done once after creation, do we have any place where we reuse the `Blobovnicza` struct?
Author
Member

No, here we check 'opened' flag for consistency with Init and Close

No, here we check 'opened' flag for consistency with `Init` and `Close`
fyrchik marked this conversation as resolved
@ -51,0 +60,4 @@
defer b.controlMtx.Unlock()
if !b.opened {
return errors.New("blobovnizca is not open")
Owner

s/open/opened/

s/open/opened/
Member

"open" seems fine to me as well. As in, "the door is open".

"open" seems fine to me as well. As in, "the door is open".
fyrchik marked this conversation as resolved
@ -92,2 +117,4 @@
// Close releases all internal database resources.
//
// If blobovnizca is already close, does nothing.
Owner

s/close/closed/

s/close/closed/
Author
Member

fixed

fixed
fyrchik marked this conversation as resolved
dstepanov-yadro force-pushed fix/blobovnizca_perf from 850f79361b to 6f69dcbb0d 2023-08-16 11:54:06 +00:00 Compare
dstepanov-yadro force-pushed fix/blobovnizca_perf from 6f69dcbb0d to c0f3fb332f 2023-08-16 12:24:56 +00:00 Compare
acid-ant approved these changes 2023-08-16 12:53:19 +00:00
fyrchik merged commit 10e63537b2 into master 2023-08-17 19:17:37 +00:00
Sign in to join this conversation.
No reviewers
TrueCloudLab/storage-core-developers
No milestone
No project
No assignees
4 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: TrueCloudLab/frostfs-node#612
No description provided.