Skip to content

Commit

Permalink
modify the path buckets mechanism
Browse files Browse the repository at this point in the history
  • Loading branch information
amitslavin committed Nov 26, 2023
1 parent 0384dc1 commit ca6fbbc
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 12 deletions.
4 changes: 2 additions & 2 deletions pkg/network/ebpf/c/protocols/http2/decoding.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 3 additions & 4 deletions pkg/network/protocols/http2/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
}
Expand Down Expand Up @@ -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
Expand Down
6 changes: 1 addition & 5 deletions pkg/network/protocols/http2/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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")}
}
Expand All @@ -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))
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/network/protocols/http2/types_linux.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ca6fbbc

Please sign in to comment.