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

Restructure FNS global cache to be list #2036

Merged
merged 10 commits into from
Aug 7, 2024
Merged

Restructure FNS global cache to be list #2036

merged 10 commits into from
Aug 7, 2024

Conversation

dydxwill
Copy link
Contributor

@dydxwill dydxwill commented Aug 5, 2024

Changelist

Restructure FNS global cache to be list

Test Plan

Tested in dev2

Author/Reviewer Checklist

  • If this PR has changes that result in a different app state given the same prior state and transaction list, manually add the state-breaking label.
  • If the PR has breaking postgres changes to the indexer add the indexer-postgres-breaking label.
  • If this PR isn't state-breaking but has changes that modify behavior in PrepareProposal or ProcessProposal, manually add the label proposal-breaking.
  • If this PR is one of many that implement a specific feature, manually label them all feature:[feature-name].
  • If you wish to for mergify-bot to automatically create a PR to backport your change to a release branch, manually add the label backport/[branch-name].
  • Manually add any of the following labels: refactor, chore, bug.

Summary by CodeRabbit

  • New Features
    • Improved management of stream updates and subscriptions, enhancing performance and simplifying update handling.
    • Added branch trigger for the GitHub Actions workflow to allow builds on the wl/rm_global_cache branch.
  • Bug Fixes
    • Resolved issues related to subscription ID management, ensuring accurate associations with stream updates.
  • Refactor
    • Streamlined the GitHub Actions workflow by consolidating multiple build and push jobs into a single job for improved maintainability.

Copy link
Contributor

coderabbitai bot commented Aug 5, 2024

Walkthrough

Recent updates to the FullNodeStreamingManagerImpl class and the GitHub Actions workflow enhance stream update management and streamline CI/CD processes. The transition from map-based structures to lists for stream updates improves subscription handling, while consolidating multiple CI jobs into a single workflow simplifies maintenance and enhances clarity.

Changes

Files Change Summary
protocol/streaming/full_node_streaming_manager.go - Restructured FullNodeStreamingManagerImpl to use lists for stream updates and introduced a new mapping for subscriptions.
- Updated the constructor and methods to align with these changes.
.github/workflows/protocol-build-and-push.yml - Simplified the CI/CD workflow by removing jobs for various environments, retaining only the build-and-push-dev5 job for streamlined management.
- Added a trigger for the wl/rm_global_cache branch to enhance automation.

Poem

In the meadow, streams do flow,
With updates swift, like rabbits go!
Subscriptions dance on lists so bright,
Hopping along, a joyful sight!
Performance boosted, logic clear,
A warren of code, we now hold dear! 🐇✨


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 340ea7c and 3c7a63b.

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

72-77: LGTM! Ensure new data structures are correctly initialized.

The new list-based caches are correctly initialized.


142-153: LGTM! Ensure mapping is correctly populated.

The new mapping clobPairIdToSubscriptionIdMapping is correctly populated.


315-336: LGTM! Ensure updates are correctly grouped and sent.

The updates are correctly grouped by clob pair IDs and sent using the new list-based structure.


Line range hint 354-379:
LGTM! Ensure fills are correctly grouped and sent.

The fills are correctly grouped by clob pair IDs and sent using the new list-based structure.


Line range hint 383-397:
LGTM! Ensure updates and subscription IDs are correctly added to the cache.

The updates and subscription IDs are correctly added to the cache using the new list-based structure.


Line range hint 420-459:
LGTM! Ensure updates and subscription IDs are correctly flushed.

The updates and subscription IDs are correctly flushed using the new list-based structure.

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 3c7a63b and af79f20.

Files selected for processing (1)
  • .github/workflows/protocol-build-and-push.yml (2 hunks)
Files skipped from review due to trivial changes (1)
  • .github/workflows/protocol-build-and-push.yml

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 af79f20 and 57e54fa.

Files selected for processing (1)
  • .github/workflows/protocol-build-and-push.yml (3 hunks)
Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/protocol-build-and-push.yml

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 57e54fa and e6fcbf5.

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

72-77: Initialization of new data structures looks good.

The constructor correctly initializes the new list-based data structures.


142-152: Mapping population looks correct.

The clobPairIdToSubscriptionIdMapping is correctly populated with subscription IDs.


314-335: Correct usage of list-based structure for updates.

The updates are correctly grouped and added to the cache using the new list-based structure.


Line range hint 353-378:
Correct usage of list-based structure for fill updates.

The fill updates are correctly grouped and added to the cache using the new list-based structure.


Line range hint 382-399:
Correct addition of updates and subscription IDs to cache.

The updates and subscription IDs are correctly added to the cache using the new list-based structure.


Line range hint 422-461:
Correct handling of updates with new list-based structure.

The updates are correctly collected and sent to subscribers using the new list-based structure.

// list of subscription ids for each stream update.
streamUpdateSubscriptionCache [][]uint32
clobPairIdToSubscriptionIdMapping map[uint32][]uint32
numUpdatesInCache uint32
Copy link
Contributor

Choose a reason for hiding this comment

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

prob no need for this field now that we have a central list, can use len(list)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed

streamUpdateCache []clobtypes.StreamUpdate
// list of subscription ids for each stream update.
streamUpdateSubscriptionCache [][]uint32
clobPairIdToSubscriptionIdMapping map[uint32][]uint32
Copy link
Contributor

Choose a reason for hiding this comment

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

comment for these 2 new fields?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

}
sm.clobPairIdToSubscriptionIdMapping[clobPairId] = append(
sm.clobPairIdToSubscriptionIdMapping[clobPairId],
sm.nextSubscriptionId,
Copy link
Contributor

Choose a reason for hiding this comment

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

do we evict stuff from this map when we prune order subscriptions from the fns manager?

Copy link
Contributor Author

@dydxwill dydxwill Aug 6, 2024

Choose a reason for hiding this comment

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

done, thanks for the catch!

@@ -295,27 +311,28 @@ func (sm *FullNodeStreamingManagerImpl) SendOrderbookUpdates(
}

// Unmarshal each per-clob pair message to v1 updates.
updatesByClobPairId := make(map[uint32][]clobtypes.StreamUpdate)
updatesByClobPairId := make([]clobtypes.StreamUpdate, 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

rename var since this is not a map anymore?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

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 e6fcbf5 and 8d333b8.

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

@dydxwill dydxwill requested a review from jonfung-dydx August 6, 2024 18:26
Comment on lines +33 to +35
streamUpdateCache []clobtypes.StreamUpdate
// list of subscription ids for each stream update.
streamUpdateSubscriptionCache [][]uint32
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: cleaner to combine these two since they are used together and assumed to have same length etc

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added a TODO for now, will address in followup PR

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 8d333b8 and 40a26d5.

Files selected for processing (1)
  • .github/workflows/protocol-build-and-push.yml (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/protocol-build-and-push.yml

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 40a26d5 and c238336.

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

@dydxwill dydxwill merged commit 1b0f052 into main Aug 7, 2024
17 checks passed
@dydxwill dydxwill deleted the wl/rm_global_cache branch August 7, 2024 14:37
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