-
Notifications
You must be signed in to change notification settings - Fork 0
⚡ Bolt: 대용량 파일 업로드 청크 크기 증가로 컨텍스트 스위칭 오버헤드 감소 #776
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
8ac0677
⚡ Bolt: 대용량 파일 업로드 청크 크기 증가로 컨텍스트 스위칭 오버헤드 감소
seonghobae 49a423b
일시적인 Noema CI 인프라 오류 해결을 위한 빈 커밋 추가
seonghobae 77bd680
일시적인 Noema CI 인프라 오류 해결을 위한 빈 커밋 추가
seonghobae b730bfb
일시적인 Noema CI 인프라 오류 해결을 위한 빈 커밋 추가
seonghobae 896dc20
Trivy 스캔 실패 해결을 위한 pypdf 6.16.2 버전 업데이트
seonghobae File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,6 +42,7 @@ | |
| from .service import parse_pdf | ||
|
|
||
| MAX_PARSE_UPLOAD_BYTES = 20 * 1024 * 1024 | ||
| UPLOAD_READ_CHUNK_SIZE_BYTES = 1024 * 1024 | ||
| MAX_AUTHORIZATION_HEADER_BYTES = MAX_BEARER_HEADER_BYTES | ||
| UNSUPPORTED_MEDIA_DETAIL = "Unsupported Media Type" | ||
| PAYLOAD_TOO_LARGE_DETAIL = "Payload Too Large" | ||
|
|
@@ -252,7 +253,7 @@ async def parse( | |
| temporary_file.write(header) | ||
|
|
||
| bytes_read = len(header) | ||
| while chunk := await file.read(8192): | ||
| while chunk := await file.read(UPLOAD_READ_CHUNK_SIZE_BYTES): | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| bytes_read += len(chunk) | ||
| if bytes_read > MAX_PARSE_UPLOAD_BYTES: | ||
| LOGGER.warning( | ||
|
|
||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ | |
| from newsdom_api import mineru_runner | ||
| from newsdom_api.main import ( | ||
| MAX_PARSE_UPLOAD_BYTES, | ||
| UPLOAD_READ_CHUNK_SIZE_BYTES, | ||
| app, | ||
| parse, | ||
| _validate_pdf_structure, | ||
|
|
@@ -30,7 +31,7 @@ def __exit__(self, exc_type, exc, tb): | |
| class _ReadTrackingUpload: | ||
| content_type = "application/pdf" | ||
| filename = "fixture.pdf" | ||
| size = 10 * 1024 * 1024 | ||
| size = 10 * UPLOAD_READ_CHUNK_SIZE_BYTES | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| def __init__(self, payload: bytes): | ||
| self._payload = payload | ||
|
|
@@ -385,7 +386,7 @@ def test_parse_endpoint_rejects_missing_magic_bytes(): | |
|
|
||
| @pytest.mark.asyncio | ||
| async def test_parse_endpoint_rejects_magic_bytes_before_full_read(): | ||
| upload = _ReadTrackingUpload(b"MZ\x90\x00\x03" + (b"x" * 1024 * 1024)) | ||
| upload = _ReadTrackingUpload(b"MZ\x90\x00\x03" + (b"x" * UPLOAD_READ_CHUNK_SIZE_BYTES)) | ||
|
|
||
| with pytest.raises(HTTPException) as exc_info: | ||
| await parse(upload) | ||
|
|
||
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
헤딩 뒤에 빈 줄을 추가하세요.
## 2026-09-01 - Avoid small chunk sizes in asynchronous file uploads다음에 빈 줄이 없어markdownlint-cli2의 MD022 경고가 발생합니다.**Learning:**앞에 빈 줄을 추가하세요.수정 예시
## 2026-09-01 - Avoid small chunk sizes in asynchronous file uploads + **Learning:** Small chunk sizes (e.g., 8192 bytes) with `await file.read()` create massive threadpool and context-switching overhead in FastAPI/Starlette, severely limiting parsing throughput on large PDFs.🧰 Tools
🪛 markdownlint-cli2 (0.23.2)
[warning] 67-67: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below
(MD022, blanks-around-headings)
🤖 Prompt for AI Agents
Source: Linters/SAST tools