diff options
author | Ondrej Fabry <ofabry@cisco.com> | 2019-09-17 12:41:47 +0200 |
---|---|---|
committer | Ondrej Fabry <ofabry@cisco.com> | 2019-10-03 12:54:22 +0200 |
commit | 809b69ea4a90455445c34bbad7d8e5fea5cf3462 (patch) | |
tree | ba4b94339ac83908e2d9933692dc373929380aa7 /adapter/vppapiclient | |
parent | 48198748bdfcc7d30c794cdac19de822da53f840 (diff) |
Optimizations for statsclient
- this dramatically improves performance for stats data collection
- memory allocation is now done only when stat dirs change
- updating prepared stat dir does not need to allocate memory
- created integration test for testing stats client
- added NumWorkerThreads and VectorRatePerWorker to SystemStats
- added ReduceSimpleCounterStatIndex, ReduceCombinedCounterStatIndex for
aggregating specific index
Change-Id: I702731a69024ab5dd0832bb5cfe2773a987359e5
Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
Diffstat (limited to 'adapter/vppapiclient')
-rw-r--r-- | adapter/vppapiclient/stat_client.go | 28 | ||||
-rw-r--r-- | adapter/vppapiclient/stat_client_stub.go | 10 |
2 files changed, 27 insertions, 11 deletions
diff --git a/adapter/vppapiclient/stat_client.go b/adapter/vppapiclient/stat_client.go index 0ab088c..bf19c45 100644 --- a/adapter/vppapiclient/stat_client.go +++ b/adapter/vppapiclient/stat_client.go @@ -86,7 +86,7 @@ func (c *statClient) Disconnect() error { func (c *statClient) ListStats(patterns ...string) (stats []string, err error) { dir := C.govpp_stat_segment_ls(convertStringSlice(patterns)) if dir == nil { - return nil, adapter.ErrStatDirBusy + return nil, adapter.ErrStatsDataBusy } defer C.govpp_stat_segment_vec_free(unsafe.Pointer(dir)) @@ -100,16 +100,16 @@ func (c *statClient) ListStats(patterns ...string) (stats []string, err error) { return stats, nil } -func (c *statClient) DumpStats(patterns ...string) (stats []*adapter.StatEntry, err error) { +func (c *statClient) DumpStats(patterns ...string) (stats []adapter.StatEntry, err error) { dir := C.govpp_stat_segment_ls(convertStringSlice(patterns)) if dir == nil { - return nil, adapter.ErrStatDirBusy + return nil, adapter.ErrStatsDataBusy } defer C.govpp_stat_segment_vec_free(unsafe.Pointer(dir)) dump := C.govpp_stat_segment_dump(dir) if dump == nil { - return nil, adapter.ErrStatDumpBusy + return nil, adapter.ErrStatsDataBusy } defer C.govpp_stat_segment_data_free(dump) @@ -120,8 +120,8 @@ func (c *statClient) DumpStats(patterns ...string) (stats []*adapter.StatEntry, name := C.GoString(nameChar) typ := adapter.StatType(C.govpp_stat_segment_data_type(&v)) - stat := &adapter.StatEntry{ - Name: name, + stat := adapter.StatEntry{ + Name: []byte(name), Type: typ, } @@ -147,10 +147,10 @@ func (c *statClient) DumpStats(patterns ...string) (stats []*adapter.StatEntry, vector := make([][]adapter.CombinedCounter, length) for k := 0; k < length; k++ { for j := 0; j < int(C.govpp_stat_segment_vec_len(unsafe.Pointer(C.govpp_stat_segment_data_get_combined_counter_index(&v, C.int(k))))); j++ { - vector[k] = append(vector[k], adapter.CombinedCounter{ - Packets: adapter.Counter(C.govpp_stat_segment_data_get_combined_counter_index_packets(&v, C.int(k), C.int(j))), - Bytes: adapter.Counter(C.govpp_stat_segment_data_get_combined_counter_index_bytes(&v, C.int(k), C.int(j))), - }) + vector[k] = append(vector[k], adapter.CombinedCounter([2]uint64{ + uint64(C.govpp_stat_segment_data_get_combined_counter_index_packets(&v, C.int(k), C.int(j))), + uint64(C.govpp_stat_segment_data_get_combined_counter_index_bytes(&v, C.int(k), C.int(j))), + })) } } stat.Data = adapter.CombinedCounterStat(vector) @@ -180,6 +180,14 @@ func (c *statClient) DumpStats(patterns ...string) (stats []*adapter.StatEntry, return stats, nil } +func (c *statClient) PrepareDir(prefixes ...string) (*adapter.StatDir, error) { + return nil, adapter.ErrNotImplemented +} + +func (c *statClient) UpdateDir(dir *adapter.StatDir) error { + return adapter.ErrNotImplemented +} + func convertStringSlice(strs []string) **C.uint8_t { var arr **C.uint8_t for _, str := range strs { diff --git a/adapter/vppapiclient/stat_client_stub.go b/adapter/vppapiclient/stat_client_stub.go index 57792f3..c764391 100644 --- a/adapter/vppapiclient/stat_client_stub.go +++ b/adapter/vppapiclient/stat_client_stub.go @@ -40,6 +40,14 @@ func (*stubStatClient) ListStats(patterns ...string) (statNames []string, err er return nil, adapter.ErrNotImplemented } -func (*stubStatClient) DumpStats(patterns ...string) ([]*adapter.StatEntry, error) { +func (*stubStatClient) DumpStats(patterns ...string) ([]adapter.StatEntry, error) { return nil, adapter.ErrNotImplemented } + +func (*stubStatClient) PrepareDir(prefixes ...string) (*adapter.StatDir, error) { + return nil, adapter.ErrNotImplemented +} + +func (*stubStatClient) UpdateDir(dir *adapter.StatDir) error { + return adapter.ErrNotImplemented +} |