Closed valdisxp1 closed 3 years ago
thank you, good optimization!
Could you tag this pull request with hacktoberfest-accepted
?
Long story short: it costs you nothing, I get a free t-shirt. :smile:
https://hacktoberfest.digitalocean.com/hacktoberfest-update
Done
When downloading
FairPieceStorageFactory.createStorage
could not tell the difference between a partial download and a completely blank piece it just created. Then it would compute SHA-1 hash in both cases.If we have a newly created blank piece we assume that the torrent does not have a blank piece and download that piece without looking at the hash. I.e. do not put it in
availablePieces
.This should be significant speed up when downloading. I did the
CommunicationManagerTest#download_many_times
test 50 times and without the delay, i.e:In jProfiler I see that
java.security.MessageDigest.digest
(calculation SHA-1) before optimizations took 2,295 ms (24 %). And after it takes 1,209 ms (13 %). So I expect >10% speed improvement for downloads.