mila-iqia/bcachefs

get next is O(d) because of nested Btrees

Closed this issue · 1 comments

I think there is a potential issue with the iterator when it traverse nested Btree Node
the complexity to fetch next value is O(d) where d is the depth of the Btree Node because we have to traverse the linked list of iterators.

I think if we reverse the list and make it a stack instead it would get O(1)
You just pick the latest added until its end and pop it.

* BCacheFS_iter_make_dirent
* BCacheFS_iter_next

Olexa pointed out that

By definition the BcacheFS filesystem's B+trees are maximum 4-level deep.Therefore we can assume O(d) = O(1) constant.