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

Dynamically calculate performables limit based on perform data size #305

Conversation

amirylm
Copy link
Collaborator

@amirylm amirylm commented Jan 15, 2024

AUTO-7597

Description

The idea is to put the maximal number of performables in observation/outcome dynamically calculate it based on performData and what fits into observation / outcome size, rather than using a fixed limit of number of upkeeps based on hardcoded limits.

Changes

  • Added helper functions to calculate size
  • Limit the amount of performables based on bytes size rather than hardcoded number of results
  • Validate performables bytes size rather than hardcoded number of results
  • Backwards compatibility (only for generating compatible outcome/observation, validation is being done only on the number of bytes)
    • NOTE: a followup PR should reduce backwards compatibility, which will be only for a single version

@amirylm amirylm changed the title [DO NOT MERGE] Dynamically calculate performables limit based on perform data size Dynamically calculate performables limit based on perform data size Jan 16, 2024
@@ -163,6 +163,21 @@ type CheckResult struct {
RetryInterval time.Duration
}

// Size returns the size of the check result in bytes
func (cr *CheckResult) Size() int {
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 estimating the size of the EVM encoded result, right? We have tried this a bit before and the function becomes full of magic numbers. Also, this becomes brittle when changing encoding of the CheckResult, which is in the core code.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Note that all the numbers have a corresponding comment to specify what field they represent.
The most naive option is to encode the object and count the bytes, but that would be expensive in runtime (encoding/decoding is currently taking dozens percentage of CPU)

The CheckResult currently still resides here, once moved to cl-common I'll adjust.

Copy link
Collaborator

Choose a reason for hiding this comment

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

+1 don't quite like this hardcoded size counting as historically this as bitten us in the past.

  1. Anytime the struct is changed it creates an implicit dependency to change which is very easy to forget
  2. If encoding type is changed then this needs to change
  3. This will likely need some magic numbers to match exact json encoding size then just adding the byte size of fields

@EasterTheBunny
Copy link
Contributor

What if we estimated size in the check pipeline instead of in the plugin? In this way, size just becomes a number and the size estimation logic is closer to the encoding functions. It would make the process less brittle.

@amirylm
Copy link
Collaborator Author

amirylm commented Jan 16, 2024

What if we estimated size in the check pipeline instead of in the plugin? In this way, size just becomes a number and the size estimation logic is closer to the encoding functions. It would make the process less brittle.

This change refers to Observation and Outcome which are encoded within the plugin as they are used by OCR (no EVM encoding).
One thing that could be an issue is the overhead of JSON encoding (property names, {}, quotes, white spaces)

@EasterTheBunny
Copy link
Contributor

Ahh ok. That makes sense. This is for byte limits of Observation and Outcome.

Comment on lines +86 to +88
// TODO: remove this in next version, it's a temporary fix for
// supporting old nodes that will limit the number of results rather than the size
// of the outcome
Copy link
Collaborator

Choose a reason for hiding this comment

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

Need to think more deeply, but i guess this will be a breaking change even if we remove this in the next version?

I think the ideal way to make this non breaking is to do it with a feature flag that is then turned on at once for all nodes (via config), but I think for this specific change we may just be ok to just take a breaking risk as we don't expect more than 50 performables in a round for current traffic

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Need to think more deeply, but i guess this will be a breaking change even if we remove this in the next version?

In case all ops will update to this version, where the nodes will produce "limited" Outcome/Observation but won't validate that, they can update to next version where we'll start producing "unlimited" Outcome/Observation as the validation will accept those

for this specific change we may just be ok to just take a breaking risk as we don't expect more than 50 performables in a round for current traffic

OK make sense

Copy link
Collaborator

Choose a reason for hiding this comment

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

they can update to next version where we'll start producing "unlimited" Outcome/Observation as the validation will accept those

Yes the validation would pass but outcome consensus would still not happen if some NOPs produce limited outcome and some with more

@amirylm amirylm closed this May 8, 2024
@amirylm amirylm deleted the AUTO-7597-dynamically-calculate-performables-limit-based-on-perform-data-size branch May 8, 2024 14:04
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.

None yet

3 participants