-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NonderterministicFastCommit commits changes in nondeterministic order. It can be used by migration program when ordering isn't required. │ before.txt │ after.txt │ │ sec/op │ sec/op vs base │ StorageFastCommit/10-12 89.72µ ± 4% 57.50µ ± 3% -35.92% (p=0.000 n=10) StorageFastCommit/100-12 118.9µ ± 1% 116.0µ ± 4% ~ (p=0.436 n=10) StorageFastCommit/1000-12 4.086m ± 5% 2.397m ± 25% -41.35% (p=0.000 n=10) StorageFastCommit/10000-12 12.629m ± 4% 9.857m ± 3% -21.95% (p=0.000 n=10) StorageFastCommit/100000-12 102.73m ± 0% 72.26m ± 1% -29.66% (p=0.000 n=10) StorageFastCommit/1000000-12 1.544 ± 2% 1.141 ± 2% -26.09% (p=0.000 n=10) geomean 6.661m 4.848m -27.21% │ before.txt │ after.txt │ │ B/op │ B/op vs base │ StorageFastCommit/10-12 28.92Ki ± 0% 28.05Ki ± 0% -3.00% (p=0.000 n=10) StorageFastCommit/100-12 286.4Ki ± 0% 278.6Ki ± 0% -2.71% (p=0.000 n=10) StorageFastCommit/1000-12 3.009Mi ± 0% 2.901Mi ± 0% -3.58% (p=0.000 n=10) StorageFastCommit/10000-12 28.65Mi ± 0% 27.79Mi ± 0% -2.98% (p=0.000 n=10) StorageFastCommit/100000-12 278.8Mi ± 0% 271.1Mi ± 0% -2.75% (p=0.000 n=10) StorageFastCommit/1000000-12 2.923Gi ± 0% 2.821Gi ± 0% -3.49% (p=0.000 n=10) geomean 9.101Mi 8.820Mi -3.09% │ before.txt │ after.txt │ │ allocs/op │ allocs/op vs base │ StorageFastCommit/10-12 219.0 ± 0% 205.0 ± 0% -6.39% (p=0.000 n=10) StorageFastCommit/100-12 1.980k ± 0% 1.875k ± 0% -5.30% (p=0.000 n=10) StorageFastCommit/1000-12 19.23k ± 0% 18.23k ± 0% -5.22% (p=0.000 n=10) StorageFastCommit/10000-12 191.1k ± 0% 181.1k ± 0% -5.24% (p=0.000 n=10) StorageFastCommit/100000-12 1.918M ± 0% 1.816M ± 0% -5.30% (p=0.000 n=10) StorageFastCommit/1000000-12 19.15M ± 0% 18.15M ± 0% -5.22% (p=0.000 n=10) geomean 62.31k 58.91k -5.45%
- Loading branch information
Showing
3 changed files
with
472 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
/* | ||
* Atree - Scalable Arrays and Ordered Maps | ||
* | ||
* Copyright Dapper Labs, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package atree | ||
|
||
import ( | ||
"encoding/binary" | ||
"math/rand" | ||
"runtime" | ||
"strconv" | ||
"testing" | ||
|
||
"github.com/fxamacker/cbor/v2" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func benchmarkFastCommit(b *testing.B, seed int64, numberOfSlabs int) { | ||
r := rand.New(rand.NewSource(seed)) | ||
|
||
encMode, err := cbor.EncOptions{}.EncMode() | ||
require.NoError(b, err) | ||
|
||
decMode, err := cbor.DecOptions{}.DecMode() | ||
require.NoError(b, err) | ||
|
||
slabs := make([]Slab, numberOfSlabs) | ||
for i := 0; i < numberOfSlabs; i++ { | ||
addr := generateRandomAddress(r) | ||
|
||
var index SlabIndex | ||
binary.BigEndian.PutUint64(index[:], uint64(i)) | ||
|
||
id := SlabID{addr, index} | ||
|
||
slabs[i] = generateLargeSlab(id) | ||
} | ||
|
||
b.Run(strconv.Itoa(numberOfSlabs), func(b *testing.B) { | ||
for i := 0; i < b.N; i++ { | ||
b.StopTimer() | ||
|
||
baseStorage := NewInMemBaseStorage() | ||
storage := NewPersistentSlabStorage(baseStorage, encMode, decMode, nil, nil) | ||
|
||
for _, slab := range slabs { | ||
err = storage.Store(slab.SlabID(), slab) | ||
require.NoError(b, err) | ||
} | ||
|
||
b.StartTimer() | ||
|
||
err := storage.FastCommit(runtime.NumCPU()) | ||
require.NoError(b, err) | ||
} | ||
}) | ||
} | ||
|
||
func benchmarkNondeterministicFastCommit(b *testing.B, seed int64, numberOfSlabs int) { | ||
r := rand.New(rand.NewSource(seed)) | ||
|
||
encMode, err := cbor.EncOptions{}.EncMode() | ||
require.NoError(b, err) | ||
|
||
decMode, err := cbor.DecOptions{}.DecMode() | ||
require.NoError(b, err) | ||
|
||
slabs := make([]Slab, numberOfSlabs) | ||
for i := 0; i < numberOfSlabs; i++ { | ||
addr := generateRandomAddress(r) | ||
|
||
var index SlabIndex | ||
binary.BigEndian.PutUint64(index[:], uint64(i)) | ||
|
||
id := SlabID{addr, index} | ||
|
||
slabs[i] = generateLargeSlab(id) | ||
} | ||
|
||
b.Run(strconv.Itoa(numberOfSlabs), func(b *testing.B) { | ||
for i := 0; i < b.N; i++ { | ||
b.StopTimer() | ||
|
||
baseStorage := NewInMemBaseStorage() | ||
storage := NewPersistentSlabStorage(baseStorage, encMode, decMode, nil, nil) | ||
|
||
for _, slab := range slabs { | ||
err = storage.Store(slab.SlabID(), slab) | ||
require.NoError(b, err) | ||
} | ||
|
||
b.StartTimer() | ||
|
||
err := storage.NonderterministicFastCommit(runtime.NumCPU()) | ||
require.NoError(b, err) | ||
} | ||
}) | ||
} | ||
|
||
func BenchmarkStorageFastCommit(b *testing.B) { | ||
fixedSeed := int64(1234567) // intentionally use fixed constant rather than time, etc. | ||
|
||
benchmarkFastCommit(b, fixedSeed, 10) | ||
benchmarkFastCommit(b, fixedSeed, 100) | ||
benchmarkFastCommit(b, fixedSeed, 1_000) | ||
benchmarkFastCommit(b, fixedSeed, 10_000) | ||
benchmarkFastCommit(b, fixedSeed, 100_000) | ||
benchmarkFastCommit(b, fixedSeed, 1_000_000) | ||
} | ||
|
||
func BenchmarkStorageNondeterministicFastCommit(b *testing.B) { | ||
fixedSeed := int64(1234567) // intentionally use fixed constant rather than time, etc. | ||
|
||
benchmarkNondeterministicFastCommit(b, fixedSeed, 10) | ||
benchmarkNondeterministicFastCommit(b, fixedSeed, 100) | ||
benchmarkNondeterministicFastCommit(b, fixedSeed, 1_000) | ||
benchmarkNondeterministicFastCommit(b, fixedSeed, 10_000) | ||
benchmarkNondeterministicFastCommit(b, fixedSeed, 100_000) | ||
benchmarkNondeterministicFastCommit(b, fixedSeed, 1_000_000) | ||
} |
Oops, something went wrong.