Skip to content

Commit

Permalink
slicer: Skip object meta evaluation, if it is already done
Browse files Browse the repository at this point in the history
Updated after benchmark. For the header object we already made flushObjectMetadata step in _writeChild and don't need to compute this data again.

                                                 │    old.txt    │                new.txt                │
                                                 │    sec/op     │    sec/op     vs base                 │
SliceDataIntoObjects/slice_1-128/reader-16         106.71µ ± ∞ ¹   63.17µ ± ∞ ¹        ~ (p=1.000 n=1) ²
SliceDataIntoObjects/slice_1-128/writer-16         110.32µ ± ∞ ¹   65.66µ ± ∞ ¹        ~ (p=1.000 n=1) ²
SliceDataIntoObjects/slice_4-128/reader-16         109.83µ ± ∞ ¹   60.70µ ± ∞ ¹        ~ (p=1.000 n=1) ²
SliceDataIntoObjects/slice_4-128/writer-16         113.74µ ± ∞ ¹   63.26µ ± ∞ ¹        ~ (p=1.000 n=1) ²
SliceDataIntoObjects/slice_16-128/reader-16        108.11µ ± ∞ ¹   62.68µ ± ∞ ¹        ~ (p=1.000 n=1) ²
SliceDataIntoObjects/slice_16-128/writer-16        112.33µ ± ∞ ¹   66.46µ ± ∞ ¹        ~ (p=1.000 n=1) ²
SliceDataIntoObjects/slice_64-128/reader-16        113.14µ ± ∞ ¹   61.28µ ± ∞ ¹        ~ (p=1.000 n=1) ²
SliceDataIntoObjects/slice_64-128/writer-16        121.37µ ± ∞ ¹   65.47µ ± ∞ ¹        ~ (p=1.000 n=1) ²
SliceDataIntoObjects/slice_256-128/reader-16       107.53µ ± ∞ ¹   63.01µ ± ∞ ¹        ~ (p=1.000 n=1) ²
SliceDataIntoObjects/slice_256-128/writer-16        232.0µ ± ∞ ¹   252.4µ ± ∞ ¹        ~ (p=1.000 n=1) ²
SliceDataIntoObjects/slice_1024-128/reader-16      111.45µ ± ∞ ¹   65.12µ ± ∞ ¹        ~ (p=1.000 n=1) ²
SliceDataIntoObjects/slice_1024-128/writer-16       600.3µ ± ∞ ¹   636.6µ ± ∞ ¹        ~ (p=1.000 n=1) ²
SliceDataIntoObjects/slice_4096-128/reader-16      112.14µ ± ∞ ¹   63.38µ ± ∞ ¹        ~ (p=1.000 n=1) ²
SliceDataIntoObjects/slice_4096-128/writer-16       2.014m ± ∞ ¹   2.058m ± ∞ ¹        ~ (p=1.000 n=1) ²
SliceDataIntoObjects/slice_16384-128/reader-16     109.55µ ± ∞ ¹   62.51µ ± ∞ ¹        ~ (p=1.000 n=1) ²
SliceDataIntoObjects/slice_16384-128/writer-16      7.637m ± ∞ ¹   7.012m ± ∞ ¹        ~ (p=1.000 n=1) ²
SliceDataIntoObjects/slice_65536-128/reader-16     117.70µ ± ∞ ¹   65.71µ ± ∞ ¹        ~ (p=1.000 n=1) ²
SliceDataIntoObjects/slice_65536-128/writer-16      30.22m ± ∞ ¹   27.65m ± ∞ ¹        ~ (p=1.000 n=1) ²
SliceDataIntoObjects/slice_262144-128/reader-16    123.20µ ± ∞ ¹   73.14µ ± ∞ ¹        ~ (p=1.000 n=1) ²
SliceDataIntoObjects/slice_262144-128/writer-16     111.4m ± ∞ ¹   112.2m ± ∞ ¹        ~ (p=1.000 n=1) ²
SliceDataIntoObjects/slice_1048576-128/reader-16    194.2µ ± ∞ ¹   109.6µ ± ∞ ¹        ~ (p=1.000 n=1) ²
SliceDataIntoObjects/slice_1048576-128/writer-16    495.5m ± ∞ ¹   452.4m ± ∞ ¹        ~ (p=1.000 n=1) ²
geomean                                             459.0µ         312.0µ        -32.04%
¹ need >= 6 samples for confidence interval at level 0.95
² need >= 4 samples to detect a difference at alpha level 0.05

                                                 │    old.txt     │                new.txt                 │
                                                 │      B/op      │     B/op       vs base                 │
