satazor / js-spark-md5

Lightning fast normal and incremental md5 for javascript
Do What The F*ck You Want To Public License
2.46k stars 470 forks source link

Performance Issues in IE-11 #25

Closed umartopia closed 7 years ago

umartopia commented 9 years ago

When I executed the test files in Chrome, I was able to calculate the checksum of ~600 MB zip file in less than a minute. However, when I tried the same using IE-11, it took about 3 minutes for the same file. While debugging, I observed that the following line took long time to execute in IE-11: spark.append(e.target.result);

satazor commented 9 years ago

Hmmm I need to investigate. Thanks for reporting.

umartopia commented 9 years ago

One more thing to note: You can try running the index.html file available in your source in Chrome and IE and you can check the difference.

In Chrome:

Hash of Hello : 9ms Hash of 64 bytes: 2ms Hash of 128 bytes: 0ms Hash of 160 bytes: 0ms Incremental usage:1ms UTF-8: 2ms Hashing a PNG: 2ms

IE:

Hash of Hello : 25ms Hash of 64 bytes: 4ms Hash of 128 bytes: 5ms Hash of 160 bytes: 4ms Incremental usage:8ms UTF-8: 78ms Hashing a PNG: 24ms

satazor commented 9 years ago

I spawned a Windows VM with IE11 but I'm not getting these discrepancies:

IE11: Tests completed in 40 milliseconds. Chrome on the same VM: Tests completed in 38 milliseconds.

I've run the tests 10 times and I get similar results in all of them.

umartopia commented 9 years ago

It may be related to environment settings or may be OS related

FYI : I was using Windows 8 with IE-11 for testing this stuff

satazor commented 9 years ago

I used a win7 vm, need to test with win8

vergil-zqp commented 8 years ago

Hi,satazor, I have the same problems with IE10.

satazor commented 8 years ago

I get the same results with win8. Can you guys click in Help -> About and paste here the exact IE version you're testing against? Thanks.

kaurranjeet12 commented 8 years ago

Hi,

I am also facing the same issue with IE. I am using IE version 11.0.9600.18098.

Thanks, RJ

satazor commented 8 years ago

I will need to take a look when I have some time. If you guys could investigate first it would make it easier for me to do a patch to fix the issue.

vmihnea commented 7 years ago

Hi,

Any progress on this issue? We are facing the same problem on IE version 11.0.9600.18349

Thanks,

Vlad

satazor commented 7 years ago

@vmihnea I'm not experiencing this issue on my windows vm. I was hoping that someone of you guys could invest some time in identifying the issue and propose a PR.

vmihnea commented 7 years ago

@satazor I've invested more time in profiling and by now I can better isolate the issue, but sadly I am not able to propose a PR.

Bottom line: On IE 11 there is a lot of time spent inside md5cycle function and its subsequent calls to ff(), gg(), hh(), ii(). All these functions combined alot for ~95% of the processing time. I'm attaching a spreadsheet that contains the profiling information.

My tests were performed as follows:

  1. Using file_reader.html I have uploaded a large file (250 MB) - "normal" mode. I have done this on both IE 11 and Chrome (latest). On IE this takes about 55 seconds while on Chrome < 2 seconds.
  2. In an effort to isolate the problem I have created a test file (md5cycle.html - attached). I've stripped your library down to the basic function calls I've identified as troublesome and tried the md5 on an array similar in size with the one resulting from the large file used in step 1. As you can see the results are pretty similar.

Unfortunately this is where I am stuck and cannot help any further. The functions identified as problematic on IE 11 basically do bit-wise operations I have no clue how to interpret let alone how to fix.

My gut feeling is that these bit-wise operations are not very optimized on IE 11 thus taking a little longer and when it comes to large files these differences pile up. I've found no benchmark available on this topic so take it with a grain of salt.

Could you please try to investigate further and let me know if you are able to patch?

Attached files: md5cycle.html.txt Profiler.xlsx

Cheers,

Vlad

vmihnea commented 7 years ago

One more note. This is reproducible on all our hardware configuration (VM also).

vmihnea commented 7 years ago

Hello again,

I've found a fix for the IE 11 performance issues while testing another library (yamd5) which is based on yours.

Basically if I replace your md5cycle function with the one here: yamd5.js I get a clear performance boost on IE 11 while the performance on Chrome & Firefox is very similar. Haven't tested on older IE versions and, from the comments in the code, there might be an impact there.

Thanks,

Vlad

satazor commented 7 years ago

@vmihnea Thanks for the analysis. I will investigate yamd5 and see what they are doing differently.

satazor commented 7 years ago

Should be fixed by #41 and released as v3.0.0. Try it out and post feedback here. Ty @nochev