I wrote a guide covering the most interesting tuning parameters, including dirty_data_max. Where to tune it depends on your system. Avoid TrueNAS Scale. I use 30GB dirty data max on my pool, along with higher txg timeout and outside of complications when using high compression (short lock-ups, because compress 30GB NOW pls, resulting in 100% CPU on all cores), it runs fine.
You need the memory for it though. That’s 30GB in your ARC and the usual cached data will be evicted if ARC has to store dirty data, so keep this in mind. But it works like a write cache. It runs fine with my 10Gbit networking.1.17 GiB/sec sequential writes according to htop, with 4k random, my HDDs write faster than the NVMe can read them.
Eventually, this is limited by my HDDs (3x mirrors, they write with 600-750MB/s) once the 30GB are full. I rarely have >50-80GB to write at once, so this 30GB buffer is perfect.
That’s async writes. Not sure how sync writes work on NVMe pools. Another option would be sync=disabled (yet another heretical feature of ZFS) to effectively use ARC as your LOG.
This is almost certainly not the recommended way of doing things, but it works for me and gets the job done (fast).
scroll down to second posting to find tuning stuff. But basics will be on the top posting and may be useful too.