perf(adapters): avoid eager Unicode schema cloning - #4526
Conversation
Co-authored-by: luvs01 <27862058+luvs01@users.noreply.github.com>
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: trueThanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
✅ Deterministic PR hygiene checks passed. |
⏳ DRAFT
What to do
Review readiness checklist
0/4 boxes ticked. This PR stays in draft until every box above is ticked. |
리뷰 · 우선순위 52 / 80이 PR은 이번 변경은 동작을 바꾸지 않는 복사 시점 최적화입니다. 스택으로 활성 경로만 따라가고, 실제로 패턴을 지운 조상 컨테이너만 복사합니다(copy-on-write). 안 바뀐 형제 객체는 같은 참조를 유지하고, 아무 것도 안 지웠으면 입력 객체 그대로를 반환합니다. name bag( 구조 문서 여덟 곳이 같은 한 줄을 가리키도록 갱신된 것은 이 저장소의 structure owner 매핑 규칙과 맞습니다. 회귀 테스트 두 개는 “넓은 스키마에서 안 바뀐 형제 정체성 유지”와 “배열 경로·리터럴 보존”을 직접 잠급니다. base는 지금 다만 이 PR은 아직 draft입니다. CodeRabbit도 draft라서 리뷰를 건너뛰었고, hygiene/label/enforce-target만 통과한 상태입니다. 작성자도 전체 크로스플랫폼 CI는 아직이라고 적었습니다. 라벨은 라인 - 메인테이너의 판단이 필요한 지점
너의 추천 이 댓글은 grok-bot이 작성했습니다 |
Summary
Unicode pattern normalization eagerly cloned every visited container and queued a closure for each sibling even when returning the original input on a no-op. Traverse iteratively and copy only containers on paths where an unsupported scalar pattern is removed. Unchanged siblings retain identity, the input stays unchanged, and existing name-bag, literal-value, protected-subtree and encrypted-marker behavior is preserved.
This is an allocation optimization, not a hard memory bound or a uniformly faster implementation. In isolated synthetic 25,000-field processes, three repeated runs measured median peak RSS of about 69→54 MiB for no-op input and 90→62 MiB with one changed pattern. Median invocation time was about 17.2→13.0 ms for no-op input, but 15.1→19.3 ms for changed input. Peak RSS includes the runtime and input; these measurements do not establish production frequency or total application savings. Schema size still determines traversal and changed-container copying cost.
Verification
bun test tests/adapters/openai/openai-chat-hardening.test.ts tests/responses/openai-responses-passthrough.test.ts: 290 pass, 0 fail, 200,888 assertions, including existing deep-schema and wire-contract cases.bun run typecheck,bun run structure:check,bun run privacy:scan, andgit diff --check: passed.Checklist
Review readiness checklist
Co-authored-by: luvs01 27862058+luvs01@users.noreply.github.com