SliceDataIntoObjects/slice_1-128/reader-16         13.064Ki ± ∞ ¹   9.578Ki ± ∞ ¹        ~ (p=1.000 n=1) ²
SliceDataIntoObjects/slice_1-128/writer-16         14.283Ki ± ∞ ¹   9.469Ki ± ∞ ¹        ~ (p=1.000 n=1) ²
SliceDataIntoObjects/slice_4-128/reader-16         14.690Ki ± ∞ ¹   8.702Ki ± ∞ ¹        ~ (p=1.000 n=1) ²
SliceDataIntoObjects/slice_4-128/writer-16         15.910Ki ± ∞ ¹   8.593Ki ± ∞ ¹        ~ (p=1.000 n=1) ²
SliceDataIntoObjects/slice_16-128/reader-16        14.190Ki ± ∞ ¹   9.578Ki ± ∞ ¹        ~ (p=1.000 n=1) ²
SliceDataIntoObjects/slice_16-128/writer-16        15.347Ki ± ∞ ¹   9.469Ki ± ∞ ¹        ~ (p=1.000 n=1) ²
SliceDataIntoObjects/slice_64-128/reader-16        16.316Ki ± ∞ ¹   9.171Ki ± ∞ ¹        ~ (p=1.000 n=1) ²
SliceDataIntoObjects/slice_64-128/writer-16        17.536Ki ± ∞ ¹   9.062Ki ± ∞ ¹        ~ (p=1.000 n=1) ²
SliceDataIntoObjects/slice_256-128/reader-16       13.441Ki ± ∞ ¹   9.517Ki ± ∞ ¹        ~ (p=1.000 n=1) ²
SliceDataIntoObjects/slice_256-128/writer-16        30.20Ki ± ∞ ¹   33.24Ki ± ∞ ¹        ~ (p=1.000 n=1) ²
SliceDataIntoObjects/slice_1024-128/reader-16       15.70Ki ± ∞ ¹   10.80Ki ± ∞ ¹        ~ (p=1.000 n=1) ²
SliceDataIntoObjects/slice_1024-128/writer-16       77.03Ki ± ∞ ¹   85.03Ki ± ∞ ¹        ~ (p=1.000 n=1) ²
SliceDataIntoObjects/slice_4096-128/reader-16      15.710Ki ± ∞ ¹   9.529Ki ± ∞ ¹        ~ (p=1.000 n=1) ²
SliceDataIntoObjects/slice_4096-128/writer-16       247.3Ki ± ∞ ¹   262.5Ki ± ∞ ¹        ~ (p=1.000 n=1) ²
SliceDataIntoObjects/slice_16384-128/reader-16     14.766Ki ± ∞ ¹   8.751Ki ± ∞ ¹        ~ (p=1.000 n=1) ²
SliceDataIntoObjects/slice_16384-128/writer-16      926.9Ki ± ∞ ¹   964.9Ki ± ∞ ¹        ~ (p=1.000 n=1) ²
SliceDataIntoObjects/slice_65536-128/reader-16      16.69Ki ± ∞ ¹   10.26Ki ± ∞ ¹        ~ (p=1.000 n=1) ²
SliceDataIntoObjects/slice_65536-128/writer-16      3.569Mi ± ∞ ¹   3.729Mi ± ∞ ¹        ~ (p=1.000 n=1) ²
SliceDataIntoObjects/slice_262144-128/reader-16     17.28Ki ± ∞ ¹   11.10Ki ± ∞ ¹        ~ (p=1.000 n=1) ²
SliceDataIntoObjects/slice_262144-128/writer-16     13.88Mi ± ∞ ¹   15.03Mi ± ∞ ¹        ~ (p=1.000 n=1) ²
SliceDataIntoObjects/slice_1048576-128/reader-16    23.90Ki ± ∞ ¹   16.27Ki ± ∞ ¹        ~ (p=1.000 n=1) ²
SliceDataIntoObjects/slice_1048576-128/writer-16    57.21Mi ± ∞ ¹   59.78Mi ± ∞ ¹        ~ (p=1.000 n=1) ²
geomean                                             60.34Ki         44.76Ki        -25.82%
¹ need >= 6 samples for confidence interval at level 0.95
² need >= 4 samples to detect a difference at alpha level 0.05

                                                 │   old.txt    │                new.txt                │
                                                 │  allocs/op   │  allocs/op    vs base                 │
