Skip to content

perf: amortize repeated scalar concat-assignment growth #1298

Description

@fglock

Repeated Perl concat-assignment (for example, building a parser token one character at a time with .=) currently risks copying the complete Java String prefix on every append. This produces quadratic time and can turn ordinary multi-megabyte inputs into apparent hangs.

The immediate Selenium::Remote::Driver regression provides a concrete example: JSON::PP decodes a 3.4 MB mocked response with an escaped body using repeated scalar appends.

Investigate a runtime-level amortized representation for ordinary growing string scalars, with materialization at observable boundaries. Preserve Perl behavior for aliases, UTF-8 versus byte-string flags, tied and overloaded scalars, scalar magic/watchers, serialization, and both JVM and interpreter backends.

Acceptance criteria:

  • Repeated .= growth is linear or amortized-linear for plain strings.
  • Existing scalar semantics remain unchanged at read, assignment, and interop boundaries.
  • Include focused performance/regression coverage and benchmarks for parser-style large inputs.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:performancePerformance optimization and hangsarea:runtimeCore Perl runtime semanticsenhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions