Skip to content

Chore: Improve perf benchmarking#299

Merged
Aaron ("AJ") Steers (aaronsteers) merged 5 commits into
mainfrom
chore/improved-perf-benchmarks
Jul 18, 2024
Merged

Chore: Improve perf benchmarking#299
Aaron ("AJ") Steers (aaronsteers) merged 5 commits into
mainfrom
chore/improved-perf-benchmarks

Conversation

@aaronsteers

@aaronsteers Aaron ("AJ") Steers (aaronsteers) commented Jul 17, 2024

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • New Features

    • Introduced a new script for performance profiling of read throughput, supporting multiple cache types (DuckDB, Snowflake, BigQuery).
    • Added guidelines for using different scale values and tools like viztracer for profiling.
  • Enhancements

    • Improved formatting of elapsed time strings for better accuracy in reporting elapsed times under various conditions.
  • Documentation

    • Included detailed notes on estimating throughput in performance test scripts, covering assumptions about record sizes and throughput metrics.

@coderabbitai

coderabbitai Bot commented Jul 17, 2024

Copy link
Copy Markdown
Contributor
Walkthrough

Walkthrough

The recent changes improve the time formatting in progress.py, enhance the performance profiling in run_perf_test_reads.py with throughput estimation notes, and introduce a new script run_perf_test_reads_2.py for detailed performance profiling of read throughput. This new script includes guidelines for using various scale values, integrates with different cache types, and provides instructions for generating flamegraphs using viztracer.

Changes

File Change Summary
airbyte/progress.py Improved the formatting of elapsed time strings in the _get_elapsed_time_str function to handle various elapsed time scenarios more accurately.
examples/run_perf_test_reads.py Introduced notes on estimating throughput, detailing assumptions about record sizes and throughput in MB/s based on record counts per second.
examples/run_perf_test_reads_2.py Added a new script for performance profiling read throughput. The script accepts a scale argument, provides guidelines for profiling, and integrates with various caches like DuckDB, Snowflake, and BigQuery. Includes instructions for generating flamegraphs.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant User as User
    participant Script as run_perf_test_reads_2.py
    participant Cache as Cache (DuckDB/Snowflake/BigQuery)
    participant Source as Source

    User->>Script: Run with -e=SCALE
    Script->>Source: Configure source
    Script->>Cache: Set up cache type
    Script->>Source: Check connection
    Source-->>Script: Connection successful
    Script->>Source: Read data
    Source->>Cache: Read data from cache
    Cache-->>Source: Data read successfully
    Source-->>Script: Data read complete
    Script-->>User: Performance profiling result
Loading

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Comment thread examples/run_perf_test_reads_2.py Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 1acd6df and a159f16.

Files selected for processing (3)
  • airbyte/progress.py (1 hunks)
  • examples/run_perf_test_reads.py (1 hunks)
  • examples/run_perf_test_reads_2.py (1 hunks)
Files skipped from review due to trivial changes (1)
  • examples/run_perf_test_reads.py
Additional comments not posted (4)
examples/run_perf_test_reads_2.py (2)

1-42: LGTM!

The header and docstring provide a clear and detailed overview of the script's purpose and usage.


44-57: LGTM!

The imports and constants are appropriate and necessary for the script's functionality.

airbyte/progress.py (2)

96-114: LGTM!

The modifications improve the readability and accuracy of the elapsed time strings.


Line range hint 188-191:
LGTM!

The usage of _get_elapsed_time_str is consistent and appropriate.

Comment thread examples/run_perf_test_reads_2.py Outdated
Comment thread examples/run_perf_test_reads_2.py Outdated
Comment thread examples/run_perf_test_reads_2.py Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between a159f16 and e88c407.

Files selected for processing (1)
  • examples/run_perf_test_reads_2.py (1 hunks)
Additional context used
Ruff
examples/run_perf_test_reads_2.py

48-48: pathlib.Path imported but unused

Remove unused import: pathlib.Path

(F401)

Additional comments not posted (4)
examples/run_perf_test_reads_2.py (4)

55-55: LGTM!

The constant AIRBYTE_INTERNAL_GCP_PROJECT is correctly defined and used.


66-67: Replace assert with proper error handling.

Using assert for error handling is not recommended in production code. Consider raising an exception instead.

-    assert secret is not None, "Secret not found."
+    if secret is None:
+        raise ValueError("Secret not found.")

70-127: Refactor cache initialization into a separate function.

To improve readability and maintainability, consider refactoring the cache initialization into a separate function.

def initialize_cache(cache_type: str) -> CacheBase:
    if cache_type == "duckdb":
        return ab.new_local_cache()
    elif cache_type == "snowflake":
        secret_config = get_gsm_secret_json(secret_name="AIRBYTE_LIB_SNOWFLAKE_CREDS")
        return SnowflakeCache(
            account=secret_config["account"],
            username=secret_config["username"],
            password=secret_config["password"],
            database=secret_config["database"],
            warehouse=secret_config["warehouse"],
            role=secret_config["role"],
        )
    elif cache_type == "bigquery":
        temp = tempfile.NamedTemporaryFile(mode="w+", delete=False, encoding="utf-8")
        secret_config = get_gsm_secret_json(secret_name="SECRET_DESTINATION-BIGQUERY_CREDENTIALS__CREDS")
        try:
            temp.write(secret_config["credentials_json"])
            temp.flush()
        finally:
            temp.close()
        return BigQueryCache(
            project_name=secret_config["project_id"],
            dataset_name=secret_config.get("dataset_id", "pyairbyte_integtest"),
            credentials_path=temp.name,
        )

def main(e: int | None = None, n: int | None = None, cache_type: str = "duckdb") -> None:
    num_records: int = n or 5 * (10 ** (e or 3))
    cache = initialize_cache(cache_type)
    source = ab.get_source(
        "source-e2-test",  # No-op source
        docker_image="airbyte/source-e2e-test:cg10",
        streams="*",
        config={
            "type": "BENCHMARK",
            "schema": "FIVE_STRING_COLUMNS",
            "terminationCondition": {
                "type": "MAX_RECORDS",
                "max": num_records,
            },
        },
    )
    source.check()
    source.read(cache)

144-148: Clarify the help text for the -n argument.

The help text for the -n argument is slightly misleading. It should indicate that the value is the exact record count, not a recommended value.

-            "Recommended values: 2-3 (500 or 5_000) for read and overhead costs, "
-            " 4-6 (50K or 5MM) for write throughput. "
+            "The exact record count."

Comment thread examples/run_perf_test_reads_2.py Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between e88c407 and 84bffa1.

Files selected for processing (1)
  • examples/run_perf_test_reads.py (6 hunks)
Files skipped from review as they are similar to previous changes (1)
  • examples/run_perf_test_reads.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant