I expect this to go into 0.14 sometime relatively soon.
That's great news.
If you are going to do speed improvements for 0.14, can you also "profile" or check the I/O, and especially writes. I think there's something doing needless work there and it's also stalling the cpu which is waiting for the I/O to finish.
I have the blockchain on my mechanical disk, and while my connection is just 600kb/sec, if I sync to get the last 3-4 days (-blocksonly), this is generating a near constant 10-13mb/s read, and a 11-14mb/s write. Obviously my question was "wtf is it writing?" If I use full indexing support in the filesystem, and since writes have to be performed x2, speed goes down to a crawl.
I initially thought its a flushing issue or something... I was like "ok, if I'm 4 days behind, that's at most ~570mb... can't this be loaded entirely into RAM and then flush it in the end in some kind of batch change to avoid all these writes which kill I/O speed and slow down my sync? It would take just 4-5 seconds in the end..."
I started searching the source files for any file with "flush" and I found some parameters in main.h... So I did some changes in the main.h flush times in lines 97 and 99 (multiplied the defaults x100) but didn't have any obvious effect.
Then I realized that
of course it wouldn't have any obvious effect because it's doing something else. With 600kb/sec download, the 11+ mb/s in writes are not the blockchain getting downloaded. It's some other process of rearranging files, writing undo instructions, writing logfiles etc.
So I left it for a few hours and I launched it a few minutes ago to sync the last 10 hours. I now noticed that there were 5-11mb/sec writes going on even in the phase where the bitcoin-qt launches and does the 0%-100% verification, and without having downloaded any extra blocks.
By doing an lsof -p 7464 (bitcoin-qt pid), I get that that the following files are loaded with write or exclusive write attributes:
bitcoin-q 7464 15uW REG 254,1 .bitcoin/.lock
bitcoin-q 7464 16w REG 254,1 .bitcoin/debug.log
bitcoin-q 7464 17w REG 254,1 .bitcoin/db.log
bitcoin-q 7464 18w REG 254,1 .bitcoin/blocks/index/LOG
bitcoin-q 7464 19uW REG 254,1 .bitcoin/blocks/index/LOCK
bitcoin-q 7464 20w REG 254,1 .bitcoin/blocks/index/003446.log
bitcoin-q 7464 21w REG 254,1 .bitcoin/blocks/index/MANIFEST-003444
bitcoin-q 7464 22w REG 254,1 .bitcoin/chainstate/LOG
bitcoin-q 7464 23uW REG 254,1 .bitcoin/chainstate/LOCK
bitcoin-q 7464 24w REG 254,1 .bitcoin/chainstate/749940.log
bitcoin-q 7464 25w REG 254,1 .bitcoin/chainstate/MANIFEST-749938
...so the culprit is somewhere in there doing way too many writes for apparently no reason (?), or in a suboptimal way (?).
I also tried dbcache settings of 0 and 1000, they didn't make any difference in making this phenomenon of ~10mb/s writes disappear (whether in the bitcoin-qt launch, or later when syncing).