Skip to content

Conversation

@geky
Copy link
Member

@geky geky commented Apr 26, 2023

See #746

I accidentally merged the previous PR into the wrong branch. It doesn't look like GitHub has an option to reopen a merged PR, so creating a new PR to merge this in with CI correctly.

The previous cycle detection algorithm (a naive check against the largest
possible tail list) is simple and gets the job done, but has the potential to
take a very long time on disks with many blocks. Brent's algorithm, on
the other hand, takes at most 2x the number of blocks in the tail list.

Originally naive cycle detection was chosen over Floyd's algorithm to
avoid the extra complexity of managing two desynced traversals for every
traversal of the tail list, but Brent's algorithm is very well suited for our
use case, requiring only we keep track of an additional mdir pointer on the
stack as we traverse.
@geky geky added this to the v2.6 milestone Apr 26, 2023
@geky geky changed the title Adopted Brent's algorithm for cycle detection Adopt Brent's algorithm for cycle detection Apr 26, 2023
@geky geky merged commit 2a18e03 into devel Apr 26, 2023
@geky geky mentioned this pull request May 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants