Skip to content

Chunk download latency #634

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
wants to merge 21 commits into
base: sea-migration
Choose a base branch
from
Open

Chunk download latency #634

wants to merge 21 commits into from

Conversation

saishreeeee
Copy link
Collaborator

@saishreeeee saishreeeee commented Jul 13, 2025

What type of PR is this?

  • Refactor
  • Feature
  • Bug Fix
  • Other

Description

Record chunk download latency
Added chunk_id to SqlExecutionEvent and ResultDownloadHandler

How is this tested?

  • Unit tests
  • E2E Tests
  • Manually
  • N/A

Ran the query: SELECT * FROM RANGE(20000000)
Latency was recorded for 4 chunks.
The latency log for the 1st chunk:

{
  "frontend_log_event_id": "e684ff49-9026-49af-abb6-687a6a16e565",
  "context": {
    "client_context": {
      "timestamp_millis": 1752467452769,
      "user_agent": "PyDatabricksSqlConnector/4.0.5"
    }
  },
  "entry": {
    "sql_driver_log": {
      "session_id": "01f0606b-4825-118d-abd2-87f5748c7dd3",
      "system_configuration": {
        "driver_version": "4.0.5",
        "os_name": "Darwin",
        "os_version": "24.5.0",
        "os_arch": "arm64",
        "runtime_name": "Python 3.13.3",
        "runtime_version": "3.13.3",
        "runtime_vendor": "CPython",
        "driver_name": "Databricks SQL Python Connector",
        "char_set_encoding": "utf-8",
        "locale_name": "en_US"
      },
      "driver_connection_params": {
        "http_path": <HTTP_PATH>,
        "mode": "THRIFT",
        "host_info": {
          "host_url": <SERVER_HOSTNAME>,
          "port": 443
        },
        "auth_mech": "PAT"
      },
      "sql_statement_id": "01f0606b-4854-1f89-a0cb-d5860332ef81",
      "sql_operation": {
        "statement_type": "QUERY",
        "is_compressed": true,
        "execution_result": "EXTERNAL_LINKS",
        "chunk_id": 0
      },
      "operation_latency_ms": 15882
    }
  }
}

Related Tickets & Documents

Signed-off-by: Sai Shree Pradhan <[email protected]>
Signed-off-by: Sai Shree Pradhan <[email protected]>
Signed-off-by: Sai Shree Pradhan <[email protected]>
Signed-off-by: Sai Shree Pradhan <[email protected]>
Signed-off-by: Sai Shree Pradhan <[email protected]>
-
Signed-off-by: Sai Shree Pradhan <[email protected]>
@saishreeeee saishreeeee marked this pull request as ready for review July 14, 2025 04:46
@saishreeeee saishreeeee self-assigned this Jul 14, 2025
@saishreeeee saishreeeee requested a review from jprakash-db July 14, 2025 04:46
Signed-off-by: Sai Shree Pradhan <[email protected]>
Signed-off-by: Sai Shree Pradhan <[email protected]>
Signed-off-by: Sai Shree Pradhan <[email protected]>
Signed-off-by: Sai Shree Pradhan <[email protected]>
Signed-off-by: Sai Shree Pradhan <[email protected]>
@vikrantpuppala
Copy link
Contributor

@jayantsing-db can you take a look, this PR adds latency logs (merges into sea-migration) as there are some refactorings that this PR leverages

@@ -1060,7 +1070,7 @@ def tables(
)
return self

@log_latency(StatementType.METADATA)
@log_latency()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel why is the code modified to fit telemetry? like the statement type within log latency decorator made sense. Why is it now a part of the statement type in the code ?

Copy link
Collaborator Author

@saishreeeee saishreeeee Jul 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The chunk downloader function doesn't know the StatementType, hence had to pass it down as arg.
Now have changed it to always set statement_type to StatementType.QUERY as metadata does not use cloud fetch.

@@ -63,6 +63,10 @@ def test_initializer_adds_links(self, mock_create_next_table):
result_links=result_links,
max_download_threads=10,
ssl_options=SSLOptions(),
session_id_hex=Mock(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vikrantpuppala I think we should introduce some variables like the connection context in JDBC .

  • Passing these variables in so many functions is just bloating the code. A future TODO
  • This will also simply the TelemetryExtractor:

Signed-off-by: Sai Shree Pradhan <[email protected]>
Signed-off-by: Sai Shree Pradhan <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants