6 ms·
Global Kernel Locks in APFS
- chmaynard 8y agoThe author worked very hard to determine the root cause of the problem but he was stymied because the APFS source code is not available. Why not? Apple has open-sourced the Swift compiler with great success, but there seems to be no movement within Apple to open up other system software components.
- jarym 8y agoPretty sure the code would expose just how much of a rush-job apple did with APFS. It may be released one day..
- wmf 8y agoApple releases most of the macOS kernel but I guess it doesn't include APFS: https://opensource.apple.com/source/xnu/ https://opensource.apple.com/source/xnu/
- NegativeLatency 8y agoThat's missing a good chunk of the interesting stuff related to how users interact with the os though. (app and framework source code)
- wmf 8y agoYeah, apps and frameworks aren't part of the kernel. But APFS is.
- Phrodo_00 8y agoKind of talking out of my ass, but Darwin can act as a mirokernel, so APFS could be implemented as a user mode service (no idea if it's the case, though).
- yjftsjthsd-h 8y agoDarwin's XNU is not a microkernel, in spite of there being a microkernel version of XNU. While Darwin does support FUSE, performance would almost certainly be inadequate, given the constant transitions between user and kernel space.
- Phrodo_00 8y agoI thought it was a mixture of OSFMK and BSD, which is why I said it can act like a microkernel. Don't know more than what wikipedia says, though.
- rayiner 8y agoYes, it is, but the Mach layer and BSD layer were fused into a monolithic kernel before NeXT Step turned into OS X. In OS X, HFS (and presumably APFS) are in the BSD layer.
- comex 8y agoIt's loaded into the kernel, but it's a kext (kernel extension) rather than being part of the xnu source tree itself. Only a subset of kexts are open source. (By comparison, HFS used to be in the xnu tree, but it was moved into a kext as well a few years back; that one is open source.)
- mikhailt 8y agoThey do plan to document it fully later: > Is APFS open source? > An open source implementation is not available at this time. Apple plans to document and publish the APFS volume format specification. Source: https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/APFS_Guide/FAQ/FAQ.html https://developer.apple.com/library/archive/documentation/Fi... My theory is that Apple rushed APFS and its implementation isn't in a great shape for the public review. APFS doesn't feel any faster on my SSDs on macOS. I suspect they'll add it in a few years, after a few iterations.
- twotwotwo 8y agoThey released the format spec here: https://developer.apple.com/support/apple-file-system/Apple-File-System-Reference.pdf https://developer.apple.com/support/apple-file-system/Apple-...
- JadeNB 8y ago> They do plan to document it fully later: > > Is APFS open source? > > An open source implementation is not available at this time. Apple plans to document and publish the APFS volume format specification. They claim to plan to document it fully later.
- MBCook 8y agoWhat makes you think it’s a rush job? Perhaps it’s just the lawyer reviews holding it up.
- asveikau 8y ago
- saagarjha 8y agoThe APFS source code isn't available, but you're free to disassemble apfs_vnop_readdir in apfs.kext. I'm seeing a couple of calls to lck_rw_lock_shared, so it's entirely possible that there's a lock here.
- userbinator 8y agoThis. It's what everyone I know who works in the Windows space does when they have a deep problem to investigate. Lack of source doesn't mean lack of ability to investigate, and sometimes the source doesn't tell the whole story either. (Yes, I know about the anti-RE clauses in EULAs. If they were actually enforced as strictly as they claim, people like Mark Russinovich and Matt Pietrek would've been sued out of existence long ago, along with just about every Windows security researcher.)
- pcwalton 8y agoThe Wine source is often helpful too.
- kiwijamo 8y agoI wonder if this is why recent versions of macOS performs so poorly on old HDD-based MacBooks. The difference between my work's 2012 MacBook (HDD) and my personal 2015 (SSD) MacBook is like night and day. Most apps open in a second on my SSD MacBook yet take up to a minute to open on my employer's HDD MacBook. It's not just this MacBook, I also see the same on a work iMac as well. Such a shame as these older machines previously didn't run so slowly.
- GeekyBear 8y ago2015 was the year that Apple moved to NVMe SSDs, so they are bound to feel much more snappy than spinning rust disks, regardless of the file system involved. https://www.anandtech.com/show/9136/the-2015-macbook-review/8 https://www.anandtech.com/show/9136/the-2015-macbook-review/...
- DavidNielsen 8y agoExcept for their desktops models, the base models of even the 5K iMac still ship with a Fusion Drive, and we only just got support for APFS on those configurations with macOS 10.14. As the base models are typically all authorized Apple Resellers and pop up stores get they must sell a bunch of those especially in regions where there aren’t a lot of Apple Stores (and where people don’t want to pay full price for a year old system). They are going to need to support and perform well on non-SSD systems for quite a while.
- bradknowles 8y agoReplacing an HDD with an SSD really is a night-and-day kind of difference for any laptop I've ever seen, regardless of the OS or filesystem. IMO, that's likely to be a much bigger factor than the filesystem.
- awiesenhofer 8y agoUnfortunately not the biggest one though. I too have a old 2012 macbook pro with hdd. While it was flying under snow leopard it now grinds to a halt every time i open any app or document. Already ordered an ssd but still dreaming of downgrading it back to snow leopard.
- lelf 8y agoAbsolutely nothing there indicates the presence of global kernel locks. readdir (obviously!!!) needs to hold a lock, it’s not global, it’s per-DIR.
- twotwotwo 8y agoI'm too late to the thread, but wonder if locking might have to do with updating access times on the dirs on read--that would help justify a read-only workload taking some sort of exclusive lock. The "fix" there would be something like relatime to get atimes set infrequently. There're def a ton of other possibilities. Some locking could be overbroad, like an exclusive lock where a reader lock would be enough. I don't see super-strong evidence that any locks involved are actually global, just that they're under contention here. And I can understand shipping a product with somewhat excessive locking because perf issues with specific workloads are a better problem to have with your shiny new FS rollout than data loss. Anyway it's mostly shooting in the dark for us here (though cool some folks disassembled the functions), but there are some shots in the dark that look different from what I could find in the comments already here :)
- georgn 8y agoAs someone who used to work on BitKeeper, I'm tickled to see a more popular SCM's test suite as a kind of de facto filesystem benchmark -- confirming what we had been observing ourselves forever.