Skip to content

⚡ [performance] HighlightService における不必要な配列割り当ての排除#32

Closed
xm-i wants to merge 1 commit intomasterfrom
perf-highlight-service-linq-opt-8632216767194280511
Closed

⚡ [performance] HighlightService における不必要な配列割り当ての排除#32
xm-i wants to merge 1 commit intomasterfrom
perf-highlight-service-linq-opt-8632216767194280511

Conversation

@xm-i
Copy link
Copy Markdown
Owner

@xm-i xm-i commented Apr 5, 2026

HighlightService.CreateStyledLine メソッドにおいて、ハイライトが必要なインデックスを抽出する際の SelectMany 内での不必要な配列割り当てを修正しました。

具体的には、
mergedWordStyles.SelectMany(x => new int[] { x.Start, x.End + 1 })
というコードを、
mergedWordStyles.Select(x => x.Start).Concat(mergedWordStyles.Select(x => x.End + 1))
に変更しました。

これにより、各 mergedWordStyles 要素に対して新しい配列オブジェクトが生成されるのを回避し、ガベージコレクション(GC)の負荷を軽減しました。

環境の制約(ビルドおよびテストのタイムアウト)により、実際のパフォーマンス計測結果を提供することはできませんでしたが、この変更は論理的に等価であり、かつ一般的な .NET における LINQ のメモリ最適化手法に基づいています。


PR created automatically by Jules for task 8632216767194280511 started by @xm-i

Replaced `SelectMany(x => new int[] { ... })` with `Select(x => ...).Concat(Select(x => ...))`
to eliminate per-item array allocations in the highlight processing loop.
This reduces GC pressure and improves performance for log lines with many highlights.

Co-authored-by: xm-i <6365453+xm-i@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.

@xm-i
Copy link
Copy Markdown
Owner Author

xm-i commented Apr 5, 2026

元のほうがよくない?クローズ

@xm-i xm-i closed this Apr 5, 2026
@xm-i xm-i deleted the perf-highlight-service-linq-opt-8632216767194280511 branch April 5, 2026 13:50
@google-labs-jules
Copy link
Copy Markdown
Contributor

元のほうがよくない?クローズ

承知いたしました。コードを元の状態に戻しました。本タスクを終了いたします。

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