Skip to content
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

feat: refine scan metrics logging #4296

Merged
merged 5 commits into from
Jul 5, 2024

Conversation

evenyag
Copy link
Contributor

@evenyag evenyag commented Jul 5, 2024

I hereby agree to the terms of the GreptimeDB CLA.

Refer to a related PR or issue link (optional)

What's changed and what's your intention?

This PR fixes the scan cost metrics and changes the prepare cost metric. It also logs the elapsed time before the first poll.

Checklist

  • I have written the necessary rustdoc comments.
  • I have added the necessary unit tests and integration tests.
  • This PR requires documentation updates.

Summary by CodeRabbit

  • Refactor
    • Improved performance tracking by modifying the calculation of scan costs in various scanning operations.
    • Enhanced logging to include more precise timing metrics (e.g., first_poll duration).
    • Updated debug output to reflect these changes for better diagnostics.

Copy link
Contributor

coderabbitai bot commented Jul 5, 2024

Walkthrough

The primary change involves the removal of the prepare_scan_cost field from various scan-related structs and replacing its usage with query_start.elapsed(). This includes modifying the locations where scanning costs were previously calculated to use elapsed time directly. Logging updates also reflect these changes, ensuring scan durations are properly tracked and reported.

Changes

Files Change Summary
src/.../scan_region.rs Removed prepare_scan_cost field from StreamContext and eliminated its initialization.
src/.../seq_scan.rs Replaced prepare_scan_cost assignments with self.stream_ctx.query_start.elapsed(); added first_poll variable; updated logs.
src/.../unordered_scan.rs Same changes as in seq_scan.rs, including prepare_scan_cost to query_start.elapsed() replacement, added first_poll, and updated logs.
src/.../parquet/reader.rs Adjusted scan cost calculations; removed elapsed time capture in certain code branches, centralized it.

Poem

In quiet bytes where data streams flow,
Blossoms a change, so calm, so slow.
Away with old costs, elapsed time reigns,
The clock now whispers, progress remains.
Logs now sing in accurate song,
Scan anew, where timings belong.
🌟🐇✨


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 Configration 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.

@github-actions github-actions bot added the docs-not-required This change does not impact docs. label Jul 5, 2024
@evenyag evenyag marked this pull request as ready for review July 5, 2024 08:00
@evenyag evenyag requested a review from WenyXu July 5, 2024 08:02
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

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 8a119aa and a563c3c.

Files selected for processing (4)
  • src/mito2/src/read/scan_region.rs (2 hunks)
  • src/mito2/src/read/seq_scan.rs (6 hunks)
  • src/mito2/src/read/unordered_scan.rs (3 hunks)
  • src/mito2/src/sst/parquet/reader.rs (4 hunks)
Files skipped from review due to trivial changes (1)
  • src/mito2/src/read/scan_region.rs
Additional comments not posted (13)
src/mito2/src/read/unordered_scan.rs (3)

144-145: Replace prepare_scan_cost with query_start.elapsed().

The prepare_scan_cost field has been replaced with self.stream_ctx.query_start.elapsed(). Ensure that this change accurately reflects the intended metric.


149-150: Introduce first_poll variable to track elapsed time before the first poll.

The first_poll variable is introduced to log the elapsed time before the first poll. This is a useful metric for performance monitoring.


201-202: Log first_poll duration.

The logging statement now includes the first_poll duration. This provides additional insights into the performance of the scan.

src/mito2/src/read/seq_scan.rs (7)

93-94: Replace prepare_scan_cost with query_start.elapsed().

The prepare_scan_cost field has been replaced with self.stream_ctx.query_start.elapsed(). Ensure that this change accurately reflects the intended metric.


250-251: Replace prepare_scan_cost with query_start.elapsed().

The prepare_scan_cost field has been replaced with self.stream_ctx.query_start.elapsed(). Ensure that this change accurately reflects the intended metric.


257-258: Introduce first_poll variable to track elapsed time before the first poll.

The first_poll variable is introduced to log the elapsed time before the first poll. This is a useful metric for performance monitoring.


292-296: Log first_poll duration.

The logging statement now includes the first_poll duration. This provides additional insights into the performance of the scan.


327-328: Replace prepare_scan_cost with query_start.elapsed().

The prepare_scan_cost field has been replaced with self.stream_ctx.query_start.elapsed(). Ensure that this change accurately reflects the intended metric.


335-336: Introduce first_poll variable to track elapsed time before the first poll.

The first_poll variable is introduced to log the elapsed time before the first poll. This is a useful metric for performance monitoring.


383-387: Log first_poll duration.

The logging statement now includes the first_poll duration. This provides additional insights into the performance of the scan.

src/mito2/src/sst/parquet/reader.rs (3)

873-876: Track scan_start for elapsed time measurement.

The scan_start variable is introduced to measure the elapsed time at the beginning of the next_batch method. This provides more accurate tracking of scan costs.


883-883: Update scan cost after fetching the next record batch.

The scan cost is updated after fetching the next record batch. Ensure that this change accurately reflects the intended metric.


896-896: Update scan cost after processing batches.

The scan cost is updated after processing the batches. Ensure that this change accurately reflects the intended metric.

Copy link

codecov bot commented Jul 5, 2024

Codecov Report

Attention: Patch coverage is 87.50000% with 1 line in your changes missing coverage. Please review.

Project coverage is 85.01%. Comparing base (849e0b9) to head (a563c3c).
Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4296      +/-   ##
==========================================
- Coverage   85.31%   85.01%   -0.30%     
==========================================
  Files        1063     1066       +3     
  Lines      188345   188633     +288     
==========================================
- Hits       160686   160367     -319     
- Misses      27659    28266     +607     

Copy link
Contributor

@v0y4g3r v0y4g3r left a comment

Choose a reason for hiding this comment

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

LGTM

@v0y4g3r v0y4g3r enabled auto-merge July 5, 2024 08:31
@v0y4g3r v0y4g3r added this pull request to the merge queue Jul 5, 2024
Merged via the queue into GreptimeTeam:main with commit b1219fa Jul 5, 2024
107 checks passed
@v0y4g3r v0y4g3r deleted the feat/correct-metrics branch July 5, 2024 08:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs-not-required This change does not impact docs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants