Skip to content

⚡ Optimize string accumulation in ExtractTopology#8

Merged
xkilldash9x merged 3 commits intomainfrom
perf/optimize-topology-string-allocs-5495069235814211934
Feb 4, 2026
Merged

⚡ Optimize string accumulation in ExtractTopology#8
xkilldash9x merged 3 commits intomainfrom
perf/optimize-topology-string-allocs-5495069235814211934

Conversation

@xkilldash9x
Copy link
Copy Markdown
Collaborator

💡 What: Optimized string literal concatenation in ExtractTopology by avoiding intermediate []byte allocations and refactoring the logic into a helper function flattenStringLiterals.
🎯 Why: The previous implementation allocated a new byte slice for each string literal ([]byte(s)), which could be inefficient for functions with many string literals.
📊 Measured Improvement:
Benchmark showed comparable performance (approx 122k ns/op vs 123k ns/op) and identical memory allocation count (1 alloc/op). This indicates the Go 1.24 compiler likely already optimized the []byte(s) conversion in the append context. However, the change makes the code more idiomatic (append(b, s...)) and guarantees zero intermediate allocation regardless of compiler optimization levels. A new benchmark BenchmarkFlattenStringLiterals was added to verify this.


PR created automatically by Jules for task 5495069235814211934 started by @xkilldash9x

… allocations

Co-authored-by: xkilldash9x <223238109+xkilldash9x@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

google-labs-jules Bot and others added 2 commits February 2, 2026 08:00
… allocations

Co-authored-by: xkilldash9x <223238109+xkilldash9x@users.noreply.github.com>
Co-authored-by: xkilldash9x <223238109+xkilldash9x@users.noreply.github.com>
@xkilldash9x xkilldash9x merged commit a1db95a into main Feb 4, 2026
1 of 2 checks passed
@xkilldash9x xkilldash9x deleted the perf/optimize-topology-string-allocs-5495069235814211934 branch February 4, 2026 12:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant