Refactor sign/verify message #8
Labels
No labels
P0
P1
P2
P3
good first issue
Infrastructure
blocked
bug
config
discussion
documentation
duplicate
enhancement
go
help wanted
internal
invalid
kludge
observability
perfomance
question
refactoring
wontfix
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: TrueCloudLab/frostfs-api-go#8
Loading…
Reference in a new issue
No description provided.
Delete branch "dstepanov-yadro/frostfs-api-go:feat/refactor-signservicemessage"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Speaking of buffers pool, do we need a local benchmark for this?
@ -17,1 +13,4 @@
var wrapperPool = sync.Pool{
New: func() any {
return &StableMarshalerWrapper{}
Can we instead just use
StableMarshalerWrapper
directly and make method receiver pointerless (it seems they already are)?Don't understand you. StableMarshalerWrapper is used to convert stableMarshaller interface to DataSource integface.
I've meant
&StableMarshalerWrapper{SM: msg}
allocates but withStableMarshalerWrapper{SM: msg}
we, probably, do not need pool at all.Fixed.
mb a separate commit for that then? freezed me a little when saw that change in the "Add buffer pool"
... or not according to @fyrchik's:
up to you then
I missed that part -- in
Drop marshaler wrapper pool
we actually also removed a pointer wrom the wrapper.@ -0,0 +10,4 @@
var buffersPool = sync.Pool{
New: func() any {
return &buffer{}
Why do you return
*buffer
and not[]byte
?This makes easier to create new buffer here:
It just creates a new slice in case of current capacity does not meet the requested size.
But how is
cap(buf) < size
andbuf = make...
different? Besides being able to implementfree
method on them (could be function as well).You are right. Fixed.
There are two benchmarks already (sign and verify) that use pool.
They are single-threaded now (and I think we need them written this way).
If using pool provides some improvements, could you attach benchmark diff to a commit message?
7f9809b7eb
to311ce95cb3
The last 4 commits are really a single commit -- "add buffer pool", can we squash them?
Introducing and dropping marshaler pool is not something we would like to see in history. May be we could mention about trying it in the PR message, though.
Adding a buffer pool and fixing it could become more readable too as an atomic change.
311ce95cb3
to18631efdaf
Done
@ -18,3 +18,3 @@
strategy:
matrix:
go: [ '1.17.x', '1.18.x', '1.19.x' ]
go: [ '1.18.x', '1.19.x', '1.20.x' ]
i think that should be either removed or changed in the same commit that updates
go
versionfixed
well, PR that removes that file has been merged first :)
@ -175,0 +47,4 @@
body := serviceMessageBody(v)
meta := v.GetMetaHeader()
header := v.GetVerificationHeader()
if err := signMessageParts(key, body, meta, header, header != nil, result); err != nil {
why do we pass both
header
andheader != nil
?because of go:
oh, it is an interface in the func's definition, missed that
@ -73,0 +79,4 @@
for i := 0; i < b.N; i++ {
b.StopTimer()
dec := new(accounting.Decimal)
why do we create the same message inside every bench cycle?
because sign methods creates origin at every call, so it's like matryoshka. so every cycle step signs not one message.
@ -0,0 +22,4 @@
func returnBufferToPool(buf []byte) {
if cap(buf) > poolSliceMaxSize {
buf = nil
is there any practical case when we put
nil
slice and it helps us?Fixed
18631efdaf
tofe59664de1
fe59664de1
to7655227773
7655227773
toec0d0274fa