- Notifications
You must be signed in to change notification settings - Fork126
added logs for cloud fetch speed#654
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
3 commits Select commitHold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
37 changes: 37 additions & 0 deletionssrc/databricks/sql/cloudfetch/downloader.py
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 |
|---|---|---|
| @@ -51,12 +51,14 @@ class DownloadableResultSettings: | ||
| link_expiry_buffer_secs (int): Time in seconds to prevent download of a link before it expires. Default 0 secs. | ||
| download_timeout (int): Timeout for download requests. Default 60 secs. | ||
| max_consecutive_file_download_retries (int): Number of consecutive download retries before shutting down. | ||
| min_cloudfetch_download_speed (float): Threshold in MB/s below which to log warning. Default 0.1 MB/s. | ||
| """ | ||
| is_lz4_compressed: bool | ||
| link_expiry_buffer_secs: int = 0 | ||
| download_timeout: int = 60 | ||
| max_consecutive_file_download_retries: int = 0 | ||
| min_cloudfetch_download_speed: float = 0.1 | ||
| class ResultSetDownloadHandler: | ||
| @@ -90,6 +92,8 @@ def run(self) -> DownloadedFile: | ||
| self.link, self.settings.link_expiry_buffer_secs | ||
| ) | ||
| start_time = time.time() | ||
| with self._http_client.execute( | ||
| method=HttpMethod.GET, | ||
| url=self.link.fileLink, | ||
| @@ -102,6 +106,13 @@ def run(self) -> DownloadedFile: | ||
| # Save (and decompress if needed) the downloaded file | ||
| compressed_data = response.content | ||
| # Log download metrics | ||
| download_duration = time.time() - start_time | ||
| self._log_download_metrics( | ||
| self.link.fileLink, len(compressed_data), download_duration | ||
| ) | ||
| decompressed_data = ( | ||
| ResultSetDownloadHandler._decompress_data(compressed_data) | ||
| if self.settings.is_lz4_compressed | ||
| @@ -128,6 +139,32 @@ def run(self) -> DownloadedFile: | ||
| self.link.rowCount, | ||
| ) | ||
| def _log_download_metrics( | ||
| self, url: str, bytes_downloaded: int, duration_seconds: float | ||
| ): | ||
| """Log download speed metrics at INFO/WARN levels.""" | ||
| # Calculate speed in MB/s (ensure float division for precision) | ||
| speed_mbps = (float(bytes_downloaded) / (1024 * 1024)) / duration_seconds | ||
| urlEndpoint = url.split("?")[0] | ||
| # INFO level logging | ||
| logger.info( | ||
| "CloudFetch download completed: %.4f MB/s, %d bytes in %.3fs from %s", | ||
| speed_mbps, | ||
| bytes_downloaded, | ||
| duration_seconds, | ||
| urlEndpoint, | ||
| ) | ||
| # WARN level logging if below threshold | ||
| if speed_mbps < self.settings.min_cloudfetch_download_speed: | ||
| logger.warning( | ||
shivam2680 marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| "CloudFetch download slower than threshold: %.4f MB/s (threshold: %.1f MB/s) from %s", | ||
| speed_mbps, | ||
| self.settings.min_cloudfetch_download_speed, | ||
| url, | ||
| ) | ||
| @staticmethod | ||
| def _validate_link(link: TSparkArrowResultLink, expiry_buffer_secs: int): | ||
| """ | ||
23 changes: 21 additions & 2 deletionstests/unit/test_downloader.py
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.
Uh oh!
There was an error while loading.Please reload this page.
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.