Skip to content

Conversation

@hengfeiyang
Copy link
Contributor

@hengfeiyang hengfeiyang commented May 27, 2024

Last PR i added a new ENV ZO_DATAFUSION_PARQUET_STAT_DISABLE_FOR_AGGS, but now we can use parquet file statistics cache to do better, so i deleted the ENV.

Query for last 3 days within 100GB data:

  • without cache: 10s
  • with stat cache: 8s

This is for all the query not only for aggregation.

Also added a new ENV:

ZO_DATAFUSION_FILE_STAT_CACHE_MAX_ENTRIES=100000

@hengfeiyang hengfeiyang marked this pull request as draft May 27, 2024 16:14
@hengfeiyang hengfeiyang requested review from haohuaijin and oasisk and removed request for oasisk May 27, 2024 16:14
@coderabbitai
Copy link
Contributor

coderabbitai bot commented May 27, 2024

Walkthrough

The recent changes primarily focus on updating dependencies, modifying configuration structures, enhancing cache management, and refining DataFusion execution logic. The Cargo.toml file updates the async-nats dependency. The config.rs file sees the removal of DataFusion Parquet fields and the addition of a new cache configuration field. Several files introduce or modify caching mechanisms, particularly for file statistics, and adjust how schema and memory configurations are handled in DataFusion execution.

Changes

File Path Change Summary
Cargo.toml Updated async-nats dependency version from 0.34.0 to 0.35.1.
src/config/src/config.rs Removed two Parquet-related fields from Common struct; added a new field to Limit struct.
src/handler/http/request/status/mod.rs Added new import and updated cache_status function to include file_statistics_cache.
src/infra/src/cache/mod.rs Updated copyright year from 2023 to 2024.
src/service/search/datafusion/exec.rs Modified schema inference, cache management configuration, memory pool handling, and table registration logic in DataFusion module.
src/service/search/datafusion/storage/file_list.rs Updated set function to take an additional schema_key parameter and use it for key construction.
src/service/search/datafusion/storage/file_statistics_cache.rs Introduced a new cache mechanism for storing and managing file statistics.
src/service/search/datafusion/storage/mod.rs Added file_statistics_cache module to the public scope.

Sequence Diagram(s) (Beta)

sequenceDiagram
    participant User
    participant HTTPHandler as HTTP Handler
    participant CacheManager as Cache Manager
    participant DataFusion as DataFusion Engine

    User->>HTTPHandler: Send request to check cache status
    HTTPHandler->>CacheManager: Request cache statistics
    CacheManager->>HTTPHandler: Return file statistics cache data
    HTTPHandler->>User: Respond with cache status

    User->>DataFusion: Submit query
    DataFusion->>CacheManager: Check file statistics cache
    alt Cache Hit
        CacheManager->>DataFusion: Return cached statistics
    else Cache Miss
        DataFusion->>CacheManager: Update cache with new statistics
    end
    DataFusion->>User: Return query results
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.

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 full the 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 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.

@hengfeiyang hengfeiyang requested a review from oasisk May 27, 2024 16:14
@hengfeiyang hengfeiyang marked this pull request as ready for review May 28, 2024 01:51
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

Outside diff range and nitpick comments (1)
src/service/search/datafusion/storage/file_list.rs (1)

Line range hint 33-47: Refactor the set function to improve key management and data insertion.

The addition of schema_key enhances the granularity of file metadata management. Ensure that all dependent functions and modules are updated to handle this new key structure effectively.

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between b3a3edc and 6870ceb.
Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
Files selected for processing (8)
  • Cargo.toml (1 hunks)
  • src/config/src/config.rs (2 hunks)
  • src/handler/http/request/status/mod.rs (2 hunks)
  • src/infra/src/cache/mod.rs (1 hunks)
  • src/service/search/datafusion/exec.rs (8 hunks)
  • src/service/search/datafusion/storage/file_list.rs (2 hunks)
  • src/service/search/datafusion/storage/file_statistics_cache.rs (1 hunks)
  • src/service/search/datafusion/storage/mod.rs (1 hunks)
Files skipped from review due to trivial changes (3)
  • Cargo.toml
  • src/config/src/config.rs
  • src/infra/src/cache/mod.rs
Additional comments not posted (8)
src/service/search/datafusion/storage/mod.rs (1)

23-23: Successfully added file_statistics_cache module to enhance modularity.

This change promotes better separation of concerns and encapsulation within the system architecture.

src/service/search/datafusion/storage/file_statistics_cache.rs (1)

26-140: Implement robust caching mechanism with FileStatisticsCache.

The use of DashMap for concurrency and VecDeque for eviction policy is well thought out. Ensure that the cache eviction logic is thoroughly tested to prevent potential data loss or inconsistencies.

src/handler/http/request/status/mod.rs (1)

313-316: Enhance monitoring capabilities by adding file_statistics_cache statistics.

The integration of file_statistics_cache statistics into the cache_status function is a valuable addition for better visibility and monitoring of cache performance.

src/service/search/datafusion/exec.rs (5)

1240-1247: The with_collect_stat option has been added to the listing options for both JSON and PARQUET file types. Ensure this change aligns with the intended data collection and performance metrics.

This change should help in better statistics collection for performance tuning.


27-27: Ensure the new import schema_ext::SchemaExt is utilized effectively in the code.

Verification successful

The SchemaExt trait is indeed utilized in various parts of the codebase, including the file src/service/search/datafusion/exec.rs. This confirms that the new import schema_ext::SchemaExt is effectively used.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the usage of `schema_ext::SchemaExt` throughout the codebase.

# Test: Search for the usage of `SchemaExt`. Expect: At least one usage in the code.
ast-grep --lang rust --pattern $'use $_ { $$$, SchemaExt, $$$ }'

Length of output: 65



Script:

#!/bin/bash
# Description: Verify the usage of `SchemaExt` throughout the codebase.

# Test: Search for any references to `SchemaExt`. Expect: At least one usage in the code.
rg 'SchemaExt'

Length of output: 2064


Line range hint 1141-1176: Review the configuration of the RuntimeEnv. Ensure that the memory pool settings and cache manager configurations are correctly applied based on the system's configuration.

Verification successful

The recent script outputs provide useful insights into the configuration of the RuntimeEnv, specifically regarding memory pool settings and cache manager configurations. Here are the key findings:

  • Memory Pool Settings:

    • The memory_pool references in src/service/search/datafusion/exec.rs indicate that both GreedyMemoryPool and FairSpillPool are being configured based on the CONFIG.memory_cache.datafusion_memory_pool setting.
    • The datafusion_memory_pool configuration is defined in src/config/src/config.rs.
  • Cache Manager Settings:

    • The cache_manager references in src/service/search/datafusion/exec.rs show that the CacheManagerConfig is being used and applied to rn_config.

These findings confirm that the memory pool settings and cache manager configurations are being correctly applied based on the system's configuration.

  • src/service/search/datafusion/exec.rs:

    • Memory pool settings are configured with GreedyMemoryPool and FairSpillPool.
    • Cache manager settings are applied using CacheManagerConfig.
  • src/config/src/config.rs:

    • The datafusion_memory_pool configuration is defined.

Based on this information, the review comment is verified.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the correct application of memory pool settings and cache manager configurations.

# Test: Search for the usage of `RuntimeEnv` configuration. Expect: Correct settings based on system configuration.
ast-grep --lang rust --pattern $'let $_ = RuntimeEnv::new($_)'

Length of output: 63



Script:

#!/bin/bash
# Description: Verify the correct application of memory pool settings and cache manager configurations.

# Test: Search for the usage of `RuntimeEnv` configuration and related settings.

# Search for any instantiation or configuration of RuntimeEnv
ast-grep --lang rust --pattern $'let $_ = RuntimeEnv::new($_)'

# Search for any method calls on RuntimeEnv that might configure it
rg 'RuntimeEnv::with_'

# Search for any references to memory pool settings
rg 'memory_pool'

# Search for any references to cache manager settings
rg 'cache_manager'

Length of output: 1016


Line range hint 1256-1291: The handling of different storage types (Memory, Wal, Tmpfs) in the register_table function has been updated. Ensure that these changes do not affect the existing functionality and that the schema key generation and file list management are correctly implemented.

Verification successful

The register_table function in src/service/search/datafusion/exec.rs handles different storage types (Memory, Wal, Tmpfs) and ensures schema key generation and file list management are correctly implemented. The function also includes error handling for unsupported file types and URL parsing errors.

  • The function correctly sets the prefix based on the storage type.
  • It manages the file list for Memory and Wal storage types.
  • It handles schema inference and caching based on configuration.

The changes appear to be correctly implemented without affecting existing functionality.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the handling of different storage types in the `register_table` function.

# Test: Search for the usage of storage type handling in `register_table`. Expect: Correct implementation without affecting existing functionality.
ast-grep --lang rust --pattern $'let $_ = register_table($_, $_, $_, $_, $_, $_)'

Length of output: 82



Script:

#!/bin/bash
# Search for the definition of the `register_table` function in the codebase
ast-grep --lang rust --pattern 'fn register_table($_, $_, $_, $_, $_, $_) -> $_ { $$$ }'

# Search for the usage of the `register_table` function in the codebase
rg 'register_table\('

Length of output: 3508



Script:

#!/bin/bash
# Extract the definition of the `register_table` function from `src/service/search/datafusion/exec.rs`
ast-grep --lang rust --pattern 'pub async fn register_table($_, $_, $_, $_, $_, $_) -> $_ { $$$ }' src/service/search/datafusion/exec.rs

Length of output: 6298


45-45: The addition of CacheManagerConfig should be aligned with the overall caching strategy. Confirm that this configuration is properly integrated and utilized.

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.

3 participants