Currently, tree insertion keeps track of children nodes in a sorted slice and new children nodes are inserted in order. The complexity of insertion is thus O(n) in the worst case. Switching to a balanced binary search tree, this operation could become O(log n), so this should be, in theory, an improvement.
Currently, tree insertion keeps track of children nodes in a sorted slice and new children nodes are inserted in order. The complexity of insertion is thus
O(n)
in the worst case. Switching to a balanced binary search tree, this operation could becomeO(log n)
, so this should be, in theory, an improvement.As discussed in https://github.com/pyroscope-io/pyroscope/pull/773#discussion_r794604814, tree insertion is in the hot path, making this potential improvement interesting to scale the number of applications.