Use new protobuf marshaler #1322

Merged
fyrchik merged 1 commit from fyrchik/frostfs-node:update-marshaling into master 2024-08-22 07:17:44 +00:00
Owner

@TrueCloudLab/storage-core-committers @TrueCloudLab/storage-core-developers
I am concerned about the necessity to copy the slice before the unmarshaling.
This is because bbolt Bucket.Get() return value lifetime is equal to that of a transaction.
I may have forgotten some of the places, please recheck if possible.

@TrueCloudLab/storage-core-committers @TrueCloudLab/storage-core-developers I am concerned about the necessity to copy the slice before the unmarshaling. This is because bbolt `Bucket.Get()` return value lifetime is equal to that of a transaction. I may have forgotten some of the places, please recheck if possible.
fyrchik force-pushed update-marshaling from 9894847659 to 1368911f67 2024-08-20 07:13:04 +00:00 Compare
fyrchik requested review from storage-core-committers 2024-08-20 07:13:05 +00:00
fyrchik requested review from storage-core-developers 2024-08-20 07:13:31 +00:00
aarifullin reviewed 2024-08-20 07:21:34 +00:00
@ -63,3 +61,1 @@
if !sig.Verify(body.StableMarshal(nil)) {
commonCmd.ExitOnErr(cmd, "", errors.New("invalid response signature"))
}
// if !sig.Verify(body.StableMarshal(nil)) {
Member

Disabled for debug?

Disabled for debug?
Author
Owner

oops, yes

oops, yes
Author
Owner

moved to WIP, will revisit everything

moved to WIP, will revisit everything
Author
Owner

Fixed, retested on dev-env

Fixed, retested on dev-env
aarifullin marked this conversation as resolved
fyrchik changed title from Use new protobuf marshaler to WIP: Use new protobuf marshaler 2024-08-20 07:23:19 +00:00
fyrchik force-pushed update-marshaling from 1368911f67 to 19baa40a77 2024-08-20 07:28:27 +00:00 Compare
fyrchik force-pushed update-marshaling from 19baa40a77 to c524cb145d 2024-08-20 08:05:27 +00:00 Compare
fyrchik force-pushed update-marshaling from c524cb145d to 6e1b74c58e 2024-08-20 08:24:35 +00:00 Compare
fyrchik changed title from WIP: Use new protobuf marshaler to Use new protobuf marshaler 2024-08-20 08:25:00 +00:00
fyrchik force-pushed update-marshaling from 6e1b74c58e to 203ddb1800 2024-08-20 08:46:40 +00:00 Compare
aarifullin approved these changes 2024-08-20 09:00:17 +00:00
aarifullin left a comment
Member

Awesome

Awesome
dstepanov-yadro reviewed 2024-08-20 13:14:17 +00:00
Makefile Outdated
@ -114,10 +114,8 @@ protoc:
echo "⇒ Processing $$f "; \
$(PROTOC_DIR)/bin/protoc \
--proto_path=.:$(PROTOC_DIR)/include:/usr/local/include \
--plugin=protoc-gen-go=$(PROTOC_GEN_GO_DIR)/protoc-gen-go \

If it not required, then need to drop this variable.

If it not required, then need to drop this variable.
Author
Owner

fixed

