Commit 65cfa007 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent bb90dc01
// Copyright (C) 2017-2019 Nexedi SA and Contributors. // Copyright (C) 2017-2020 Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com> // Kirill Smelkov <kirr@nexedi.com>
// //
// This program is free software: you can Use, Study, Modify and Redistribute // This program is free software: you can Use, Study, Modify and Redistribute
...@@ -38,10 +38,9 @@ import ( ...@@ -38,10 +38,9 @@ import (
"testing" "testing"
"time" "time"
"golang.org/x/sync/errgroup"
"lab.nexedi.com/kirr/go123/prog" "lab.nexedi.com/kirr/go123/prog"
"lab.nexedi.com/kirr/go123/xerr" "lab.nexedi.com/kirr/go123/xerr"
"lab.nexedi.com/kirr/go123/xsync"
"lab.nexedi.com/kirr/neo/go/internal/log" "lab.nexedi.com/kirr/neo/go/internal/log"
"lab.nexedi.com/kirr/neo/go/internal/task" "lab.nexedi.com/kirr/neo/go/internal/task"
...@@ -323,14 +322,14 @@ func zwrk(ctx context.Context, url string, nwrk int, h hasher, bench, check stri ...@@ -323,14 +322,14 @@ func zwrk(ctx context.Context, url string, nwrk int, h hasher, bench, check stri
// benchmark parallel loads // benchmark parallel loads
defer task.Runningf(&ctx, "zwrk-%d/bench", nwrk)(&err) defer task.Runningf(&ctx, "zwrk-%d/bench", nwrk)(&err)
r := testing.Benchmark(func (b *testing.B) { r := testing.Benchmark(func (b *testing.B) {
wg, ctx := errgroup.WithContext(ctx) wg := xsync.NewWorkGroup(ctx)
var n int64 var n int64
for i := 0; i < nwrk; i++ { for i := 0; i < nwrk; i++ {
stor := storv[i] stor := storv[i]
oid := zodb.Oid(0) oid := zodb.Oid(0)
wg.Go(func() error { wg.Go(func(ctx context.Context) error {
for { for {
n := atomic.AddInt64(&n, +1) n := atomic.AddInt64(&n, +1)
if n >= int64(b.N) { if n >= int64(b.N) {
...@@ -383,10 +382,10 @@ func zwrkPreconnect(ctx context.Context, url string, at zodb.Tid, nwrk int) (_ [ ...@@ -383,10 +382,10 @@ func zwrkPreconnect(ctx context.Context, url string, at zodb.Tid, nwrk int) (_ [
defer task.Runningf(&ctx, "zwrk-%d/preconnect", nwrk)(&err) defer task.Runningf(&ctx, "zwrk-%d/preconnect", nwrk)(&err)
storv := make([]zodb.IStorage, nwrk) storv := make([]zodb.IStorage, nwrk)
wg, ctx := errgroup.WithContext(ctx) wg := xsync.NewWorkGroup(ctx)
for i := 0; i < nwrk; i++ { for i := 0; i < nwrk; i++ {
i := i i := i
wg.Go(func() error { wg.Go(func(ctx context.Context) error {
// open storage without caching - we need to take // open storage without caching - we need to take
// latency of every request into account, and a cache // latency of every request into account, and a cache
// could be inhibiting (e.g. making significantly // could be inhibiting (e.g. making significantly
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment