mirror of
https://github.com/tailscale/tailscale.git
synced 2025-08-11 13:18:53 +00:00
sockstats: remove per-interface stats from Get
They're not needed for the sockstats logger, and they're somewhat expensive to return (since they involve the creation of a map per label). We now have a separate GetInterfaces() method that returns them instead (which we can still use in the PeerAPI debug endpoint). If changing sockstatlog to sample at 10,000 Hz (instead of the default of 10Hz), the CPU usage would go up to 59% on a iPhone XS. Removing the per-interface stats drops it to 20% (a no-op implementation of Get that returns a fixed value is 16%). Updates tailscale/corp#9230 Updates #3363 Signed-off-by: Mihai Parparita <mihai@tailscale.com>
This commit is contained in:

committed by
Mihai Parparita

parent
9ebab961c9
commit
97b6d3e917
@@ -34,9 +34,6 @@ func TestDelta(t *testing.T) {
|
||||
Stats: map[sockstats.Label]sockstats.SockStat{
|
||||
sockstats.LabelDERPHTTPClient: {
|
||||
TxBytes: 10,
|
||||
TxBytesByInterface: map[string]uint64{
|
||||
"en0": 10,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -44,9 +41,6 @@ func TestDelta(t *testing.T) {
|
||||
Stats: map[sockstats.Label]sockstats.SockStat{
|
||||
sockstats.LabelDERPHTTPClient: {
|
||||
TxBytes: 10,
|
||||
TxBytesByInterface: map[string]uint64{
|
||||
"en0": 10,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -59,12 +53,8 @@ func TestDelta(t *testing.T) {
|
||||
Stats: map[sockstats.Label]sockstats.SockStat{
|
||||
sockstats.LabelDERPHTTPClient: {
|
||||
TxBytes: 10,
|
||||
TxBytesByInterface: map[string]uint64{
|
||||
"en0": 10,
|
||||
},
|
||||
},
|
||||
},
|
||||
Interfaces: []string{"en0"},
|
||||
},
|
||||
wantStats: map[sockstats.Label]deltaStat{
|
||||
sockstats.LabelDERPHTTPClient: {10, 0},
|
||||
@@ -77,30 +67,16 @@ func TestDelta(t *testing.T) {
|
||||
sockstats.LabelDERPHTTPClient: {
|
||||
TxBytes: 10,
|
||||
RxBytes: 10,
|
||||
TxBytesByInterface: map[string]uint64{
|
||||
"en0": 10,
|
||||
},
|
||||
RxBytesByInterface: map[string]uint64{
|
||||
"en0": 10,
|
||||
},
|
||||
},
|
||||
},
|
||||
Interfaces: []string{"en0"},
|
||||
},
|
||||
b: &sockstats.SockStats{
|
||||
Stats: map[sockstats.Label]sockstats.SockStat{
|
||||
sockstats.LabelDERPHTTPClient: {
|
||||
TxBytes: 10,
|
||||
RxBytes: 30,
|
||||
TxBytesByInterface: map[string]uint64{
|
||||
"en0": 10,
|
||||
},
|
||||
RxBytesByInterface: map[string]uint64{
|
||||
"en0": 30,
|
||||
},
|
||||
},
|
||||
},
|
||||
Interfaces: []string{"en0"},
|
||||
},
|
||||
wantStats: map[sockstats.Label]deltaStat{
|
||||
sockstats.LabelDERPHTTPClient: {0, 20},
|
||||
|
Reference in New Issue
Block a user