-
Notifications
You must be signed in to change notification settings - Fork 446
fix: unify streaming download chunk size with dedicated DOWNLOAD_CHUNK_SIZE_MB knob #1817
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
Open
jacalata
wants to merge
6
commits into
development
Choose a base branch
from
jac/fix-large-view-download
base: development
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
695f784
fix: increase streaming chunk size for CSV and Excel view downloads
jacalata 55985a9
Merge origin/development into jac/fix-large-view-download
jacalata b5b3de1
fix: unify streaming download chunk size across Views, CustomViews, a…
jacalata 850a017
Add dedicated DOWNLOAD_CHUNK_SIZE_MB (default 1 MB), split from upload
jacalata db8682a
Merge remote-tracking branch 'origin/development' into jac/fix-large-…
jacalata 08d456c
Address review feedback on DOWNLOAD_CHUNK_SIZE_MB
jacalata 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,10 +14,38 @@ def FILESIZE_LIMIT_MB(self): | |
| return min(int(os.getenv("TSC_FILESIZE_LIMIT_MB", 64)), 64) | ||
|
|
||
| # For when a datasource is over 64MB, break it into 5MB(standard chunk size) chunks | ||
| # Applies to *upload* / chunked publish. Downloads use DOWNLOAD_CHUNK_SIZE_MB. | ||
| @property | ||
| def CHUNK_SIZE_MB(self): | ||
| return int(os.getenv("TSC_CHUNK_SIZE_MB", 5 * 10)) # 5MB felt too slow, upped it to 50 | ||
|
|
||
| # Chunk size for streaming *downloads* (view CSV / Excel, workbook / | ||
| # datasource / flow downloads). Kept separate from the upload knob because | ||
| # a large read chunk delays the first-byte yield on slow connections -- | ||
| # requests.iter_content buffers up to chunk_size before yielding, so on a | ||
| # 1 Mbps link a 50 MB chunk means ~7 minutes before the first yield. | ||
| # 1 MB is empirically a reasonable balance between per-chunk overhead and | ||
| # progressive-yield latency; callers who want a different tradeoff can | ||
| # tune via TSC_DOWNLOAD_CHUNK_SIZE_MB. | ||
| # | ||
| # No upper bound is enforced, but very large values (thousands of MB) will | ||
| # OOM on constrained hosts because each chunk is buffered in memory before | ||
| # it is written or yielded. Keep this under ~100 MB unless the caller has | ||
| # specifically measured a benefit at higher values. | ||
| # | ||
| # Bounds: values <= 0 or non-numeric input are treated as invalid and fall | ||
| # back to the 1 MB default; 0 or a negative chunk size would silently | ||
| # corrupt the output because iter_content interprets it as "read all". | ||
| @property | ||
| def DOWNLOAD_CHUNK_SIZE_MB(self) -> int: | ||
| raw = os.getenv("TSC_DOWNLOAD_CHUNK_SIZE_MB", "1") | ||
| try: | ||
| value = int(raw) | ||
| except ValueError: | ||
| # invalid env value; fall back to default | ||
| value = 1 | ||
|
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. is default hardcoded anywhere |
||
| return max(1, value) | ||
|
|
||
| # Default page size | ||
| @property | ||
| def PAGE_SIZE(self): | ||
|
|
||
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
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.
Minor: this says the pre-PR code used "mixed 1024-byte and 10240-byte chunks," but the diff (and the pre-PR
endpoint.py/views_endpoint.py/custom_views_endpoint.py) shows every download path hardcodediter_content(1024)-- there's no 10240-byte chunk anywhere in the codebase (checked via clone + grep). Worth fixing the changelog wording so it doesn't overstate the prior inconsistency; doesn't affect the code itself.— Jaehun Bot