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

feat: added MILLIS_PER_BLOCK Streaming mode to the simulator #248

Merged
merged 1 commit into from
Oct 16, 2024

Conversation

AlfredoG87
Copy link
Contributor

@AlfredoG87 AlfredoG87 commented Oct 10, 2024

Description:
Improvements to how the simulator is able to stream to the BlockNode, this commit creates a StreamingMode enum, with 2 values, CONSTANT_RATE and MILLIS_PER_BLOCK.

CONSTANT_RATE is the streaming mode that we have been using, that streams a block item, then waits X amount of NS, then streams another blockItem.

MILLIS_PER_BLOCK, does a lot less thread interruptions, and has a more realistic behaviour, since is going to stream the whole block, as fast as it can, and then going to sleep for X-(time it took to stream) being X the target of block production, by default 1 block is produced each second, so it will attempt to stream 1 block per every 1000 ms, however if the block takes more than 1000 ms to stream, it wont sleep at all, but WARN of a potential issue.

Added documentation for explaining the changes.

Related issue(s):

Fixes #249

Notes for reviewer:

Checklist

  • Documented (Code comments, README, etc.)
  • Tested (unit, integration, etc.)

@AlfredoG87 AlfredoG87 self-assigned this Oct 10, 2024
@AlfredoG87 AlfredoG87 added Simulator Issue related to Block Stream Simulator P1 High priority issue. Required to be completed in the assigned milestone. P2 Required to be completed in the assigned milestone, but may or may not impact release schedule. and removed P1 High priority issue. Required to be completed in the assigned milestone. labels Oct 10, 2024
@AlfredoG87 AlfredoG87 added this to the 0.1.0 milestone Oct 10, 2024
@AlfredoG87 AlfredoG87 marked this pull request as ready for review October 10, 2024 21:50
@AlfredoG87 AlfredoG87 requested a review from a team as a code owner October 10, 2024 21:50
@AlfredoG87 AlfredoG87 modified the milestones: 0.1.0, 0.2.0 Oct 12, 2024
… this commit creates a StreamingMode enum, with 2 values, CONSTANT_RATE and MILLIS_PER_BLOCK.

CONSTANT_RATE is the streaming mode that we have been using, that streams a block item, then waits X amount of NS, then streams another blockItem.

MILLIS_PER_BLOCK, does a lot less thread interruptions, and has a more realistic behaviour, since is going to stream the whole block, as fast as it can, and then going to sleep for X-(time it took to stream) being X the target of block production, by default 1 block is produced each second, so it will attempt to stream 1 block per every 1000 ms, however if the block takes more than 1000 ms to stream, it wont sleep at all, but WARN of a potential issue.

Added documentation for explaining the changes

Signed-off-by: Alfredo Gutierrez <[email protected]>
@AlfredoG87 AlfredoG87 force-pushed the simulator-streaming-improvements branch from 25c5ce6 to 7e9c65e Compare October 15, 2024 21:14
Copy link
Contributor

@mattp-swirldslabs mattp-swirldslabs left a comment

Choose a reason for hiding this comment

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

Looks good. I like all of the tests! :)

@AlfredoG87 AlfredoG87 merged commit 611e91b into main Oct 16, 2024
13 checks passed
@AlfredoG87 AlfredoG87 deleted the simulator-streaming-improvements branch October 16, 2024 18:39
Copy link

codecov bot commented Oct 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.78%. Comparing base (c2a360a) to head (7e9c65e).
Report is 2 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main     #248      +/-   ##
============================================
+ Coverage     99.66%   99.78%   +0.11%     
- Complexity      248      257       +9     
============================================
  Files            51       51              
  Lines           907      932      +25     
  Branches         61       64       +3     
============================================
+ Hits            904      930      +26     
+ Misses            3        2       -1     
Files with missing lines Coverage Δ
...edera/block/simulator/BlockStreamSimulatorApp.java 100.00% <100.00%> (ø)
...block/simulator/config/data/BlockStreamConfig.java 100.00% <ø> (ø)
...ra/block/simulator/config/types/StreamingMode.java 100.00% <100.00%> (ø)

... and 1 file with indirect coverage changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 Required to be completed in the assigned milestone, but may or may not impact release schedule. Simulator Issue related to Block Stream Simulator
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Simulator Streaming Mode to reflect more accurate CN Behaviour
3 participants