Usually it's "just" X11 that becomes unusable. To get a keystroke from your keyboard to a program, and have it show anything on screen, code in several different processes has to run. (X server to get the keystroke from the kernel, xterm or equivalent to get the event and decide to draw something, then send a message to the X server to draw a glyph from a font.)
ctrl+alt+F2 to switch to another virtual console usually makes it possible to log in and run shell commands with only a couple seconds latency when something is causing swap thrashing. It's just
bash; the Linux kernel isn't swappable and it has all the VT and
It may take some time before this keypress does anything, if swap is really thrashing badly. The X server, not the kernel, has to receive that keystroke and switch away from its own VT after putting the video hardware back into the right mode. The kernel is still looking for Alt+SysRq key combos, but nothing else. But once you do get switched to a text console, there's usually at most 1 user-space process between typing and characters showing on screen.
If your X server actually locked up, then ctrl+alt+F2 may not work at all.
To avoid slowdown when you're not truly thrashing, reducing "swappiness" can help. e.g. I set the
/proc/sys/vm/swappiness tunable to
6 on my desktop with 16GB of RAM and a 2GB swap partition on an NVMe SSD. You can read more about tuning for interactive latency (as opposed to server throughput); any guide will mention that tunable.
But if you have any swap at all, Linux will use it before invoking the OOM killer. Keep your swap partition small, just big enough for Linux to page out really stale crap that typically really doesn't get used for a long time. (e.g. memory leaks!)
I haven't had any problems with swap being full. Modern Linux deals with having limited swap space just fine. Chromium (which I use instead of firefox) does sometimes get slowish with dozens of Stack Overflow tabs open, but The Great Suspender is a nice addon for unloading tabs when you're not using them. I think that saves significant RAM for me, although it will only unload tabs where you haven't typed anything in a textbox. It might also be available for Firefox.
As other have suggested, 16GB of RAM is really nice for interactive use with Linux. DRAM prices are relatively low currently; after spiking about 1.5 years ago, they've mostly declined again.