fixed
dstepanov-yadro marked this conversation as resolved
@ -125,3 +126,3 @@
data = getFromBucket(tx, bucketNameLockers(cnr, bucketName), key)
if len(data) != 0 {
return obj, obj.Unmarshal(data)
return obj, obj.Unmarshal(bytes.Clone(data))

What is the benefit of using a new marshalled in the end?

What is the benefit of using a new marshalled in the end?
Author
Owner
  1. We clone a single slice here vs cloning allocating multiple times for each slice field we use.
  2. If we unmarshal from then FSTree, no clone is done.
  3. Later we will add idiomatic []Attribute fields, that will allow us to gradually remove layers in ToGRPCMessage() conversion functions from the api-go.
1. We clone a single slice here vs cloning allocating multiple times for each slice field we use. 2. If we unmarshal from then FSTree, no clone is done. 3. Later we will add idiomatic `[]Attribute` fields, that will allow us to gradually remove layers in `ToGRPCMessage()` conversion functions from the api-go.
dstepanov-yadro marked this conversation as resolved
fyrchik force-pushed update-marshaling from 203ddb1800 to 80bd32e866 2024-08-21 07:39:03 +00:00 Compare
acid-ant approved these changes 2024-08-21 08:04:26 +00:00
dstepanov-yadro approved these changes 2024-08-21 08:07:33 +00:00

Technically it looks ok, but I would add performance tests.

Technically it looks ok, but I would add performance tests.
Author
Owner

@dstepanov-yadro good idea!
Here are the results for BenchmarkSubstorageReadPerf from the blobstor/perf_test.go.
I have intentionally stripped some of the benchmarks because they are too slow.
old is master, new is this PR.
The improvements are there both in terms of allocations and speed. I expect gains to be even bigger for big objects.

goos: linux
goarch: amd64
pkg: git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor
cpu: 11th Gen Intel(R) Core(TM) i5-1135G7 @ 2.40GHz
                                                        │     old      │                 new                 │
                                                        │    sec/op    │   sec/op     vs base                │
SubstorageReadPerf/memstore-rand100-8                     1108.0n ± 1%   986.3n ± 0%  -10.98% (p=0.000 n=10)
SubstorageReadPerf/fstree_with_object_counter-rand100-8    2.770µ ± 2%   2.378µ ± 1%  -14.15% (p=0.000 n=10)
geomean                                                    1.752µ        1.531µ       -12.58%

                                                        │     old      │                 new                  │
                                                        │     B/op     │     B/op      vs base                │
SubstorageReadPerf/memstore-rand100-8                      1552.0 ± 0%     896.0 ± 0%  -42.27% (p=0.000 n=10)
SubstorageReadPerf/fstree_with_object_counter-rand100-8   3.257Ki ± 0%   2.624Ki ± 1%  -19.44% (p=0.000 n=10)
geomean                                                   2.222Ki        1.515Ki       -31.80%

                                                        │    old     │                new                 │
                                                        │ allocs/op  │ allocs/op   vs base                │
SubstorageReadPerf/memstore-rand100-8                     27.00 ± 0%   21.00 ± 0%  -22.22% (p=0.000 n=10)
SubstorageReadPerf/fstree_with_object_counter-rand100-8   46.00 ± 0%   40.00 ± 0%  -13.04% (p=0.000 n=10)
geomean                                                   35.24        28.98       -17.76%

The diff I have applied.

diff --git a/pkg/local_object_storage/blobstor/perf_test.go b/pkg/local_object_storage/blobstor/perf_test.go
index 501c95a1dc..e9035e53ed 100644
--- a/pkg/local_object_storage/blobstor/perf_test.go
+++ b/pkg/local_object_storage/blobstor/perf_test.go
@@ -5,7 +5,6 @@ import (
 	"fmt"
 	"testing"
 
-	"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor/blobovniczatree"
 	"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor/common"
 	"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor/fstree"
 	"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor/memstore"
@@ -38,27 +37,27 @@ var storages = []storage{
 			return memstore.New()
 		},
 	},
-	{
-		desc: "fstree_nosync",
-		create: func(dir string) common.Storage {
-			return fstree.New(
-				fstree.WithPath(dir),
-				fstree.WithDepth(2),
-				fstree.WithDirNameLen(2),
-				fstree.WithNoSync(true),
-			)
-		},
-	},
-	{
-		desc: "fstree_without_object_counter",
-		create: func(dir string) common.Storage {
-			return fstree.New(
-				fstree.WithPath(dir),
-				fstree.WithDepth(2),
-				fstree.WithDirNameLen(2),
-			)
-		},
-	},
+	// {
+	// 	desc: "fstree_nosync",
+	// 	create: func(dir string) common.Storage {
+	// 		return fstree.New(
+	// 			fstree.WithPath(dir),
+	// 			fstree.WithDepth(2),
+	// 			fstree.WithDirNameLen(2),
+	// 			fstree.WithNoSync(true),
+	// 		)
+	// 	},
+	// },
+	// {
+	// 	desc: "fstree_without_object_counter",
+	// 	create: func(dir string) common.Storage {
+	// 		return fstree.New(
+	// 			fstree.WithPath(dir),
+	// 			fstree.WithDepth(2),
+	// 			fstree.WithDirNameLen(2),
+	// 		)
+	// 	},
+	// },
 	{
 		desc: "fstree_with_object_counter",
 		create: func(dir string) common.Storage {
@@ -70,15 +69,15 @@ var storages = []storage{
 			)
 		},
 	},
-	{
-		desc: "blobovniczatree",
-		create: func(dir string) common.Storage {
-			return blobovniczatree.NewBlobovniczaTree(
-				context.Background(),
-				blobovniczatree.WithRootPath(dir),
-			)
-		},
-	},
+	// {
+	// 	desc: "blobovniczatree",
+	// 	create: func(dir string) common.Storage {
+	// 		return blobovniczatree.NewBlobovniczaTree(
+	// 			context.Background(),
+	// 			blobovniczatree.WithRootPath(dir),
+	// 		)
+	// 	},
+	// },
 }
 
 func BenchmarkSubstorageReadPerf(b *testing.B) {
@@ -88,12 +87,12 @@ func BenchmarkSubstorageReadPerf(b *testing.B) {
 		objGen  func() testutil.ObjectGenerator
 		addrGen func() testutil.AddressGenerator
 	}{
-		{
-			desc:    "seq100",
-			size:    10000,
-			objGen:  func() testutil.ObjectGenerator { return &testutil.SeqObjGenerator{ObjSize: 100} },
-			addrGen: func() testutil.AddressGenerator { return &testutil.SeqAddrGenerator{MaxID: 100} },
-		},
+		// {
+		// 	desc:    "seq100",
+		// 	size:    10000,
+		// 	objGen:  func() testutil.ObjectGenerator { return &testutil.SeqObjGenerator{ObjSize: 100} },
+		// 	addrGen: func() testutil.AddressGenerator { return &testutil.SeqAddrGenerator{MaxID: 100} },
+		// },
 		{
 			desc:    "rand100",
 			size:    10000,
@dstepanov-yadro good idea! Here are the results for `BenchmarkSubstorageReadPerf` from the `blobstor/perf_test.go`. I have intentionally stripped some of the benchmarks because they are too slow. `old` is master, `new` is this PR. The improvements are there both in terms of allocations and speed. I expect gains to be even bigger for big objects. ``` goos: linux goarch: amd64 pkg: git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor cpu: 11th Gen Intel(R) Core(TM) i5-1135G7 @ 2.40GHz │ old │ new │ │ sec/op │ sec/op vs base │ SubstorageReadPerf/memstore-rand100-8 1108.0n ± 1% 986.3n ± 0% -10.98% (p=0.000 n=10) SubstorageReadPerf/fstree_with_object_counter-rand100-8 2.770µ ± 2% 2.378µ ± 1% -14.15% (p=0.000 n=10) geomean 1.752µ 1.531µ -12.58% │ old │ new │ │ B/op │ B/op vs base │ SubstorageReadPerf/memstore-rand100-8 1552.0 ± 0% 896.0 ± 0% -42.27% (p=0.000 n=10) SubstorageReadPerf/fstree_with_object_counter-rand100-8 3.257Ki ± 0% 2.624Ki ± 1% -19.44% (p=0.000 n=10) geomean 2.222Ki 1.515Ki -31.80% │ old │ new │ │ allocs/op │ allocs/op vs base │ SubstorageReadPerf/memstore-rand100-8 27.00 ± 0% 21.00 ± 0% -22.22% (p=0.000 n=10) SubstorageReadPerf/fstree_with_object_counter-rand100-8 46.00 ± 0% 40.00 ± 0% -13.04% (p=0.000 n=10) geomean 35.24 28.98 -17.76% ``` The diff I have applied. ```diff diff --git a/pkg/local_object_storage/blobstor/perf_test.go b/pkg/local_object_storage/blobstor/perf_test.go index 501c95a1dc..e9035e53ed 100644 --- a/pkg/local_object_storage/blobstor/perf_test.go +++ b/pkg/local_object_storage/blobstor/perf_test.go @@ -5,7 +5,6 @@ import ( "fmt" "testing" - "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor/blobovniczatree" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor/common" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor/fstree" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor/memstore" @@ -38,27 +37,27 @@ var storages = []storage{ return memstore.New() }, }, - { - desc: "fstree_nosync", - create: func(dir string) common.Storage { - return fstree.New( - fstree.WithPath(dir), - fstree.WithDepth(2), - fstree.WithDirNameLen(2), - fstree.WithNoSync(true), - ) - }, - }, - { - desc: "fstree_without_object_counter", - create: func(dir string) common.Storage { - return fstree.New( - fstree.WithPath(dir), - fstree.WithDepth(2), - fstree.WithDirNameLen(2), - ) - }, - }, + // { + // desc: "fstree_nosync", + // create: func(dir string) common.Storage { + // return fstree.New( + // fstree.WithPath(dir), + // fstree.WithDepth(2), + // fstree.WithDirNameLen(2), + // fstree.WithNoSync(true), + // ) + // }, + // }, + // { + // desc: "fstree_without_object_counter", + // create: func(dir string) common.Storage { + // return fstree.New( + // fstree.WithPath(dir), + // fstree.WithDepth(2), + // fstree.WithDirNameLen(2), + // ) + // }, + // }, { desc: "fstree_with_object_counter", create: func(dir string) common.Storage { @@ -70,15 +69,15 @@ var storages = []storage{ ) }, }, - { - desc: "blobovniczatree", - create: func(dir string) common.Storage { - return blobovniczatree.NewBlobovniczaTree( - context.Background(), - blobovniczatree.WithRootPath(dir), - ) - }, - }, + // { + // desc: "blobovniczatree", + // create: func(dir string) common.Storage { + // return blobovniczatree.NewBlobovniczaTree( + // context.Background(), + // blobovniczatree.WithRootPath(dir), + // ) + // }, + // }, } func BenchmarkSubstorageReadPerf(b *testing.B) { @@ -88,12 +87,12 @@ func BenchmarkSubstorageReadPerf(b *testing.B) { objGen func() testutil.ObjectGenerator addrGen func() testutil.AddressGenerator }{ - { - desc: "seq100", - size: 10000, - objGen: func() testutil.ObjectGenerator { return &testutil.SeqObjGenerator{ObjSize: 100} }, - addrGen: func() testutil.AddressGenerator { return &testutil.SeqAddrGenerator{MaxID: 100} }, - }, + // { + // desc: "seq100", + // size: 10000, + // objGen: func() testutil.ObjectGenerator { return &testutil.SeqObjGenerator{ObjSize: 100} }, + // addrGen: func() testutil.AddressGenerator { return &testutil.SeqAddrGenerator{MaxID: 100} }, + // }, { desc: "rand100", size: 10000, ```
dstepanov-yadro approved these changes 2024-08-21 11:23:00 +00:00
fyrchik merged commit 7bca428db0 into master 2024-08-22 07:17:43 +00:00
fyrchik referenced this pull request from a commit 2024-08-22 07:17:44 +00:00
fyrchik deleted branch update-marshaling 2024-08-22 07:17:48 +00:00
Sign in to join this conversation.
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#1322
No description provided.