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

Full node streaming batch size reset to 2000, properly zero out cache on flush #2068

Merged
merged 3 commits into from
Aug 9, 2024

Conversation

jonfung-dydx
Copy link
Contributor

@jonfung-dydx jonfung-dydx commented Aug 9, 2024

  • properly zero out the cache
  • emit metrics on # streamUpdates
  • reset max batch size default to 2000

Copy link
Contributor

coderabbitai bot commented Aug 9, 2024

Walkthrough

This update enhances GitHub Actions workflows by enabling triggers on branches prefixed with jonfung/, improving flexibility for development processes. Additionally, it modifies gRPC streaming settings to lower batch size and buffer limits for better performance. The streaming manager's methods were refined to simplify cache updates, resulting in cleaner and more efficient code.

Changes

File(s) Change Summary
.github/workflows/protocol-build-and-push-*.yml Added jonfung/** branch pattern to the push event, allowing workflow triggers for more branches.
protocol/app/flags/flags.go Reduced DefaultGrpcStreamingMaxBatchSize and DefaultGrpcStreamingMaxChannelBufferSize values from 1000000 to 2000.
protocol/app/flags/flags_test.go Adjusted test parameters to reflect new gRPC streaming limits, changing expected values from 1000000 to 2000.
protocol/streaming/full_node_streaming_manager.go Simplified methods by removing unnecessary parameters in AddUpdatesToCache, enhancing readability and performance.

Poem

🐰 In the garden of code, where updates delight,
New branches sprout forth, taking flight!
With streaming so smooth, and limits so tight,
Our rabbit hearts dance in the soft moonlight.
Hopping through changes, we sing with glee,
For each little tweak brings joy, you see! 🌷


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.

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 651bfbb and 32db698.

Files selected for processing (5)
  • .github/workflows/protocol-build-and-push-snapshot.yml (1 hunks)
  • .github/workflows/protocol-build-and-push.yml (1 hunks)
  • protocol/app/flags/flags.go (1 hunks)
  • protocol/app/flags/flags_test.go (4 hunks)
  • protocol/streaming/full_node_streaming_manager.go (5 hunks)
Additional comments not posted (10)
.github/workflows/protocol-build-and-push.yml (1)

7-7: Approve the addition of branch pattern jonfung/**.

The addition of the jonfung/** branch pattern under the push event enhances flexibility by allowing workflows to trigger on branches prefixed with jonfung/. This is a beneficial change for development processes.

.github/workflows/protocol-build-and-push-snapshot.yml (1)

7-7: Approve the addition of branch pattern jonfung/**.

The addition of the jonfung/** branch pattern under the push event enhances flexibility by allowing workflows to trigger on branches prefixed with jonfung/. This is a beneficial change for development processes.

protocol/app/flags/flags.go (1)

67-68: Verify the appropriateness of reduced gRPC streaming constants.

The constants DefaultGrpcStreamingMaxBatchSize and DefaultGrpcStreamingMaxChannelBufferSize have been significantly reduced from 1000000 to 2000. Ensure these new values are suitable for the expected workload and do not negatively impact performance.

protocol/app/flags/flags_test.go (2)

83-84: Verify the impact of reduced gRPC streaming parameters.

The reduction of GrpcStreamingMaxBatchSize and GrpcStreamingMaxChannelBufferSize to 2000 across multiple test cases suggests a shift towards stricter limits. Ensure that these changes align with the intended system behavior and performance expectations.

Also applies to: 133-133, 143-143


186-187: Ensure consistency with intended configuration defaults.

The default values for GrpcStreamingBatchSize and GrpcStreamingMaxChannelBufferSize are set to 2000. Verify that these defaults align with the overall system configuration strategy.

protocol/streaming/full_node_streaming_manager.go (5)

353-353: LGTM! Refactoring improves readability.

The removal of the numUpdatesToAdd parameter from the AddUpdatesToCache call simplifies the method and enhances readability.


396-396: LGTM! Consistent refactoring with improved readability.

The removal of the numUpdatesToAdd parameter from the AddUpdatesToCache call aligns with the refactoring strategy, enhancing readability.


414-423: LGTM! Simplified data structure reduces complexity.

The restructuring of the data passed to AddUpdatesToCache reduces complexity and aligns with the refactoring efforts.


Line range hint 427-457:
LGTM! Streamlined method enhances maintainability.

The removal of the numUpdatesToAdd parameter and the simplification of cache clearing logic improve maintainability and performance.


506-507: LGTM! Simplified cache clearing improves clarity.

The direct setting of the cache to nil clarifies the intent of cache clearing and simplifies the method.

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 32db698 and 7abe7ed.

Files selected for processing (1)
  • protocol/streaming/full_node_streaming_manager.go (7 hunks)
Additional comments not posted (4)
protocol/streaming/full_node_streaming_manager.go (4)

356-356: Simplified update handling looks good!

The changes in SendOrderbookUpdates improve readability by removing the explicit count of updates. Ensure that the logic for grouping updates remains correct.


399-399: Consistent simplification in update handling!

The changes in SendOrderbookFillUpdates maintain consistency with SendOrderbookUpdates by simplifying the call to AddUpdatesToCache. This enhances code clarity.


417-426: Simplified taker order status update handling!

The changes in SendTakerOrderStatus align with the simplifications in other methods, enhancing code clarity and consistency.


Line range hint 430-460: Cache management simplification is effective!

The removal of numUpdatesToAdd parameter in AddUpdatesToCache simplifies the method. Ensure that the cache management logic, particularly the overflow handling, is correct.

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 7abe7ed and 67de632.

Files selected for processing (1)
  • protocol/streaming/full_node_streaming_manager.go (7 hunks)
Files skipped from review as they are similar to previous changes (1)
  • protocol/streaming/full_node_streaming_manager.go

@jonfung-dydx jonfung-dydx requested review from dydxwill and jayy04 August 9, 2024 02:26
@jonfung-dydx jonfung-dydx changed the title Full node streaming metrics fixes Full node streaming batch size reset to 2000, properly zero out cache on flush Aug 9, 2024
@@ -501,8 +503,8 @@ func (sm *FullNodeStreamingManagerImpl) FlushStreamUpdatesWithLock() {
}
}

clear(sm.streamUpdateCache)
clear(sm.streamUpdateSubscriptionCache)
sm.streamUpdateCache = nil
Copy link
Contributor

Choose a reason for hiding this comment

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

will this work? vs. setting to empty array

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yep, tested

@jonfung-dydx jonfung-dydx merged commit 56fe707 into main Aug 9, 2024
18 checks passed
@jonfung-dydx jonfung-dydx deleted the jonfung/fns_fixes branch August 9, 2024 16:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

3 participants