iTunes-Backup-Explorer
iTunes-Backup-Explorer copied to clipboard
Use NIO for file decryption
Refactor the decryption code to use NIO classes. There's a pretty good performance win, and I think it's due to a combination of larger buffers and fewer intermediate buffers.
I tested it by extracting with the modified code and comparing the restored files.
To get an estimate of the performance win, I wrote quick test script that uses similar decrypt implementations over different file sizes:
https://gist.github.com/ehrmann/e80e4eda48b839d41d9cd52d0ba551ee
Windows:
size, old, new
1K, 1969, 1399
2K, 2066, 1339
4K, 1893, 1357
8K, 1921, 1355
16K, 2172, 1390
32K, 2270, 1484
64K, 2632, 1518
128K, 2767, 1684
256K, 3469, 1962
512K, 5074, 2643
1024K, 7862, 3724
2048K, 13456, 6070
4096K, 26723, 12902
FreeBSD
size, old, new
1K, 60, 42
2K, 96, 21
4K, 17, 42
8K, 34, 28
16K, 44, 37
32K, 83, 55
64K, 120, 78
128K, 189, 135
256K, 397, 144
512K, 306, 376
1024K, 1136, 591
2048K, 1444, 640
4096K, 3563, 2326
Linux
size, old, new
1K, 105, 35
2K, 107, 34
4K, 107, 32
8K, 120, 42
16K, 127, 40
32K, 165, 47
64K, 192, 64
128K, 278, 98
256K, 438, 160
512K, 773, 292
1024K, 1422, 525
2048K, 2680, 1047
4096K, 5207, 2020