From 5335e7089ea5d9b04e0992cab3355bd75a22646b Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Wed, 16 Aug 2023 12:28:19 +0300 Subject: [PATCH] [#615] pilorama: Speedup TestForest_ApplyRandom() Some of our pilorama tests fail on CI. The reasons are not obvious, but one possible improvement is using `WithNoSync` option for these. It should have much effect, because we are writing on the tmpfs, but doesn't hurt anyway. If I replace `t.TempDir()` with a local directory, test execution time goes down from 5s (sync) to 0.4s (nosync), which is the same time as with `t.TempDir()`. Maybe we have some strange CI configuration. ``` panic: test timed out after 10m0s running tests: TestForest_ApplyRandom (8m22s) TestForest_ApplyRandom/bbolt (8m21s) ... goroutine 170 [syscall]: syscall.Syscall(0xc000100000?, 0xc00047b758?, 0x6aff9a?, 0xc00041c1b0?) /opt/hostedtoolcache/go/1.20.7/x64/src/syscall/syscall_linux.go:69 +0x27 syscall.Fdatasync(0x9e35c0?) /opt/hostedtoolcache/go/1.20.7/x64/src/syscall/zsyscall_linux_amd64.go:418 +0x2a go.etcd.io/bbolt.fdatasync(0xc000189000?) ``` Signed-off-by: Evgenii Stratonikov --- pkg/local_object_storage/pilorama/forest_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/local_object_storage/pilorama/forest_test.go b/pkg/local_object_storage/pilorama/forest_test.go index 0e2dd5ccb..6f657873a 100644 --- a/pkg/local_object_storage/pilorama/forest_test.go +++ b/pkg/local_object_storage/pilorama/forest_test.go @@ -825,7 +825,7 @@ func testForestTreeParallelApply(t *testing.T, constructor func(t testing.TB, _ cid := cidtest.ID() treeID := "version" - expected := constructor(t) + expected := constructor(t, WithNoSync(true)) for i := range ops { require.NoError(t, expected.TreeApply(context.Background(), cid, treeID, &ops[i], false)) } @@ -834,7 +834,7 @@ func testForestTreeParallelApply(t *testing.T, constructor func(t testing.TB, _ // Shuffle random operations, leave initialization in place. r.Shuffle(len(ops), func(i, j int) { ops[i], ops[j] = ops[j], ops[i] }) - actual := constructor(t, WithMaxBatchSize(batchSize)) + actual := constructor(t, WithMaxBatchSize(batchSize), WithNoSync(true)) wg := new(sync.WaitGroup) ch := make(chan *Move) for i := 0; i < batchSize; i++ { @@ -870,7 +870,7 @@ func testForestTreeApplyRandom(t *testing.T, constructor func(t testing.TB, _ .. cid := cidtest.ID() treeID := "version" - expected := constructor(t) + expected := constructor(t, WithNoSync(true)) for i := range ops { require.NoError(t, expected.TreeApply(context.Background(), cid, treeID, &ops[i], false)) } @@ -880,7 +880,7 @@ func testForestTreeApplyRandom(t *testing.T, constructor func(t testing.TB, _ .. // Shuffle random operations, leave initialization in place. r.Shuffle(len(ops), func(i, j int) { ops[i], ops[j] = ops[j], ops[i] }) - actual := constructor(t) + actual := constructor(t, WithNoSync(true)) for i := range ops { require.NoError(t, actual.TreeApply(context.Background(), cid, treeID, &ops[i], false)) }