Merge: Performance improvement in read_all_bytes
authorJean Privat <jean@pryen.org>
Mon, 17 Aug 2015 20:15:27 +0000 (16:15 -0400)
committerJean Privat <jean@pryen.org>
Mon, 17 Aug 2015 20:15:27 +0000 (16:15 -0400)
commit4d2df686d05106d391259a39c7c0c905fc774118
tree0007c994eda0d721c69db96d052a82583ecbb8c5
parentd65f682c8e84639cc7919418ba50cb092ea2e395
parent2a51f527ed6c1a788f5b63bd6c2791f00076faf4
Merge: Performance improvement in read_all_bytes

As @privat notified me of yesterday, a lot of time is wasted in read_all by boxing and unboxing bytes when doing the infamous `_buffer.add` operation in `read_all_bytes`.

This PR removes the boxing operations by bulk-writing a NativeString to a Bytes.
The buffer on files is also tenfold-bigger, which cuts I/O times while still retaining a reasonable size.

# Performances

On the Batmobileā„¢

## Valgrind

Before:
standard___standard__BufferedReader___Reader__read_all_bytes: 90.816 MIr
After:
standard___standard__BufferedReader___Reader__read_all_bytes: 7.596 MIr

## ./ncall-best

Before
user 0m4.316s
After
user 0m4.182s

Close #1298

Pull-Request: #1636
Reviewed-by: Jean Privat <jean@pryen.org>
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>