Skip to content

Instantly share code, notes, and snippets.

View zsfelfoldi's full-sized avatar

Felföldi Zsolt zsfelfoldi

View GitHub Profile
// Copyright 2015 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
// The go-ethereum library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// The go-ethereum library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// Copyright 2015 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
// The go-ethereum library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// The go-ethereum library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// Copyright 2015 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
// The go-ethereum library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// The go-ethereum library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
@zsfelfoldi
zsfelfoldi / lc
Last active October 14, 2015 12:11
Instructions for trying the light client prototype
- download and compile my light branch:
https://github.com/zsfelfoldi/go-ethereum/tree/light
(better clone the entire branch, it will not work when pulled in current develop)
- run geth in light mode, with a new datadir and peer discovery disabled
./geth --mode "light" --datadir "~/.light" --nodiscover console
imported 965000 blocks in 7h7m22s
fetched 10000 headers in 2m14s
fetched 965000 headers in 4m31s
fefe@Fefe-ThinkPad-SL500:~/go-ethereum$ ./geth --datadir "~/.222" import "/media/fefe/My Book/blockchain"
I0405 04:05:20.301262 ethdb/database.go:88] Alloted 128MB cache and 1024 file handles to /home/fefe/.222/chaindata
I0405 04:05:20.934751 core/headerchain.go:93] WARNING: Wrote default ethereum genesis block
I0405 04:05:20.935057 core/blockchain.go:206] Last header: #0 [d4e56740…] TD=17179869184
I0405 04:05:20.935105 core/blockchain.go:207] Last block: #0 [d4e56740…] TD=17179869184
I0405 04:05:20.935129 core/blockchain.go:208] Fast block: #0 [d4e56740…] TD=17179869184
imported 965000 blocks in 4h18m58s
fetched 10000 headers in 1.8s
fetched 965000 headers in 57s
fefe@Fefe-ThinkPad-SL500:~/go-ethereum$ ./geth --datadir "~/.333" import "/media/fefe/My Book/blockchain"
I0405 16:04:40.803209 ethdb/database.go:82] Alloted 128MB cache and 1024 file handles to /home/fefe/.333/chaindata
I0405 16:04:41.456626 core/headerchain.go:93] WARNING: Wrote default ethereum genesis block
I0405 16:04:41.456945 core/blockchain.go:206] Last header: #0 [d4e56740…] TD=17179869184
I0405 16:04:41.456993 core/blockchain.go:207] Last block: #0 [d4e56740…] TD=17179869184
I0405 16:04:41.457017 core/blockchain.go:208] Fast block: #0 [d4e56740…] TD=17179869184
How to benchmark my proposed changes for block data db storage:
- export your chain data (preferably to a physical drive different from the one you put the chain db on)
- download my branch:
https://github.com/zsfelfoldi/go-ethereum/tree/chaindb
- set useNewDb in core/database_util.go to false
- compile
- import chain data (specify a new datadir)
- run "geth headerbenchmark" with the same datadir
- set useNewDb in core/database_util.go to true and repeat the last three steps
BenchmarkInsertChain_empty_memdb 5000 371519 ns/op 43341 B/op 603 allocs/op
BenchmarkInsertChain_empty_diskdb 3000 732071 ns/op 56835 B/op 683 allocs/op
BenchmarkInsertChain_valueTx_memdb 2000 669609 ns/op 82256 B/op 1284 allocs/op
BenchmarkInsertChain_valueTx_diskdb 2000 1137578 ns/op 98221 B/op 1361 allocs/op
BenchmarkInsertChain_valueTx_100kB_memdb 500 2586936 ns/op 933950 B/op 1280 allocs/op
BenchmarkInsertChain_valueTx_100kB_diskdb 100 11507311 ns/op 1854512 B/op 1385 allocs/op
BenchmarkInsertChain_uncles_memdb 2000 802834 ns/op 81055 B/op 1154 allocs/op
BenchmarkInsertChain_uncles_diskdb 2000 1443088 ns/op 95069 B/op 1231 allocs/op
BenchmarkInsertChain_ring200_memdb 5 286776384 ns/op 29705977 B/op 407193 allocs/op
BenchmarkInsertChain_ring200_diskdb 10 250175954 ns/op 30438291 B/op 412880 allocs/op
Benchmarking 100000 consecutive header reads from an existing "old style" database (found at DefaultDataDir/_old):
(note that the database being cached into memory either by leveldb or by the OS affects this test dramatically; this test has been carried out after a fresh system restart)
fefe@Fefe-ThinkPad-SL500:~/go-ethereum$ godep go test -v ./core -bench BenchmarkReadChain_old_header_100k -run XXX -cpuprofile old.prof
PASS
BenchmarkReadChain_old_header_100k-2 1 539808334396 ns/op
ok _/home/fefe/go-ethereum/core 540.260s
CPU profile top 100 nodes (both flat and cumulative are listed):
Benchmarking 100000 consecutive header reads from an existing "new style" database (found at DefaultDataDir/_new):
(note that the database being cached into memory either by leveldb or by the OS affects this test dramatically; this test has been carried out after a fresh system restart)
fefe@Fefe-ThinkPad-SL500:~/go-ethereum$ godep go test -v ./core -bench BenchmarkReadChain_new_header_100k -run XXX -cpuprofile new.prof
PASS
BenchmarkReadChain_new_header_100k-2 1 6754975060 ns/op
ok _/home/fefe/go-ethereum/core 7.218s
CPU profile top 100 nodes (both flat and cumulative are listed):