Skip to content

Review all usages of fmt.Sprintf() or similar fmt function inside hot paths #19571

@christarazi

Description

@christarazi

fmt.Sprintf() is well-known for not being opimal in terms of CPU and memory allocations. If these functions are called in hot paths such as pkg/policy/api or even parts of pkg/policy, it can be quite impactful, especially in environments that experience high or bursty churn.

Writing a benchmark and replacing the current code with strings.Builder or bytes.NewBuffer can show us if we can achieve some quick wins.

Some examples:

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/agentCilium agent related.help-wantedPlease volunteer for this by adding yourself as an assignee!kind/enhancementThis would improve or streamline existing functionality.kind/performanceThere is a performance impact of this.staleThe stale bot thinks this issue is old. Add "pinned" label to prevent this from becoming stale.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions