We are currently flushing the wallet after every operation. This is very slow. In case of syncing txs, we need performance, rather than durability. Our SetBestChain-mechanism ensures, that txs from a block are always synced, even on a crash, as we rescan the necessary blocks on startup. The FlushWalletThread only flushes, if there is no wallet-update for 2 seconds.
I tested replacing the txn_checkpoint(..) call with log_flush, but this does not help.
Currently I can only add about 10 txs per second to the wallet on my machine. After this patch its more than 1000 txs per second.
For example importaddress mvqaxopu9Uef2qjXSV3fGrp6DcEYnCoYWK adds about 20000 txs to the wallet. Together with these optimizations #4702 #4712 you hardly notice the difference between a normal rescan and adding 20000 txs to the wallet. Currently this takes hours, I had to let my client running over night, in order to finish. The overall performance increase is like factor 500 or so on a larger wallet.