Skip to content

Comments

Simplify and optimize inotify and fanotify read_events APIs#2741

Open
sami-daniel wants to merge 1 commit intonix-rust:masterfrom
sami-daniel:master
Open

Simplify and optimize inotify and fanotify read_events APIs#2741
sami-daniel wants to merge 1 commit intonix-rust:masterfrom
sami-daniel:master

Conversation

@sami-daniel
Copy link

@sami-daniel sami-daniel commented Feb 14, 2026

What does this PR do

In both the inotify and fanotify read_events(...) APIs:

Remove logic with MaybeUninit + copy_nonoverlapping and use ptr::read_unaligned, leaving the code more concise and clean on both sides, without the redundant check using .min()

Use Vec::with_capacity(nread / size) instead of allocating empty space. Useful for increasing performance in case of event bursts. Allocates space to spare, but is still more performant than allocating almost empty space.

In inotify read_events:

Reduce the event name iteration window to the maximum byte size (which is event.len), without risking reading beyond the event name in any way and without needing to scan again using CStr::from_ptr and increasing perfomance

Checklist:

  • I have read CONTRIBUTING.md
  • I have written necessary tests and rustdoc comments
  • A change log has been added if this PR modifies nix's API

@sami-daniel sami-daniel marked this pull request as ready for review February 14, 2026 01:27
Remove logic with `MaybeUninit` + `copy_nonoverlapping` and use
`ptr::read_unaligned`, leaving the code more concise and clean on both
sides, without the redundant check using `.min()`

Use `Vec::with_capacity(nread / size)` instead of allocating empty space.
Useful for increasing performance in case of event bursts. Allocates
space to spare, but is still more performant than allocating almost empty
space.

Reduce the event name iteration window to the maximum byte size (which is
`event.len`), without risking reading beyond the event name in any way
and without needing to scan again using `CStr::from_ptr` and increasing
perfomance
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.

1 participant