I wrote this years ago when I was doing a bunch of work with low ram (1gb) potato SBCs and I use it everywhere, including my 32/64gb SFF proxmox nodes: github.com/foundObjects/zram-swap
You might find the comments re: swap sizing and compression ratios handy, I’ve found that lz4 approximates to a 2.5:1 compression ratio during most workloads. On your 4gb potato I’d run something like ~2GB lz4 zram, which would work out to a ~5GB zram device. I never bothered with sysctl tuning, you generally don’t need to.
Edit: just about every Chromebook under the sun, and like 90%+ of all Android devices, runs lzo/lzo-rle zram swap at ~(½ramsize*3). Change that to *2.5 for lz4 and you’re set.