]> Cypherpunks repositories - gostls13.git/commit
syscall: NetlinkRIB, avoid allocation in loop
authorCristian Staretu <unclejacksons@gmail.com>
Wed, 9 Jul 2014 08:50:38 +0000 (18:50 +1000)
committerDave Cheney <dave@cheney.net>
Wed, 9 Jul 2014 08:50:38 +0000 (18:50 +1000)
commit8aea9a00a838736189d4a9e381f916b0c3ceaf1d
tree827bbcf42c405df79133289b4987ea460937298a
parent3e801416ceadd622ad9703d52ac12065dba5eaf8
syscall: NetlinkRIB, avoid allocation in loop

NetlinkRIB is currently allocating a page sized slice of bytes in a
for loop and it's also calling Getpagesize() in the same for loop.

This CL changes NetlinkRIB to preallocate the page sized slice of
bytes before reaching the for loop. This reduces memory allocations
and lowers the number of calls to Getpagesize() to 1 per NetlinkRIB
call.

This CL reduces the allocated memory from 141.5 MB down to 52 MB in
a test.

LGTM=crawshaw, dave
R=dave, dsymonds, crawshaw
CC=bradfitz, dsymonds, golang-codereviews
https://golang.org/cl/110920043
src/pkg/syscall/netlink_linux.go