`readI32` ( https://github.com/apache/thrift/blob/master/lib/js/src/thrift.js#L1311-L1341 ) performance is extremely poor in Chrome when reading values from large arrays. This is due to the use of Array.shift ( https://github.com/apache/thrift/blob/master/lib/js/src/thrift.js#L1322 ) which seems to have performance issues in V8/Chrome.
As Chrome is a high market share browser I propose either changing this to use reverse/pop or detect the appropriate strategy given array length. I think this is due to how V8 handles large arrays and the heuristics used to determine whether data should be stored in a C-backed array or hash map.
0) Download or copy the attached ThriftBenchmarker.js - this file has some helper functions to build large arrays, as well as a copy/paste of the current `readI32` as well as one that uses Array.reverse/Array.pop over Array.shift.
1) Run this test in Chrome - you can simply copy/paste the code into the Console.
2) Observe that the tests using Array.shift are quite slow in Chrome:
3) Run this test in Safari (or a non-V8) browser.
4) Observe that the tests using Array.shift are far faster: