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

App performance enhancements #5022

Merged
merged 51 commits into from
Nov 5, 2024

Conversation

benjaminpkane
Copy link
Contributor

@benjaminpkane benjaminpkane commented Oct 31, 2024

What changes are proposed in this pull request?

  • Adds event listener cleanup to all looker paths
  • Improves spotlight rendering heuristics
  • Fixes frame stream management and first frame data retainment
  • Adds max_frame_stream_size app configuration option
  • Optimizes spaces changes with respect to routing

What areas of FiftyOne does this PR affect?

  • App: FiftyOne application changes
  • Build: Build and test infrastructure changes
  • Core: Core fiftyone Python library changes
  • Documentation: FiftyOne documentation changes
  • Other

Copy link
Contributor

coderabbitai bot commented Oct 31, 2024

Note

Reviews paused

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Walkthrough

The pull request introduces several modifications across various files, primarily focusing on enhancing event handling, routing logic, and type safety. Key changes include the addition of the "spaces" event to the SKIP_EVENTS constant, updates to the LocationState type, and improvements in the useSetSpaces and onSetSessionSpaces functions. Additionally, several components, including Grid, VideoElement, and Spotlight, have undergone refactoring to streamline their logic and improve clarity. New tests for shortcut processing have also been added, ensuring better coverage for recent changes.

Changes

File Path Change Summary
app/packages/app/src/routing/RouterContext.ts Modified SKIP_EVENTS constant to include "spaces".
app/packages/app/src/routing/matchPath.ts Updated LocationState type to add optional event property with value "spaces".
app/packages/app/src/useEvents/useSetSpaces.ts Replaced router.history.replace with router.replace and updated the payload structure.
app/packages/app/src/useWriters/onSetSessionSpaces.ts Similar changes as useSetSpaces, updated routing logic.
app/packages/core/src/components/Grid/Grid.tsx Altered spotlight memoization logic, added destroy method to Spotlight.
app/packages/core/src/components/Modal/utils.test.ts Added a test suite for shortcutToHelpItems function.
app/packages/core/src/components/Modal/utils.ts Enhanced type safety, refactored logic in shortcutToHelpItems.
app/packages/looker/src/elements/base.ts Refactored boot method to accept BootParams object, improved event listener handling.
app/packages/looker/src/elements/common/actions.ts Introduced no-op controls for nextFrame and previousFrame.
app/packages/looker/src/elements/common/index.ts Reorganized export statements for COMMON_SHORTCUTS and VIDEO_SHORTCUTS.
app/packages/looker/src/elements/common/options.ts Updated LoopVideoOptionElement to accept generic state types.
app/packages/looker/src/elements/image.ts Modified import statements to use import type, simplified property initialization.
app/packages/looker/src/elements/index.ts Restructured GetElements type parameters into a single object.
app/packages/looker/src/elements/util.ts Updated import statements to use import type, modified createElementsTree function signature.
app/packages/looker/src/elements/video.ts Added methods for event management, improved playback control logic.
app/packages/looker/src/lookers/abstract.ts Simplified getLabelsWorker function signature, modified property visibility for abortController.
app/packages/looker/src/lookers/image.ts Refactored getElements method to accept named parameters.
app/packages/looker/src/lookers/video.ts Enhanced video frame handling, added clear method for cleanup.
app/packages/looker/src/state.ts Added isDynamicGroup property to BaseConfig interface.
app/packages/looker/src/util.ts Reintroduced getFetchParameters function for worker initialization.
app/packages/spotlight/src/createScrollReader.ts Encapsulated scroll event handlers into named functions for clarity.
app/packages/spotlight/src/index.ts Updated error handling in destroy method for Spotlight.
app/packages/spotlight/src/row.ts Added #aborter for event management, introduced destroy method.
app/packages/spotlight/src/section.ts Introduced destroy method, removed remove method for cleanup.
app/packages/spotlight/src/types.ts Added optional destroy method to SpotlightConfig interface.
app/packages/state/src/hooks/useCreateLooker.ts Incorporated isDynamicGroup into create function configuration.

Possibly related PRs

Suggested labels

bug, app

🐰 In the meadow, changes bloom,
Events now dance, dispelling gloom.
With "spaces" added, routing's bright,
A hop, a skip, all feels just right!
Cleanups done, the code's a treat,
Let's celebrate, our work's complete! 🎉


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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 using 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.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

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.

@benjaminpkane benjaminpkane changed the title Looker event listener cleanup App performance enhancements Nov 2, 2024
@benjaminpkane benjaminpkane marked this pull request as ready for review November 4, 2024 16:20
@@ -564,19 +396,25 @@ export class VideoLooker extends AbstractLooker<VideoState, VideoSample> {
}

private hasFrame(frameNumber: number) {
if (frameNumber === this.firstFrameNumber) {
return this.firstFrame;
Copy link
Contributor

Choose a reason for hiding this comment

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

this is also present in this.frames right? any reason to shortcut here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't believe the first frame is added to the LRU cache. That's something I removed because we never want to delete it

tom-vx51
tom-vx51 previously approved these changes Nov 4, 2024
Copy link
Contributor

@tom-vx51 tom-vx51 left a comment

Choose a reason for hiding this comment

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

lgtm nice work

removeFrame: RemoveFrame,
maxFrameStreamSize?: number
) => {
console.log(maxFrameStreamSize);
Copy link
Contributor

Choose a reason for hiding this comment

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

[nit] remove

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will follow up 👍

@benjaminpkane benjaminpkane merged commit 83f9ede into release/v1.0.2 Nov 5, 2024
13 checks passed
@benjaminpkane benjaminpkane deleted the bugfix/looker-event-listeners branch November 5, 2024 00:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
app Issues related to App features enhancement Code enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants