Merged
Conversation
fb14ba5 to
bff6b51
Compare
bff6b51 to
ef99154
Compare
The default second-resolution timestamps make it impossible to understand the timing of events. Use format_timestamp_micros() in both logger init paths (krun_set_log_level and krun_init_log) so log output shows microsecond precision. Assisted-by: Cursor/Claude Opus 4.6 Signed-off-by: Nir Soffer <nirsof@gmail.com>
Make the code more clear, easier to follow by handling error from kevent() early. Assisted-by: Cursor/Claude Opus 4.6 Signed-off-by: Nir Soffer <nirsof@gmail.com>
The repeated `i as usize` casts on every array access made the loop harder to read. Assisted-by: Cursor/Claude Opus 4.6 Signed-off-by: Nir Soffer <nirsof@gmail.com>
Previously we logged the raw event before processing it. Now we process
the event and log a more clear and easier to understand message. With
this can tell if we woke up for READ or WRITE event and we the log make
the values more clear.
Example logs:
[2026-02-26T18:28:23.856913Z DEBUG utils::macos::epoll] kevent: WRITE fd=3 data=66560
[2026-02-26T18:28:23.856923Z DEBUG utils::macos::epoll] kevent: READ fd=3 data=3539700
[2026-02-26T18:28:23.859383Z DEBUG utils::macos::epoll] kevent: READ fd=83 data=8
Assisted-by: Cursor/Claude Opus 4.6
Signed-off-by: Nir Soffer <nirsof@gmail.com>
ef99154 to
99adc35
Compare
Collaborator
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request provides a good cleanup of the wait() function in the macOS epoll shim, enhancing readability and debuggability. The changes, such as returning early on errors and improving log messages, are positive improvements. Additionally, enabling microsecond-precision timestamps for logging is a valuable addition. I have one suggestion to refactor the new event_name function to be more idiomatic and maintainable.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Clean up the
wait()function in the macOS epoll/kevent shim to make iteasier to read and debug.
Changes
Return early on errors -- handle kevent() errors upfront instead
of matching at the end, making the flow clearer.
Cast kevent count to usize before the loop -- eliminates repeated
i as usizecasts on every array access.Improve kevent debug log -- log processed event info (READ/WRITE,
fd, data) instead of the raw kevent struct, making debug output
immediately useful.
Example logs
Includes the timestamp commit from #556 for better logging.