Skip to content

perf(proxy): 쿼리 및 I/O 최적화 [DON-80]#38

Merged
dongwonkwak merged 6 commits intomainfrom
perf/DON-80-proxy-query-optimization
Mar 9, 2026
Merged

perf(proxy): 쿼리 및 I/O 최적화 [DON-80]#38
dongwonkwak merged 6 commits intomainfrom
perf/DON-80-proxy-query-optimization

Conversation

@dongwonkwak
Copy link
Copy Markdown
Owner

변경 사항

  • 쿼리 파서 핫패스에서 regex 제거 및 JSON 직렬화 최적화
  • RelayBuffer를 통한 서버 응답 I/O 최적화
  • Scatter-gather I/O를 이용한 다중 버퍼 송수신
  • 클라이언트 버퍼 읽기 및 세션 I/O 성능 개선
  • 미사용 SQL 인젝션 탐지기 제거
  • UDS 테스트 안정성 개선 및 CI clang-format 훅 호환성 정리

관련 이슈

DON-80

테스트

  • 기존 단위 테스트 통과
  • UDS 서버 테스트 안정화
  • 성능 벤치마크 검증

문서 영향 분석

  • 문서 영향: [x] 있음 [ ] 없음
  • 영향 문서 후보: docs/architecture.md, docs/failure-modes.md, docs/threat-model.md
  • 실제 수정 문서: docs/architecture.md, docs/failure-modes.md, docs/threat-model.md

체크리스트

  • clang-tidy 통과
  • ASan/TSan 클린
  • 단위 테스트 통과
  • 문서 영향 분석 완료
  • 영향 문서 수정 또는 `Docs-Impact` 예외 사유 명시
  • CLAUDE.md 규칙 준수

@codex review

Codex 리뷰 지침: 한글로 리뷰를 작성해주세요. 보안/성능/C++ 품질/Go 품질/테스트 관점에서 리뷰해주세요.

dongwonkwak and others added 5 commits March 9, 2026 08:00
sql_parser에서 std::regex 3곳 제거하고 수동 문자열 파싱으로 교체하여
쿼리당 200-2500µs regex 컴파일 비용 제거. injection_detector에 fast
anchor 사전필터 추가. structured_logger ostringstream을 string 직접
조립으로 교체.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
relay_server_response에서 패킷별 개별 read/write 대신 버퍼링된
읽기(64KB 청크) + 쓰기 배치(flush) + 제로카피 패킷 뷰를 적용하여
코루틴 서스펜션 횟수를 대폭 감소. 17-패킷 result set 기준
51 suspend → 2-3 suspend. MysqlPacket parse/serialize 왕복 복사 제거.

벤치마크 결과:
- oltp_read_only TPS: 297 → 1,225 (4.1x 개선)
- oltp_read_write TPS: 251 → 646 (2.6x 개선)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- write_packet_raw: pkt.serialize() 벡터 할당+복사 → scatter-gather I/O로 교체
  (스택 헤더 + payload span 직접 전송)
- ClientReadBuffer: 클라이언트 패킷 읽기를 async_read×2 → async_read_some×1로 개선
  (16KB 버퍼링으로 per-query syscall 절감)
- injection_detector_.check(), proc_detector_.detect() 호출 제거
  (결과가 [[maybe_unused]]로 정책 엔진 미사용, 향후 재활성화 가능)
- COM_QUIT 경로도 write_packet_raw 사용으로 serialize() 제거

벤치마크 결과 (4 threads, 30s):
  oltp_read_only:  TPS 1,042~1,283 (PASS ≥1,000)
  oltp_read_write: P95 overhead 9~13% (≤10% 달성 구간 진입)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Docs-Impact: none
Docs-Impact-Reason: doc-already-updated
@dongwonkwak dongwonkwak self-assigned this Mar 9, 2026
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3486af7ea5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/proxy/session.cpp
@dongwonkwak dongwonkwak merged commit 62a2251 into main Mar 9, 2026
10 checks passed
@dongwonkwak dongwonkwak deleted the perf/DON-80-proxy-query-optimization branch March 9, 2026 11:21
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