SliceDataIntoObjects/slice_1-128/reader-16          198.0 ± ∞ ¹    152.0 ± ∞ ¹        ~ (p=1.000 n=1) ²
SliceDataIntoObjects/slice_1-128/writer-16          220.0 ± ∞ ¹    151.0 ± ∞ ¹        ~ (p=1.000 n=1) ²
SliceDataIntoObjects/slice_4-128/reader-16          224.0 ± ∞ ¹    139.0 ± ∞ ¹        ~ (p=1.000 n=1) ²
SliceDataIntoObjects/slice_4-128/writer-16          246.0 ± ∞ ¹    138.0 ± ∞ ¹        ~ (p=1.000 n=1) ²
SliceDataIntoObjects/slice_16-128/reader-16         217.0 ± ∞ ¹    152.0 ± ∞ ¹        ~ (p=1.000 n=1) ²
SliceDataIntoObjects/slice_16-128/writer-16         238.0 ± ∞ ¹    151.0 ± ∞ ¹        ~ (p=1.000 n=1) ²
SliceDataIntoObjects/slice_64-128/reader-16         248.0 ± ∞ ¹    146.0 ± ∞ ¹        ~ (p=1.000 n=1) ²
SliceDataIntoObjects/slice_64-128/writer-16         270.0 ± ∞ ¹    145.0 ± ∞ ¹        ~ (p=1.000 n=1) ²
SliceDataIntoObjects/slice_256-128/reader-16        205.0 ± ∞ ¹    151.0 ± ∞ ¹        ~ (p=1.000 n=1) ²
SliceDataIntoObjects/slice_256-128/writer-16        460.0 ± ∞ ¹    513.0 ± ∞ ¹        ~ (p=1.000 n=1) ²
SliceDataIntoObjects/slice_1024-128/reader-16       236.0 ± ∞ ¹    169.0 ± ∞ ¹        ~ (p=1.000 n=1) ²
SliceDataIntoObjects/slice_1024-128/writer-16      1.194k ± ∞ ¹   1.349k ± ∞ ¹        ~ (p=1.000 n=1) ²
SliceDataIntoObjects/slice_4096-128/reader-16       236.0 ± ∞ ¹    151.0 ± ∞ ¹        ~ (p=1.000 n=1) ²
SliceDataIntoObjects/slice_4096-128/writer-16      3.860k ± ∞ ¹   4.207k ± ∞ ¹        ~ (p=1.000 n=1) ²
SliceDataIntoObjects/slice_16384-128/reader-16      225.0 ± ∞ ¹    139.0 ± ∞ ¹        ~ (p=1.000 n=1) ²
SliceDataIntoObjects/slice_16384-128/writer-16     14.49k ± ∞ ¹   15.59k ± ∞ ¹        ~ (p=1.000 n=1) ²
SliceDataIntoObjects/slice_65536-128/reader-16      253.0 ± ∞ ¹    161.0 ± ∞ ¹        ~ (p=1.000 n=1) ²
SliceDataIntoObjects/slice_65536-128/writer-16     57.18k ± ∞ ¹   61.78k ± ∞ ¹        ~ (p=1.000 n=1) ²
SliceDataIntoObjects/slice_262144-128/reader-16     260.0 ± ∞ ¹    175.0 ± ∞ ¹        ~ (p=1.000 n=1) ²
SliceDataIntoObjects/slice_262144-128/writer-16    221.6k ± ∞ ¹   248.2k ± ∞ ¹        ~ (p=1.000 n=1) ²
SliceDataIntoObjects/slice_1048576-128/reader-16    358.0 ± ∞ ¹    257.0 ± ∞ ¹        ~ (p=1.000 n=1) ²
SliceDataIntoObjects/slice_1048576-128/writer-16   909.7k ± ∞ ¹   983.5k ± ∞ ¹        ~ (p=1.000 n=1) ²
geomean                                             924.5          712.0        -22.99%
¹ need >= 6 samples for confidence interval at level 0.95
² need >= 4 samples to detect a difference at alpha level 0.05

Signed-off-by: Evgenii Baidakov <[email protected]>
  • Loading branch information
smallhive committed Jul 28, 2023
1 parent 0946418 commit 4bfec7b
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions object/slicer/slicer.go
Original file line number Diff line number Diff line change
Expand Up @@ -469,9 +469,19 @@ func flushObjectMetadata(signer neofscrypto.Signer, meta dynamicObjectMetadata,
}

func writeInMemObject(ctx context.Context, signer user.Signer, w ObjectWriter, header object.Object, payload []byte, meta dynamicObjectMetadata, session *session.Object) (oid.ID, error) {
id, err := flushObjectMetadata(signer, meta, &header)
if err != nil {
return id, err
var (
id oid.ID
err error
isSet bool
)

id, isSet = header.ID()
if !isSet || header.Signature() == nil {
id, err = flushObjectMetadata(signer, meta, &header)

if err != nil {
return id, err
}
}

var prm client.PrmObjectPutInit
Expand Down

0 comments on commit 4bfec7b

Please sign in to comment.