[feature]: prune spend journal
Currently, an archive node leveldb database uses ~90GiB of storage, of which ~75GiB is just the spend journal. Since leveldb performance is critical to IBD speed, moving the database to an SSD while keeping the blocks in a hard disk improves IBD speed significantly in machines constrained in RAM. But the current implementation also makes harder to move the DB to an SSD, because ~90GB of DB is a lot for machines with small SSDs. Just by pruning the spend journal to ((4 << 20) * 144 * 2) bytes we can reduce the database storage usage to less than 20GiB, which even in the worst case (4 MiB / entry) would be sufficient to process reorgs of ~288 blocks.
I chose being able to process ~288 blocks of reorg because in my point of view, 144 blocks (one day) of reorg would already destroy the value of the Bitcoin protocol, so I think targeting 288 blocks of spend journal should be enough.
Another option would be to store the spend journal in flat files on disk, but pruning the spend journal already resolved my problem.
I've patched my own btcd instance to support this, with the addition of the flag --prunespendjournal=<MiB>.
Would be nice to get feedback from maintainers.
Source: btcsuite/btcd