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

refactor: leading updates in timers #955

Merged
merged 2 commits into from
May 12, 2024
Merged

refactor: leading updates in timers #955

merged 2 commits into from
May 12, 2024

Conversation

cpvalente
Copy link
Owner

@cpvalente cpvalente commented May 11, 2024

This PR offers a solution to improve the described in #940

The existing implementation assumes the following:

  • we update the clocks once a second, not on the turn of the second
  • clock updates are considered low priority
  • clock updates mentioned here are just for the WebSocket message, the integrations are checked at intervals of 32ms, apart from events such as end which are scheduled for extra accuracy

From previous conversations, we felt this was sufficient, but it is understandable that it may cause suspicion and loss of confidence from users side.

The proposed solution implements changes so that we have a leading update on clock and timer.
ie: we update the clock on the turn of the second, not once a second

See below the rate of updates in websocket. The clock message comes within 32ms after the second turn.
Screenshot 2024-05-11 at 11 28 31

I believe we can further improve this by
a) schedule individual updates instead of scheduling the interval update
b) increasing the standard refresh rate (currently 32ms)

However I am unsure if the changes are necessary.
The refresh rate is currently a setting (which is kept away from the users). We could also expose this as an application setting which I am unsure if it is a good idea.

Copy link
Contributor

coderabbitai bot commented May 11, 2024

Important

Auto Review Skipped

Review was skipped due to path filters

Files ignored due to path filters (5)
  • apps/server/src/config/config.ts is excluded by none and included by none
  • apps/server/src/services/TimerService.ts is excluded by none and included by none
  • apps/server/src/services/runtime-service/RuntimeService.ts is excluded by none and included by none
  • apps/server/src/services/runtime-service/__tests__/rundownService.utils.test.ts is excluded by none and included by none
  • apps/server/src/services/runtime-service/rundownService.utils.ts is excluded by none and included by none

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


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 a review. This is useful when automatic reviews are disabled for the repository.
  • @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.

@cpvalente cpvalente force-pushed the leading-updates branch 2 times, most recently from ac48779 to 54f4693 Compare May 11, 2024 09:58
@alex-Arc
Copy link
Collaborator

I think this is a good solution to update on the second rollover

we could look in to the scheduling, but maybe it is more complexity than it is worth (if it's easy more precision is always nice).
I would suggest going with this for now.

increasing notification rate seams "dangerous" at least as a default, but exposing the setting could be nice (and clamp it to some sane values)

@cpvalente
Copy link
Owner Author

cpvalente commented May 11, 2024

I think this is a good solution to update on the second rollover

we could look in to the scheduling, but maybe it is more complexity than it is worth (if it's easy more precision is always nice). I would suggest going with this for now.

increasing notification rate seams "dangerous" at least as a default, but exposing the setting could be nice (and clamp it to some sane values)

Agreed.
Scheduling shouldnt be too complex (in principle). We would likely need separate schedules for clock and timers since these roll over the seconds unit at different times.
This schedules need to be managed since the timer is not always running.

We would need some time to check that there are no unintended side effects.
I suggest merging this as a good improvement and continuing investigating

@cpvalente cpvalente requested a review from alex-Arc May 11, 2024 12:21
@cpvalente cpvalente merged commit 0707426 into master May 12, 2024
3 checks passed
@cpvalente cpvalente deleted the leading-updates branch May 12, 2024 15:03
@cpvalente cpvalente mentioned this pull request May 12, 2024
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.

2 participants