saifi009 / bitcoinj

Automatically exported from code.google.com/p/bitcoinj
0 stars 0 forks source link

Startup is slow #14

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
DiskBlockStore.load(file) is slowing down the startup.

It takes one second to load the current block chain with 117.000 blocks on my 
Intel Core i7 with SSD. It takes "forever" on an emulated Android device.

I found two places that could be improved:
 1. Use BufferedReader for to read the file
   - FileInputStream input = new FileInputStream(file);
   + InputStream input =  new BufferedInputStream(new FileInputStream(file));

 2. Utils.doubleDigest(input, offset, length) is called 117.000 times.
   * Move MessageDigest.getInstance("SHA-256") to a final static variable.

Attaching the "Hot Spots" results before and after these two code changes.

Original issue reported on code.google.com by heg...@gmail.com on 11 Apr 2011 at 10:38

Attachments:

GoogleCodeExporter commented 9 years ago
These are good improvements, thanks.

However the DiskBlockStore is not intended to be used on Android devices. I 
know it's slow. That's why I've been telling Andreas to wait for another 
blockstore implementation that has zero memory overhead and zero startup time 
at the cost of slower block loads and more expensive difficulty transitions.

Original comment by hearn@google.com on 12 Apr 2011 at 8:02

GoogleCodeExporter commented 9 years ago
This issue was closed by revision r53.

Original comment by hearn@google.com on 20 Apr 2011 at 4:39

GoogleCodeExporter commented 9 years ago
Note that I didn't remove the verify() call because it only saved a couple 
hundred milliseconds on my machine and it's a good check against file 
corruption.

I'd be interested to know how long it takes to load on a real Android device 
rather than the emulator, which is so slow as to be meaningless.

Original comment by hearn@google.com on 20 Apr 2011 at 4:40