Skip to content

perf(harness): parallel audience search under one global budget (#897 step 2) - #995

Open
jinon86 wants to merge 3 commits into
mainfrom
feat/897-parallel-search
Open

perf(harness): parallel audience search under one global budget (#897 step 2)#995
jinon86 wants to merge 3 commits into
mainfrom
feat/897-parallel-search

Conversation

@jinon86

@jinon86 jinon86 commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

#897 2단계 — 검색 병렬화 + 전역 예산

1단계(#991, 계측)가 머지됐으므로 이슈의 고정 순서상 다음 단계입니다.

변경

audience-private SessionStart의 4개 검색 레인(local 3s → recent 1s → shared 3s → legacy 2s, 직렬 최대 ~9초)을 병렬로 바꾸고, 대기는 전역 3초 예산(CCC_MEMORY_SEARCH_GLOBAL_TIMEOUT_SEC) 하나로 제한합니다.

  • 각 레인은 기존 inner 하드 타임아웃(SIGTERM→SIGKILL process group) 유지 — 바깥 대기가 끊겨도 무제한 검색이 고아로 남지 않음
  • CCC_MEMORY_SEARCH_PARALLEL=0이면 기존 직렬 경로 그대로 / EPOCHREALTIME 부재·mktemp 실패 시에도 직렬 블록으로 폴백 / 비audience 모드 무밀경
  • 1단계 계측과 연계: 병렬 모드는 search_parallel 통합 마크, 직렬 모드는 기존 레인별 마크 유지

실측 (2초/레인 스텁)

경로 총 훅 시간
직렬(기존) 8.07s
병렬(신규) 2.96s

검증

  • memory-hooks 신규 4건: 전 레인 병합, 통합 마크, 예산 컷(5초 지연 레인 제외하고 훅 완료), 직렬 폴백 — 47/47
  • ccc-memory 131/131, bash -n·diff --check 통과

후속

3단계(memory_render.py 통합 렌더)·4단계(setup.sh)는 별도 PR. 1단계 실측 데이터가 쌓이면 검증에 활용.

…step 2)

The audience-private SessionStart path ran four independent DB searches
serially (local 3s + recent 1s + shared 3s + legacy 2s = up to ~9s of the
15s hook budget). They now run concurrently and the hook waits on ONE
global budget (default 3s, CCC_MEMORY_SEARCH_GLOBAL_TIMEOUT_SEC); each
lane keeps its inner hard timeout (SIGTERM->SIGKILL process-group) so a
cut wait never orphans an unbounded search. CCC_MEMORY_SEARCH_PARALLEL=0
restores the serial path; without EPOCHREALTIME or on mktemp failure the
code falls back to the exact serial block; non-audience mode is unchanged.

Measured with a 2s-per-lane stub fixture: serial 8.1s -> parallel 3.0s.
The step-1 timing instrumentation gains a consolidated search_parallel
stage mark; serial mode keeps the per-lane marks.

Tests: memory-hooks suite gains parallel-merge, consolidated-mark,
budget-cut (stalled lane dropped, hook still completes) and serial-fallback
cases (47/47); ccc-memory 131/131.
@jinon86
jinon86 requested a review from seoseo-ai as a code owner August 6, 2026 16:28
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