상품 페이지를 스트리밍 가지치기로 받아 수신 단계에서 메모리 바운드 - #48
Open
m-a-king wants to merge 1 commit into
Open
Conversation
- 응답을 전부 메모리에 올린 뒤 자르던 것을, jsoup StreamParser 로 흘리며 하류가 읽지 않을 노드(style·주석·데이터 아닌 script)를 닫히는 즉시 버리는 방식으로 교체 - 원안(#47)은 Content-Length 검사 + 상한 초과 시 payload-too-large 실패였으나 두 이유로 전환. 실패는 지금 앞부분으로 추출에 성공하던 페이지를 확정 실패로 바꾸고 새 permanent code 가 infra→core→extractor 3 repo 순차 PR 을 부른다. 절단도 마찬가지로 손해다 - sanitize 가 절단을 LLM 직전으로 미뤄 둔 이유가 코드에 적혀 있듯, JS·style 을 걷어낸 뒤라야 같은 길이에 상품 정보가 더 담긴다. 가지치기는 버리는 대상이 어차피 하류가 버릴 것들이라 둘 다 피한다 - 작업 중 발견한 함정: StructuredDataExtractor 가 일반 JS script 를 훑어 window.__PRELOADED_STATE__ 를 찾는다(유니클로 계열). "데이터 script 아니면 버린다"로 짰다면 그 경로가 조용히 깨졌다. 보존 규칙이 두 벌(수신용·LLM 입력용) 이라는 사실을 DataScripts 에 박고, 표지 상수는 그것을 찾는 쪽이 소유하게 함 - Content-Type 게이트 신설. 지금까지 검사가 0건이라 링크가 50MB mp4·zip 을 가리켜도 전부 받았다. recall 보호를 위해 명백한 바이너리만 막고 미상은 통과 - PageContent 가 String 대신 Document 를 든다. 하류가 전부 Document 를 원해 문자열은 중간 표현일 뿐이었고, 그 결과 HtmlSnapshotPipeline 과 EmptyShellDetector 가 같은 HTML 을 두 번 파싱하던 것도 사라짐 - 상한은 둘. 와이어 바이트(끝나지 않는 스트림용, 해제 후 바이트에 걸린다)와 보존분 문자(가지쳐도 안 줄어드는 문서용). 정상 페이지는 어느 쪽에도 안 닿는다
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: Thanks 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Situation
Task
원래 이슈는 "받은 뒤 자르는 지점을 앞당기자"였다. 그런데 자르는 것 자체가 손해라는 게 드러나면서, "다 받은 뒤 어떻게 자르나"가 아니라 "다 안 받는다" 로 문제를 다시 잡았다.
제약 둘: 절단도 실패도 recall 을 깎는다. 그리고 새 실패 code 를 만들면 3 repo 순차 PR 이 된다.
Action
접근 선택
수신 단계
조용히 깨질 뻔한 자리
구조 정리
구현 좌표
PruningHtmlParserHttpPageFetcher(toEntity→exchange),FetchProperties(maxFetchBytes신설,maxFetchChars→maxRetainedChars)PageContent(String → Document + retainedChars),DataScripts(retainForParsing),StructuredDataExtractor(표지 상수 공개)HtmlSnapshotPipeline,EmptyShellDetector,DefaultProductLinkExtractor,HttpHeadlessRenderer,HeadlessExtractionPropertiesResult
연관 이슈