Skip to content

Comments

Fix ordering of debounced events#638

Merged
0xpr03 merged 2 commits intonotify-rs:mainfrom
dfaust:fix-event-ordering
Sep 14, 2024
Merged

Fix ordering of debounced events#638
0xpr03 merged 2 commits intonotify-rs:mainfrom
dfaust:fix-event-ordering

Conversation

@dfaust
Copy link
Member

@dfaust dfaust commented Sep 14, 2024

I wasn't able to reproduce the panic, but the new sort logic should fix the issue and it's also stable now.

We should release this fix as soon as possible.

Fixes #636.

@dfaust dfaust mentioned this pull request Sep 14, 2024
let min_time = events_by_path
.values()
.map(|events| events[0].time)
.min()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seem with that total algorithmic complexity has O(n^2). May be it is need to use binary heap or something like this to track min_time?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using BinaryHeap improves performance a bit. Especially in scenarios with many files.

I didn't commit the benchmark because I don't know if it's useful enough. But here are the results. Unfortunately they are a bit over the place, so I'm not sure how reliable they are:

sort-events/sort_events with 10 files and 100k events each
    new:   [328.05 ms 330.98 ms 334.31 ms]
    old:   [408.45 ms 453.59 ms 512.18 ms] +37.042%

sort-events/sort_events with 1k files and 1k events each
    new:   [398.06 ms 401.66 ms 405.87 ms]
    old:   [448.35 ms 454.64 ms 462.24 ms] +13.190%

sort-events/sort_events with 100k files and 10 events each
    new:   [841.49 ms 906.83 ms 1.0303 s]
    old:   aborted after 10 minutes

@0xpr03 0xpr03 merged commit 7b73ab3 into notify-rs:main Sep 14, 2024
rhizoome added a commit to rhizoome/gitbutler that referenced this pull request Apr 9, 2025
rhizoome added a commit to rhizoome/gitbutler that referenced this pull request Apr 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Panics with Rust 1.81.0

4 participants