diff --git a/bench/append_requestor.go b/bench/append_requestor.go index 04db12a..1699d42 100644 --- a/bench/append_requestor.go +++ b/bench/append_requestor.go @@ -131,19 +131,12 @@ func (r *appendRequester) Setup() error { return err } } - if r.opts.truncatePeriod == 0 { - // Now truncate all, but one of those back out. We leave one to be more - // realistic since raft always leaves some recent logs. Note r.index is - // already at the next index after the one we just wrote so the inclusive - // delete range is not one but two before that to leave the one before - // intact. - fmt.Fprintf(r.output, "Truncating 1 - %d\n", r.index-2) - err := r.store.DeleteRange(1, r.index-2) - if err != nil { - return err - } - } else { - fmt.Fprintf(r.output, "Done preloading, will leave truncate for background process\n") + + // Now truncate back to trailingLogs. + fmt.Fprintf(r.output, "Truncating 1 - %d\n", r.index-uint64(r.opts.truncateTrailingLogs)) + err := r.store.DeleteRange(1, r.index-uint64(r.opts.truncateTrailingLogs)) + if err != nil { + return err } r.dumpStats() } diff --git a/bench/main.go b/bench/main.go index 904de24..0749fad 100644 --- a/bench/main.go +++ b/bench/main.go @@ -82,6 +82,12 @@ func main() { } } } + + // Make the results dir if it doesn't exist + if err := os.MkdirAll(filepath.Join(o.dir, filepath.Dir(outFileName(o, "blah"))), 0755); err != nil { + panic(err) + } + r := &appendRequesterFactory{ opts: o, output: teeOut, @@ -104,7 +110,7 @@ func outFileName(o opts, suffix string) string { if o.version == "bolt" && o.noFreelistSync { version += "-nfls" } - return fmt.Sprintf("bench-result-%s-s%d-n%d-r%d-seg%dm-pre%d-trail%d-tp%s-%s-%s.txt", + return fmt.Sprintf("bench-result-%s-s%d-n%d-r%d-seg%dm-pre%d-trail%d-tp%s/%s-%s.txt", o.duration, o.logSize, o.batchSize, o.rate, o.segSize, o.preLoadN, o.truncateTrailingLogs, o.truncatePeriod, version, suffix) }