mirror of
https://github.com/arnaucube/arbo.git
synced 2026-01-15 01:41:28 +01:00
Add CPU parallelization to buildTreBottomUp
buildTreeBottomUp splits the key-values into n Buckets (where n is the number of CPUs), in parallel builds a subtree for each bucket, once all the subtrees are built, uses the subtrees roots as keys for a new tree, which as result will have the complete Tree build from bottom to up, where until the log2(nCPU) level it has been computed in parallel. As result of this, the tree construction can be parallelized until almost the top level, almost dividing the time by the number of CPUs.
This commit is contained in:
11
tree_test.go
11
tree_test.go
@@ -342,7 +342,7 @@ func TestSetGetNLeafs(t *testing.T) {
|
||||
|
||||
n, err := tree.GetNLeafs()
|
||||
c.Assert(err, qt.IsNil)
|
||||
c.Assert(n, qt.Equals, uint64(0))
|
||||
c.Assert(n, qt.Equals, 0)
|
||||
|
||||
// 1024
|
||||
tree.tx, err = tree.db.NewTx()
|
||||
@@ -356,13 +356,16 @@ func TestSetGetNLeafs(t *testing.T) {
|
||||
|
||||
n, err = tree.GetNLeafs()
|
||||
c.Assert(err, qt.IsNil)
|
||||
c.Assert(n, qt.Equals, uint64(1024))
|
||||
c.Assert(n, qt.Equals, 1024)
|
||||
|
||||
// 2**64 -1
|
||||
tree.tx, err = tree.db.NewTx()
|
||||
c.Assert(err, qt.IsNil)
|
||||
|
||||
err = tree.setNLeafs(18446744073709551615)
|
||||
maxUint := ^uint(0)
|
||||
maxInt := int(maxUint >> 1)
|
||||
|
||||
err = tree.setNLeafs(maxInt)
|
||||
c.Assert(err, qt.IsNil)
|
||||
|
||||
err = tree.tx.Commit()
|
||||
@@ -370,7 +373,7 @@ func TestSetGetNLeafs(t *testing.T) {
|
||||
|
||||
n, err = tree.GetNLeafs()
|
||||
c.Assert(err, qt.IsNil)
|
||||
c.Assert(n, qt.Equals, uint64(18446744073709551615))
|
||||
c.Assert(n, qt.Equals, maxInt)
|
||||
}
|
||||
|
||||
func BenchmarkAdd(b *testing.B) {
|
||||
|
||||
Reference in New Issue
Block a user