cmd, consensus: add option to disable mmap for DAG caches/datasets (#20484)
* cmd, consensus: add option to disable mmap for DAG caches/datasets * consensus: add benchmarks for mmap with/with lock
This commit is contained in:
@ -729,7 +729,7 @@ func TestConcurrentDiskCacheGeneration(t *testing.T) {
|
||||
|
||||
go func(idx int) {
|
||||
defer pend.Done()
|
||||
ethash := New(Config{cachedir, 0, 1, "", 0, 0, ModeNormal, nil}, nil, false)
|
||||
ethash := New(Config{cachedir, 0, 1, false, "", 0, 0, false, ModeNormal, nil}, nil, false)
|
||||
defer ethash.Close()
|
||||
if err := ethash.VerifySeal(nil, block.Header()); err != nil {
|
||||
t.Errorf("proc %d: block verification failed: %v", idx, err)
|
||||
@ -787,3 +787,28 @@ func BenchmarkHashimotoFullSmall(b *testing.B) {
|
||||
hashimotoFull(dataset, hash, 0)
|
||||
}
|
||||
}
|
||||
|
||||
func benchmarkHashimotoFullMmap(b *testing.B, name string, lock bool) {
|
||||
b.Run(name, func(b *testing.B) {
|
||||
tmpdir, err := ioutil.TempDir("", "ethash-test")
|
||||
if err != nil {
|
||||
b.Fatal(err)
|
||||
}
|
||||
defer os.RemoveAll(tmpdir)
|
||||
|
||||
d := &dataset{epoch: 0}
|
||||
d.generate(tmpdir, 1, lock, false)
|
||||
var hash [common.HashLength]byte
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
binary.PutVarint(hash[:], int64(i))
|
||||
hashimotoFull(d.dataset, hash[:], 0)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// Benchmarks the full verification performance for mmap
|
||||
func BenchmarkHashimotoFullMmap(b *testing.B) {
|
||||
benchmarkHashimotoFullMmap(b, "WithLock", true)
|
||||
benchmarkHashimotoFullMmap(b, "WithoutLock", false)
|
||||
}
|
||||
|
Reference in New Issue
Block a user