From ca6fbbc422f3e2fabee95e9cc88f81d7163cd666 Mon Sep 17 00:00:00 2001 From: "amit.slavin" Date: Sun, 26 Nov 2023 11:32:52 +0200 Subject: [PATCH] modify the path buckets mechanism --- pkg/network/ebpf/c/protocols/http2/decoding.h | 4 ++-- pkg/network/protocols/http2/protocol.go | 7 +++---- pkg/network/protocols/http2/telemetry.go | 6 +----- pkg/network/protocols/http2/types_linux.go | 2 +- 4 files changed, 7 insertions(+), 12 deletions(-) diff --git a/pkg/network/ebpf/c/protocols/http2/decoding.h b/pkg/network/ebpf/c/protocols/http2/decoding.h index b20cc42431bc7..fc7fcaf4c817d 100644 --- a/pkg/network/ebpf/c/protocols/http2/decoding.h +++ b/pkg/network/ebpf/c/protocols/http2/decoding.h @@ -119,8 +119,8 @@ READ_INTO_BUFFER(path, HTTP2_MAX_PATH_LEN, BLK_SIZE) // update_path_size_telemetry updates the path size telemetry. static __always_inline void update_path_size_telemetry(http2_telemetry_t *http2_tel, __u64 size) { - __s64 bucket_idx = (size - HTTP2_MAX_PATH_LEN) / 10; - bucket_idx = bucket_idx > 6 ? 6 : bucket_idx; + __s64 bucket_idx = (size - 120) / 10; + bucket_idx = bucket_idx > 4 ? 4 : bucket_idx; bucket_idx = bucket_idx < 0 ? 0 : bucket_idx; __sync_fetch_and_add(&http2_tel->path_size_bucket[bucket_idx], 1); diff --git a/pkg/network/protocols/http2/protocol.go b/pkg/network/protocols/http2/protocol.go index 6f3f81aeffbb0..8ce5daf8e0bc9 100644 --- a/pkg/network/protocols/http2/protocol.go +++ b/pkg/network/protocols/http2/protocol.go @@ -214,6 +214,7 @@ func (p *protocol) PostStart(mgr *manager.Manager) error { // Setup map cleaner after manager start. ticker := time.NewTicker(10 * time.Second) http2Telemetry := &HTTP2Telemetry{} + var zero uint32 mp, _, err := mgr.GetMap(telemetryMap) if err != nil { @@ -225,7 +226,7 @@ func (p *protocol) PostStart(mgr *manager.Manager) error { for { select { case <-ticker.C: - p.updateKernelTelemetry(http2Telemetry, mp) + p.updateKernelTelemetry(http2Telemetry, mp, zero) case <-p.done: return } @@ -379,9 +380,7 @@ func (p *protocol) GetStats() *protocols.ProtocolStats { } // updateKernelTelemetry updates the HTTP/2 kernel telemetry. -func (p *protocol) updateKernelTelemetry(http2Telemetry *HTTP2Telemetry, mp *ebpf.Map) { - var zero uint32 - +func (p *protocol) updateKernelTelemetry(http2Telemetry *HTTP2Telemetry, mp *ebpf.Map, zero uint32) { if err := mp.Lookup(unsafe.Pointer(&zero), unsafe.Pointer(http2Telemetry)); err != nil { log.Warnf("unable to lookup http2 telemetry map: %s", err) return diff --git a/pkg/network/protocols/http2/telemetry.go b/pkg/network/protocols/http2/telemetry.go index 6eb3bf998f8e5..d62f6a359a967 100644 --- a/pkg/network/protocols/http2/telemetry.go +++ b/pkg/network/protocols/http2/telemetry.go @@ -34,10 +34,8 @@ type kernelTelemetry struct { pathSizeBucket3 *libtelemetry.Counter // pathSizeBucket4 Count of path sizes between 151-160 bytes pathSizeBucket4 *libtelemetry.Counter - // pathSizeBucket5 Count of path sizes between 161-179 bytes + // pathSizeBucket5 Count of path sizes greater then 160 pathSizeBucket5 *libtelemetry.Counter - // pathSizeBucket6 Count of path is larger or equal to 180 - pathSizeBucket6 *libtelemetry.Counter // pathExceedsFrame Count of times we couldn't retrieve the path due to reaching the end of the frame. pathExceedsFrame *libtelemetry.Counter // exceedingMaxInterestingFrames Count of times we reached the max number of frames per iteration. @@ -63,7 +61,6 @@ func newHTTP2KernelTelemetry() *kernelTelemetry { pathSizeBucket3: metricGroup.NewCounter("path_size_bucket_3"), pathSizeBucket4: metricGroup.NewCounter("path_size_bucket_4"), pathSizeBucket5: metricGroup.NewCounter("path_size_bucket_5"), - pathSizeBucket6: metricGroup.NewCounter("path_size_bucket_6"), exceedingMaxInterestingFrames: metricGroup.NewCounter("exceeding_max_interesting_frames"), exceedingMaxFramesToFilter: metricGroup.NewCounter("exceeding_max_frames_to_filter")} } @@ -81,7 +78,6 @@ func (t *kernelTelemetry) update(tel *HTTP2Telemetry) { t.pathSizeBucket3.Add(int64(tel.Path_size_bucket[3])) t.pathSizeBucket4.Add(int64(tel.Path_size_bucket[4])) t.pathSizeBucket5.Add(int64(tel.Path_size_bucket[5])) - t.pathSizeBucket6.Add(int64(tel.Path_size_bucket[6])) t.exceedingMaxInterestingFrames.Add(int64(tel.Exceeding_max_interesting_frames)) t.exceedingMaxFramesToFilter.Add(int64(tel.Exceeding_max_frames_to_filter)) } diff --git a/pkg/network/protocols/http2/types_linux.go b/pkg/network/protocols/http2/types_linux.go index 6844ee603e0c0..f2a70f4b24cbe 100644 --- a/pkg/network/protocols/http2/types_linux.go +++ b/pkg/network/protocols/http2/types_linux.go @@ -56,7 +56,7 @@ type HTTP2Telemetry struct { Path_exceeds_frame uint64 Exceeding_max_interesting_frames uint64 Exceeding_max_frames_to_filter uint64 - Path_size_bucket [7]uint64 + Path_size_bucket [6]uint64 } type StaticTableEnumValue = uint8