tailscale/portlist
Brad Fitzpatrick 036f70b7b4 portlist: refactor, introduce OS-specific types
Add an osImpl interface that can be stateful and thus more efficient
between calls. It will later be implemented by all OSes but for now
this change only adds a Linux implementation.

Remove Port.inode. It was only used by Linux and moves into its osImpl.

Don't reopen /proc/net/* files on each run. Turns out you can just
keep then open and seek to the beginning and reread and the contents
are fresh.

    name                    old time/op    new time/op    delta
    GetListIncremental-8    7.29ms ± 2%    6.53ms ± 1%  -10.50%  (p=0.000 n=9+9)

    name                   old alloc/op   new alloc/op   delta
    GetListIncremental-8    1.30kB ±13%    0.70kB ± 5%  -46.38%  (p=0.000 n=9+10)

    name                  old allocs/op  new allocs/op  delta
    GetListIncremental-8      33.2 ±11%      18.0 ± 0%  -45.82%  (p=0.000 n=9+10)

Updates #5958

Change-Id: I4be83463cbd23c2e2fa5d0bdf38560004f53401b
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2022-10-23 20:29:23 -07:00
..
clean_test.go portlist: normalise space delimited process names (#5634) 2022-09-15 12:17:31 +02:00
clean.go portlist: normalise space delimited process names (#5634) 2022-09-15 12:17:31 +02:00
netstat_exec.go portlist: update some internals to use append-style APIs 2022-10-21 22:26:37 -07:00
netstat_test.go portlist: refactor, introduce OS-specific types 2022-10-23 20:29:23 -07:00
netstat.go portlist: update some internals to use append-style APIs 2022-10-21 22:26:37 -07:00
poller.go portlist: refactor, introduce OS-specific types 2022-10-23 20:29:23 -07:00
portlist_ios.go portlist: update some internals to use append-style APIs 2022-10-21 22:26:37 -07:00
portlist_js.go portlist: update some internals to use append-style APIs 2022-10-21 22:26:37 -07:00
portlist_linux_test.go portlist: refactor, introduce OS-specific types 2022-10-23 20:29:23 -07:00
portlist_linux.go portlist: refactor, introduce OS-specific types 2022-10-23 20:29:23 -07:00
portlist_macos.go portlist: update some internals to use append-style APIs 2022-10-21 22:26:37 -07:00
portlist_other.go portlist: update some internals to use append-style APIs 2022-10-21 22:26:37 -07:00
portlist_test.go portlist: refactor, introduce OS-specific types 2022-10-23 20:29:23 -07:00
portlist_windows.go portlist: update some internals to use append-style APIs 2022-10-21 22:26:37 -07:00
portlist.go portlist: refactor, introduce OS-specific types 2022-10-23 20:29:23 -07:00