Skip to content

Function ParseKeyValue has performance Bottleneck: Inefficient String Concatenation #46007

@zhaojinxin409

Description

@zhaojinxin409

Component(s)

No response

Is your feature request related to a problem? Please describe.

The SplitString function has a significant performance bottleneck caused by inefficient string concatenation when processing long input strings. This leads to excessive memory allocations and high GC pressure, resulting in degraded performance (especially with strings longer than 1KB).

Test Case:

processors:
  transform/standard:
    error_mode: silent
    log_statements:
      - context: log
        statements:
          - set(attributes["log.type"], "test")
          - merge_maps(cache, ParseKeyValue(body), "upsert")

service:
  pipelines:
    logs/main:
      receivers: [filelog/log_file]
      processors: [transform/standard]
      exporters: [debug]

This is the cpu profile of otel collector
Image

Image

Describe the solution you'd like

use strings.Builder instead

Describe alternatives you've considered

No response

Additional context

Use strings.Builder

Tip

React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions