Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
When looking at runc strace output, I noticed that selinux attr files are read byte by byte: read(8, "u", 1) = 1 read(8, "n", 1) = 1 .... Apparently, this happens because fmt.Fscanf("%s") works that way. Let's read the whole file via ioutil.ReadAll instead. The added benchmark shows a drastic improvement: name old time/op new time/op delta CurrentLabel-4 26.4µs ± 1% 4.3µs ± 1% -83.73% (p=0.004 n=6+5) name old alloc/op new alloc/op delta CurrentLabel-4 352B ± 0% 776B ± 0% +120.45% (p=0.002 n=6+6) name old allocs/op new allocs/op delta CurrentLabel-4 9.00 ± 0% 7.00 ± 0% -22.22% (p=0.002 n=6+6) Note that increased allocation size is caused by the fact that ReadAll preallocates a 512 bytes buffer, which is very reasonable. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
- Loading branch information