JuliaCollections / JuliaCollections/DataStructures.jl

In indexing data, RTtree search may be far inferior to AVLTree

Open
#724 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
745
Forks
261
PR merge metrics
No merged PRs in 30d

Description

I had done some tests to find out the performance of indexing data using RBTree or AVLTree,
the results is following:


rbtree = RBTree{Int}()
avltree = AVLTree{Int}()
sets = rand(collect(1:10^6), 10000)

for k in sets
   insert!(rbtree, k)
end


for k in sets
   insert!(avltree, k)
end

testset = collect(1:10^6)
ind = collect(1:9000)

@benchmark rbtree[rand(ind)]

BenchmarkTools.Trial: 
  memory estimate:  2.44 MiB
  allocs estimate:  27788
  --------------
  minimum time:     3.007 ms (0.00% GC)
  median time:      3.379 ms (0.00% GC)
  mean time:        3.816 ms (7.58% GC)
  maximum time:     18.757 ms (61.41% GC)
  --------------
  samples:          1306
  evals/sample:     1



@benchmark avltree[rand(ind)]
BenchmarkTools.Trial: 
  memory estimate:  86 bytes
  allocs estimate:  5
  --------------
  minimum time:     924.000 ns (0.00% GC)
  median time:      1.114 μs (0.00% GC)
  mean time:        1.191 μs (0.00% GC)
  maximum time:     4.403 μs (0.00% GC)
  --------------
  samples:          10000
  evals/sample:     14

I want to know why RBTree is so ineffecient, that is so weird!

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the RBTree and AVLTree lookup benchmarks from the issue with the provided Julia snippets. Then inspect the RBTree and AVLTree implementations and compare their lookup paths and allocations. Done means identifying the cause of the performance gap and documenting or correcting it with a confirming benchmark.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.