Commit f7e23ed8 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 9ccda1cc
......@@ -143,7 +143,9 @@ func zhash(ctx context.Context, url string, h hasher, useprefetch bool) (err err
}
}
// prefetchBlk prefetches block of 512 objects starting from xid
const nprefetch = 128 // XXX -> 512 ?
// prefetchBlk prefetches block of nprefetch objects starting from xid
//var tprevLoadBlkStart time.Time
prefetchBlk := func(ctx context.Context, xid zodb.Xid) {
if cache == nil {
......@@ -151,8 +153,7 @@ func zhash(ctx context.Context, url string, h hasher, useprefetch bool) (err err
}
//t1 := time.Now()
//for i := 0; i < 512; i++ {
for i := 0; i < 8; i++ {
for i := 0; i < nprefetch; i++ {
prefetch(ctx, xid)
xid.Oid++
}
......@@ -181,17 +182,14 @@ func zhash(ctx context.Context, url string, h hasher, useprefetch bool) (err err
//defer profile.Start(profile.CPUProfile).Stop()
}
for qqq := 0; qqq < 1; qqq++ {
tstart := time.Now()
h.Reset() // XXX temp
oid := zodb.Oid(0)
nread := 0
loop:
for {
xid := zodb.Xid{Oid: oid, XTid: zodb.XTid{Tid: before, TidBefore: true}}
//if xid.Oid % 512 == 0 {
if xid.Oid % 8 == 0 {
if xid.Oid % nprefetch == 0 {
prefetchBlk(ctx, xid)
}
buf, _, err := load(ctx, xid)
......@@ -220,11 +218,10 @@ loop:
x := "zhash.go"
if useprefetch {
x += " +prefetch"
x += fmt.Sprintf(" +prefetch%d", nprefetch)
}
fmt.Printf("%s:%x ; oid=0..%d nread=%d t=%s (%s / object) x=%s\n",
h.name, h.Sum(nil), oid-1, nread, δt, δt / time.Duration(oid), x) // XXX /oid cast ?
}
return nil
}
......@@ -121,36 +121,29 @@ def main():
last_tid = stor.lastTransaction()
before = p64(u64(last_tid) + 1)
for zzz in range(1):
tstart = time()
tstart = time()
# vvv h.reset() XXX temp
oid = 0
nread = 0
while 1:
try:
h = h.__class__()
except:
h = hashlib.new(h.name)
data, serial, _ = stor.loadBefore(p64(oid), before)
except POSKeyError:
break
oid = 0
nread = 0
while 1:
try:
data, serial, _ = stor.loadBefore(p64(oid), before)
except POSKeyError:
break
h.update(data)
h.update(data)
#print('%s @%s\tsha1: %s' % (oid, u64(serial), h.hexdigest()), file=sys.stderr)
#print('\tdata: %s' % (data.encode('hex'),), file=sys.stderr)
#print('%s @%s\tsha1: %s' % (oid, u64(serial), h.hexdigest()), file=sys.stderr)
#print('\tdata: %s' % (data.encode('hex'),), file=sys.stderr)
nread += len(data)
oid += 1
nread += len(data)
oid += 1
tend = time()
dt = tend - tstart
tend = time()
dt = tend - tstart
print('%s:%s ; oid=0..%d nread=%d t=%.3fs (%.1fμs / object) x=zhash.py' % \
(h.name, h.hexdigest(), oid-1, nread, dt, dt * 1E6 / oid))
print('%s:%s ; oid=0..%d nread=%d t=%.3fs (%.1fμs / object) x=zhash.py' % \
(h.name, h.hexdigest(), oid-1, nread, dt, dt * 1E6 / oid))
if __name__ == '__main__':
......
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