🌗 使用 kqueue 偵測 macOS 上的檔案變更
➤ 從原理到實作:深度剖析 macOS 的檔案事件通知機制
https://www.vegardstikbakke.com/kqueue/
本文作者分享了他在開發自動化工具 `reload` 時的心路歷程,旨在擺脫對大型第三方函式庫的依賴,轉而深入理解 macOS 核心的 `kqueue` 機制。文章詳細解析瞭如何利用 `EVFILT_VNODE` 濾鏡與 `NOTE_WRITE` 事件來監控檔案變更,並透過 C 語言實作原型驗證邏輯。隨後,作者展示瞭如何將此機制整合進 Go 語言程式中,並特別強調了處理檔案描述符(File Descriptor)洩漏的關鍵技巧——使用 `O_CLOEXEC` 確保子行程執行時能正確關閉這些監控資源。
+ 這篇文章非常實用,對於想要深入瞭解 macOS 底層開發的開發者來說,直接操作 `kqueue` 比起使用黑盒子的 `fsnotify` 能獲得更精準的控制。
+ `O_CLOEXEC` 的處理確實是這類監控工具最容易被忽
#macOS #kqueue #系統程式設計 #Go #檔案監控
Detecting file changes on macOS with kqueue — Vegard Stikbakke

👨‍💻💾 Oh, you need to reinvent the wheel for detecting file changes on macOS? 🙄 Congrats on discovering #kqueue, the tool that's literally older than your dev career! But hey, at least you got a blog post out of it. 🚀🎉
https://www.vegardstikbakke.com/kqueue/ #reinventthewheel #macOS #filechanges #devlife #blogpost #techhumor #HackerNews #ngated
Detecting file changes on macOS with kqueue — Vegard Stikbakke

Detecting file changes on macOS with kqueue — Vegard Stikbakke

Ah, the classic tale of reinventing the wheel 🛞! Behold, the famed network server pattern, dear reader: marvel as it twiddles its thumbs for an event, then dispatches like a waiter at a Michelin-star restaurant 🍽️. Forget progress, let's wrap "epoll" and "kqueue" in redundant libraries and call it #innovation. 🚀
https://geocar.sdf1.org/fast-servers.html #reinventingthewheel #networkserver #epoll #kqueue #softwaredevelopment #HackerNews #ngated
fast-servers

🎉 Behold the groundbreaking revelation: wrapping #io_uring and #kqueue in a warm, fuzzy blanket to make them "user-friendly" for programmers who apparently can't handle raw I/O. 🙄 Gather 'round, fellow developers, for the riveting journey from blocking I/O to... an event loop that looks suspiciously like every other one you've seen. 🤦‍♂️
https://tigerbeetle.com/blog/2022-11-23-a-friendly-abstraction-over-iouring-and-kqueue/ #userfriendly #programming #eventloop #HackerNews #ngated
A Programmer-Friendly I/O Abstraction Over io_uring and kqueue

Insights, updates, and technical deep dives on building a high-performance financial transactions database.

A Programmer-Friendly I/O Abstraction Over io_uring and kqueue

Insights, updates, and technical deep dives on building a high-performance financial transactions database.

🌘 一個對 io_uring 和 kqueue 友善的程式設計師 I/O 抽象層
➤ 從阻塞式 I/O 到高效事件驅動模型
https://tigerbeetle.com/blog/2022-11-23-a-friendly-abstraction-over-iouring-and-kqueue/
本文探討了傳統阻塞式 I/O 的侷限性,並深入介紹了 Linux 的 io_uring 和 FreeBSD/macOS 的 kqueue 這兩種高效 I/O 處理機制。作者展示瞭如何利用這兩種機制,將 I/O 操作從使用者空間移至核心空間,大幅減少系統呼叫的開銷。此外,文章提出了一種「中央 I/O 調度」的抽象層,讓開發者無需關心底層的 io_uring 或 kqueue 實作細節,只需透過統一的介面提交 I/O 請求並註冊回呼函式,即可實現更簡潔、更具擴展性的 I/O 處理邏輯,最終建立起一個類似於傳統事件迴圈的 I/O 處理模型。
+ 這篇文章對於理解 io_uring 和 kqueue 的核心概念非常有幫助!作者的
#程式設計 #IO #io_uring #kqueue #效能
A Programmer-Friendly I/O Abstraction Over io_uring and kqueue

Insights, updates, and technical deep dives on building a high-performance financial transactions database.

I started documenting kernel side #kqueue on #FreeBSD. At this point it is just a brain dump, so I need help improving https://github.com/mekanix/freebsd-src/tree/kqueue-docs. @dexter got any tips except contacting man page author?
GitHub - mekanix/freebsd-src at feature/blacklist-remove

FreeBSD src tree (read-only mirror). Contribute to mekanix/freebsd-src development by creating an account on GitHub.

GitHub

@feld @david_chisnall @meka

More generally: #kqueue still has several ragged edges, compared to poll/select.

https://tty0.social/@JdeBP/114574054783681506

https://tty0.social/@JdeBP/114575142459347113

Every little helps in order to fill in all of these gaps.

#FreeBSD

JdeBP (@[email protected])

@[email protected] It is always welcome to see more kevent(), if only because it lets other people share my pain, in the hope that that increases the push for kevent() to be fully completed and as good as select(). There are a number of cases I have hit over the years kevent() cannot *quite* do what select() does. #FreeBSD #kqueue

tty0.social

I submitted my #kqueue support for sound(4) on #FreeBSD. I hope we will polish it soon enough. https://reviews.freebsd.org/D53029

cc @JdeBP

⚙ D53029 Add kqueue(9) support to sound(4)