From 351910d1018468ca8b7a213052cb553f6f75af9a Mon Sep 17 00:00:00 2001 From: zelig Date: Sat, 7 Feb 2015 08:06:48 +0100 Subject: [PATCH] minor cleanup and remove very long benchmarks --- bzz/chunker.go | 14 +++++++------- bzz/chunker_test.go | 25 +++++++++++-------------- bzz/netstore.go | 11 ----------- 3 files changed, 18 insertions(+), 32 deletions(-) diff --git a/bzz/chunker.go b/bzz/chunker.go index c559a2e057..882a1beff1 100644 --- a/bzz/chunker.go +++ b/bzz/chunker.go @@ -110,7 +110,7 @@ func (self *TreeChunker) Init() { } self.hashSize = int64(self.HashFunc.New().Size()) self.chunkSize = self.hashSize * self.Branches - dpaLogger.Debugf("Chunker initialised: branches: %v, hashsize: %v, chunksize: %v, join timeout: %v , split timeout: %v", self.Branches, self.hashSize, self.chunkSize, self.JoinTimeout, self.SplitTimeout) + // dpaLogger.Debugf("Chunker initialised: branches: %v, hashsize: %v, chunksize: %v, join timeout: %v , split timeout: %v", self.Branches, self.hashSize, self.chunkSize, self.JoinTimeout, self.SplitTimeout) } @@ -173,7 +173,7 @@ func (self *TreeChunker) Split(key Key, data SectionReader, chunkC chan *Chunk) depth++ } - dpaLogger.Debugf("split request received for data (%v bytes, depth: %v)", size, depth) + // dpaLogger.Debugf("split request received for data (%v bytes, depth: %v)", size, depth) //launch actual recursive function passing the workgroup self.split(depth, treeSize/self.Branches, key, data, chunkC, rerrC, wg) @@ -209,7 +209,7 @@ func (self *TreeChunker) split(depth int, treeSize int64, key Key, data SectionR size := data.Size() var newChunk *Chunk var hash Key - dpaLogger.Debugf("depth: %v, max subtree size: %v, data size: %v", depth, treeSize, size) + // dpaLogger.Debugf("depth: %v, max subtree size: %v, data size: %v", depth, treeSize, size) for depth > 0 && size < treeSize { treeSize /= self.Branches @@ -219,7 +219,7 @@ func (self *TreeChunker) split(depth int, treeSize int64, key Key, data SectionR if depth == 0 { // leaf nodes -> content chunks hash = self.Hash(size, data) - dpaLogger.Debugf("content chunk: max subtree size: %v, data size: %v", treeSize, size) + // dpaLogger.Debugf("content chunk: max subtree size: %v, data size: %v", treeSize, size) newChunk = &Chunk{ Key: hash, Reader: data, @@ -228,7 +228,7 @@ func (self *TreeChunker) split(depth int, treeSize int64, key Key, data SectionR } else { // intermediate chunk containing child nodes hashes branches := int64((size-1)/treeSize) + 1 - dpaLogger.Debugf("intermediate node: setting branches: %v, depth: %v, max subtree size: %v, data size: %v", branches, depth, treeSize, size) + // dpaLogger.Debugf("intermediate node: setting branches: %v, depth: %v, max subtree size: %v, data size: %v", branches, depth, treeSize, size) var chunk []byte = make([]byte, branches*self.hashSize) var pos, i int64 @@ -369,7 +369,7 @@ func (self *TreeChunker) join(depth int, treeSize int64, key Key, chunkC chan *C var readerF func() (r LazySectionReader) var readerFs [](func() (r LazySectionReader)) branches := int64((chunk.Size-1)/treeSize) + 1 - dpaLogger.DebugDetailf("tree node - size %v, chunk size: %v, subtreeSize %v, branches %v", chunk.Size, chunk.Reader.Size(), treeSize, branches) + // dpaLogger.DebugDetailf("tree node - size %v, chunk size: %v, subtreeSize %v, branches %v", chunk.Size, chunk.Reader.Size(), treeSize, branches) // iterate through the chunk containing the keys of children // create lazy init functions that give back readers @@ -378,7 +378,7 @@ func (self *TreeChunker) join(depth int, treeSize int64, key Key, chunkC chan *C childKey = make([]byte, self.hashSize) // preallocate hashSize long slice for key // read the Hash of the subtree from the relevant section of the Chunk into the allocated byte slice in subtree.Key if _, err := chunk.Reader.ReadAt(childKey, i*self.hashSize); err != nil { - dpaLogger.DebugDetailf("Read error: %v", err) + // dpaLogger.DebugDetailf("Read error: %v", err) errC <- err break } diff --git a/bzz/chunker_test.go b/bzz/chunker_test.go index b7ddd47a58..fe347b2e94 100644 --- a/bzz/chunker_test.go +++ b/bzz/chunker_test.go @@ -196,20 +196,17 @@ func benchmarkSplitRandomData(n int, chunks int, t *testing.B) { } } -func BenchmarkJoinRandomData_100_2(t *testing.B) { benchmarkJoinRandomData(100, 3, t) } -func BenchmarkJoinRandomData_1000_2(t *testing.B) { benchmarkJoinRandomData(1000, 3, t) } -func BenchmarkJoinRandomData_10000_2(t *testing.B) { benchmarkJoinRandomData(10000, 3, t) } -func BenchmarkJoinRandomData_100000_2(t *testing.B) { benchmarkJoinRandomData(100000, 3, t) } -func BenchmarkJoinRandomData_1000000_2(t *testing.B) { benchmarkJoinRandomData(1000000, 3, t) } -func BenchmarkJoinRandomData_10000000_2(t *testing.B) { benchmarkJoinRandomData(10000000, 3, t) } -func BenchmarkJoinRandomData_100000000_2(t *testing.B) { benchmarkJoinRandomData(100000000, 3, t) } +func BenchmarkJoinRandomData_100_2(t *testing.B) { benchmarkJoinRandomData(100, 3, t) } +func BenchmarkJoinRandomData_1000_2(t *testing.B) { benchmarkJoinRandomData(1000, 3, t) } +func BenchmarkJoinRandomData_10000_2(t *testing.B) { benchmarkJoinRandomData(10000, 3, t) } +func BenchmarkJoinRandomData_100000_2(t *testing.B) { benchmarkJoinRandomData(100000, 3, t) } +func BenchmarkJoinRandomData_1000000_2(t *testing.B) { benchmarkJoinRandomData(1000000, 3, t) } -func BenchmarkSplitRandomData_100_2(t *testing.B) { benchmarkSplitRandomData(100, 3, t) } -func BenchmarkSplitRandomData_1000_2(t *testing.B) { benchmarkSplitRandomData(1000, 3, t) } -func BenchmarkSplitRandomData_10000_2(t *testing.B) { benchmarkSplitRandomData(10000, 3, t) } -func BenchmarkSplitRandomData_100000_2(t *testing.B) { benchmarkSplitRandomData(100000, 3, t) } -func BenchmarkSplitRandomData_1000000_2(t *testing.B) { benchmarkSplitRandomData(1000000, 3, t) } -func BenchmarkSplitRandomData_10000000_2(t *testing.B) { benchmarkSplitRandomData(10000000, 3, t) } -func BenchmarkSplitRandomData_100000000_2(t *testing.B) { benchmarkSplitRandomData(100000000, 3, t) } +func BenchmarkSplitRandomData_100_2(t *testing.B) { benchmarkSplitRandomData(100, 3, t) } +func BenchmarkSplitRandomData_1000_2(t *testing.B) { benchmarkSplitRandomData(1000, 3, t) } +func BenchmarkSplitRandomData_10000_2(t *testing.B) { benchmarkSplitRandomData(10000, 3, t) } +func BenchmarkSplitRandomData_100000_2(t *testing.B) { benchmarkSplitRandomData(100000, 3, t) } +func BenchmarkSplitRandomData_1000000_2(t *testing.B) { benchmarkSplitRandomData(1000000, 3, t) } +func BenchmarkSplitRandomData_10000000_2(t *testing.B) { benchmarkSplitRandomData(10000000, 3, t) } // go test -bench ./bzz -cpuprofile cpu.out -memprofile mem.out diff --git a/bzz/netstore.go b/bzz/netstore.go index 6babc6fbfe..f7b1ef5edd 100644 --- a/bzz/netstore.go +++ b/bzz/netstore.go @@ -1,16 +1,5 @@ package bzz -/* -TODO: -- put Data -> Reader logic to chunker -- clarify dpa / localStore / hive / netstore naming and division of labour and entry points for local/remote requests -- figure out if its a problem that peers on requester list may disconnect while searching -- Id (nonce/requester map key) should probs be random byte slice or (hash of) originator's address to avoid collisions -- rework protocol errors using errs after PR merged -- integrate cademlia as peer pool -- finish the net/dht logic, startSearch and storage -*/ - import ( "math/rand" "sync"