The linux kernel’s handling of IO under memory pressure is abysmal. I have to tune dirty ratios and write back ages and swap and whatnot just to get the system to not hard lock when running multiple node microservices in stages which run fine, just slower, when starting them all at once on a MacBook.
I've had similar problems but no amount of tweaking vm and vfs cache settings helped. Swap or not, both 32gb and 128gb of ram. Manually reclaiming memory would un-lock the system (/sys/fs/cgroup/memory.reclaim).
Disclaimer: I don’t even like macOS.