If uninitialized memory is read loadArrayValues could try to call
cacheMemory with a negative size, which could cause a 'makeslice:
len out of range' panic.
Fixes#354 (partial)
Prefetch the entire memory of structs and arrays and cache it instead
of issuing readMemory calls only when we get down to primitive types.
This reduces the number of system calls to ptrace that variables makes.
Improves performance in general, greatly improving it in some
particular cases (involving large structs).
Benchmarks without prefetching:
BenchmarkArray-4 10 132189944 ns/op 0.06 MB/s
BenchmarkArrayPointer-4 5 202538503 ns/op 0.04 MB/s
BenchmarkMap-4 500 3804336 ns/op 0.27 MB/s
BenchmarkGoroutinesInfo-4 10 126397104 ns/op
BenchmarkLocalVariables-4 500 2494846 ns/op
Benchmarks with prefetching:
BenchmarkArray-4 200 10719087 ns/op 0.76 MB/s
BenchmarkArrayPointer-4 100 11931326 ns/op 0.73 MB/s
BenchmarkMap-4 1000 1466479 ns/op 0.70 MB/s
BenchmarkGoroutinesInfo-4 10 103407004 ns/op
BenchmarkLocalVariables-4 1000 1530395 ns/op
Improvement factors:
BenchmarkArray 12.33x
BenchmarkArrayPointer 16.97x
BenchmarkMap 2.59x
BenchmarkGoroutinesInfo 1.22x
BenchmarkLocalVariables 1.63x