Skip to content

perf: optimize repetition detection for high-frequency streaming #55

Closed

Description

@terisuke

背景

GLM-5.1 thinking corruption fix(Issue #52)でrepetition detectionを実装。

問題

現在のdetectRepetition()はO(n*m)で���全てのtext-deltaイベントで呼ばれる。
高速ストリーミング時に性能影響の可能性がある。

対策案

  • N文字蓄積ごとにチェック(例:500文字ごと)
  • Rolling hashアルゴリズムの採用
  • キャッシュベースの最適化

現状

実測では1ms以下で完了するため、現時点ではブロッカーではない。
高速モデル(GPT-5.x等)での負荷テスト後に再評価。

関連

Activity

  1. terisuke commented on Apr 5, 2026

    @terisuke
    Author

    進捗更新: detectRepetition は repetition.ts に抽出済み (PR #70)。ただしアルゴリズム自体は同一のネステッドスキャンのまま (repetition.ts:8)、processor.ts:162,373 で毎 delta 呼び出し。性能最適化は未着手。

  2. terisuke commented on Apr 6, 2026

    @terisuke
    Author

    Note: upstream/dev has the repetition detection removal in preparation on feature branches (not yet merged to dev). When upstream merges, repetition.ts will be deleted. No optimization needed.

  3. terisuke commented on Apr 8, 2026

    @terisuke
    Author

    Closing as won't-fix for now. Per the issue body itself:

    実測では1ms以下で完了するため、現時点ではブロッカーではない。
    高速モデル(GPT-5.x等)での負荷テスト後に再評価。

    The repetition detection runs in sub-millisecond time. No measurable performance impact observed with current models (GPT-5.4, GLM-5.1, Claude Sonnet 4.5). If future high-speed models expose latency, reopen with profiling data.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions