Fixed speed of bignum and 64bit integer encoding in encode_value
This fixes an issue we ran into in one of our servers where encoding a
reasonably sized list of crc32 hashes (unsigned 32 bit integers, so
50% would not fit in a signed 32bit integer) took 10+ seconds.
| Pike v8.1 release 0 running Hilfe v3.5 (Incremental Pike Frontend)
| > array ints = allocate(50000,random)(1<<32);
| > array bigs = allocate(50000,random)(1<<320);
| > set format bench
Before my fix:
| > encode_value(ints),0; ... Execution: 1.24s
| > encode_value(bigs),0; ... Execution: 121.31ms
After my fix:
| > encode_value(ints),0; ... Execution: 18.58ms
| > encode_value(b),0; ... Execution: 43.85ms
So. "normal" 64 bit integers are now encoded about 66 times faster.
Actual bignums are only 3x faster.
This makes me somewhat suspicious about the speed of various bignum
functions in pike, by the way, since the only thing that should really
have been done is to remove the function call + object
And it does not take even close to 1.2 seconds to create and free
50.000 bignum objects (creating and reallocating the array 'b' above
takes about 50ms).