Upgrade to Pro — share decks privately, control downloads, hide ads and more …

プロファイルとAIエージェントによる効率的なデバッグ / Effective debuggin...

Avatar for ymotongpoo ymotongpoo
October 27, 2025

プロファイルとAIエージェントによる効率的なデバッグ / Effective debugging with profiler and AI assistant

Observability Conference Tokyo 2025での登壇資料です。
https://o11ycon.jp/#timetable?session=1017779

プロファイルがあることで性能改善の最後の1ステップが可能だし、それはAIアシスタントを使うとより簡単にできるよ、という話をしています。

Avatar for ymotongpoo

ymotongpoo

October 27, 2025
Tweet

More Decks by ymotongpoo

Other Decks in Technology

Transcript

  1. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 1 © 2025, Amazon Web Services, Inc. or its affiliates. All rights reserved. プロファイルとAIエージェント による効率的なデバッグ Yoshi Yamaguchi (@ymotongpoo) O B S E R V A B I L I T Y C O N F E R E N C E T O K Y O Senior Developer Advocate Amazon Web Services Japan, G.K.
  2. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 2 © 2025, Amazon Web Services, Inc. or its affiliates. All rights reserved. ⾃⼰紹介 ⼭⼝ 能迪(やまぐち よしふみ) アマゾンウェブサービスジャパン合同会社 シニアデベロッパーアドボケイト 専⾨領域 • オブザーバビリティ • SRE全般 @ymotongpoo
  3. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 3 もくじ 1. プロファイルとは 2. なぜプロファイルが重要なのか 3. プロファイルを使った従来のデバッグ⽅法 4. AIエージェントによる⽀援
  4. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 4 © 2025, Amazon Web Services, Inc. or its affiliates. All rights reserved. プロファイルとは
  5. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 5 プロファイル profile とは 通常はパフォーマンスプロファイルのことを指す • プログラムのリソース消費を詳細に調査するための⼿法 • 統計的に特定の数値をコールスタック(関数)レベルで取得する • 有名なツールには Java Flight Recorder (Java)、cProfile (Python)、perf (Linux) な どがある c.f. トレース (strace, dtrace)
  6. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 6 © 2025, Amazon Web Services, Inc. or its affiliates. All rights reserved. なぜプロファイルが 重要なのか
  7. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 7 例: レイテンシーに関する問題 問: あるサービスでレイテンシーに関する問題が発⽣してるように⾒える。 原因を特定し、アプリケーション内の該当のコードを変更してください。
  8. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 8 メトリクス たとえば CPU 負荷が⾼まったとして、それはインスタンス全体 or サービス全体 CPU使⽤率
  9. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 9 トレース • 計装したスコープレベル(たいてい関数)でしか確認できない • イベントごとにしか確認できない profileHandler getProfile getActivity db.QueryActivity db.QueryProfile
  10. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 10 ログ 特にレイテンシーが遅いだけの場合、⼀⾒するとエラーメッセージが出⼒されない 10:23:42.46 DEBUG [getProfile] user 12345 10:23:42.47 DEBUG [getActivity] 34 activities 10:23:44.50 DEBUG [getActivity] done 10:24:30.12 DEBUG [getProfile] user 98765 10:24:37.47 DEBUG [getActivity] 18 activities 10:24:50.50 DEBUG [getActivity] done
  11. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 11 ⽬的と現状と理想 ⽬的: パフォーマンス問題の原因を特定し、修正する 現状: 原因を特定する上でのピントがぼやけている状態 理想: 修正すべき箇所をコード⾏レベルで特定できる 「オブザーバビリティとは、外部出⼒の知識からシステムの内部状態を どれだけうまく推測できるかの尺度」
  12. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 12 メトリクス 全体的な指標の 時系列変化の把 握 分散トレース プロファイル ラスト1ステップにプロファイルが必要 オブザーバビリティのギャップを埋める⼤きなピース 分散システム内 のサービスの性 能劣化を把握 ログ 特定のイベントに対する 詳細を把握 スタック内のリソース 消費を統計的に把握 システムトレース インスタンスでの低レベルな リソース消費イベントの詳細 を把握 ダンプ 特定の瞬間のメモリやスタック の状況を把握 関数単位 ⾏単位 サービス単位 計装単位
  13. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 13 © 2025, Amazon Web Services, Inc. or its affiliates. All rights reserved. プロファイルを使った 従来のデバッグ⽅法
  14. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 14 他のテレメトリーの利⽤⽅法と同じ 1. 計装 2. テレメトリーの収集 3. 分析
  15. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 15 計装 計装はライブラリ依存 Go (pprof) Python (line_profiler)
  16. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 16 実際は継続的プロファイルが有効 常時稼働のサービスの場合パフォーマンスの問題は突然やってくる CPU使⽤率 ここで気がついたとしても ここでしか取れないことがある
  17. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 17 なぜ継続的プロファイルなのか それにそなえて定期的にプロファイルを取得してバックエンドに送信しておく CPU使⽤率
  18. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 18 収集できました (Amazon Managed Grafana の例) 継続的にプロファイルを収集して、スタックのリソース消費がわかるようになった
  19. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 19 これ解析できますか︖ どの⾏を修正したら良いんでしたっけ︖
  20. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 20 分析するには技術や知識が必要 プロファイル ソースコード 低レイヤーの知識
  21. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 21 先程の例の場合 1/2 1. システムコールが呼ばれすぎてる 2. 多分 cut の中でファイルの読み込みの効率が悪い
  22. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 22 先程の例の場合 2/2 func cut(filename string, delimiter byte, field int, quiet bool) { f, err := os.Open(filename) if err != nil { log.Fatalf("Could not open file %q: %v", filename, err) } defer f.Close() infield := false pos := field - 1 s := []byte{} for { var buf [1]byte _, err := f.Read(buf[:]) if err == io.EOF { break } ...(略)... 1バイトごとReadしてる
  23. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 23 © 2025, Amazon Web Services, Inc. or its affiliates. All rights reserved. AIエージェントによる⽀援
  24. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 24 現状のLLMは開発より運⽤に有利(イメージ) 開発 LLM コンテキスト 指⽰ 出⼒ 運⽤ LLM コンテキスト 指⽰ 出⼒ 分析や調査に近い
  25. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 25 テレメトリー=コンテキスト プロファイルの知識 計算機科学の知識 ⼀般的なコーディング ソースコード プロファイル 仕様 ボトルネックの 改善 改善案の提⽰ テレメトリーが個別事例を表 現するコンテキストとなる
  26. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 27 プロファイルの可視化の⽅法を理解している Amazon Q Developer
  27. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 28 可視化した内容がコンテキストに追加される
  28. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 29 main.cut に原因があることを理解し、更に深堀りしている
  29. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 30 原因を理解し、解説してくれている その修正案を提⽰
  30. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 32 まとめ • 開発のための最後の1ステップとして(継続的)プロファイルが有⽤ • 従来ではプロファイルを活かすには知識が必要だった • LLMがプロファイルの活⽤をサポートし、開発を加速してくれる
  31. © 2025, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 33 Thank you! © 2025, Amazon Web Services, Inc. or its affiliates. All rights reserved. Yoshi Yamaguchi @ymotongpoo Any questions?