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

Align log buffer to work with logs limits config #11781

Merged

Conversation

amirylm
Copy link
Collaborator

@amirylm amirylm commented Jan 15, 2024

AUTO-8229

Description

The log buffer needs to accept a config (FastExecLogsHigh) from the registry to set the upper limit for the number of logs that can be processed for a given upkeep.

Changes

  • Used FastExecLogsHigh to limit the number of logs we save in a block for an upkeep
  • Ensured limit values can be set dynamically for the buffer, as the configs might change over time
    • Default values: FastExecLogsHigh = 10

- Used FastExecLogsHigh - limit the number of logs we save in a block for an upkeep
- Used FastExecLogsHigh * NumOfLogUpkeeps - limit the amount of logs we save in a block for all upkeeps
- Ensured these values can be set dynamically for the buffer, as the configs might change over time
@amirylm amirylm force-pushed the AUTO-8229-align-log-buffer-to-work-with-logs-limits-config branch from 3bc6137 to f6c05eb Compare January 15, 2024 18:37
Copy link
Contributor

I see that you haven't updated any README files. Would it make sense to do so?

@amirylm amirylm marked this pull request as ready for review January 16, 2024 10:42
@amirylm amirylm requested a review from a team as a code owner January 16, 2024 10:42
// defaultFastExecLogsHigh is the default upper bound / maximum number of logs that Automation is committed to process for each upkeep,
// based on available capacity, i.e. if there are no logs from other upkeeps.
// Used by Log buffer to limit the number of logs we are saving in memory for each upkeep in a block
defaultFastExecLogsHigh = 10
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure what the significance of fastExec is here; going by the comment block would it make sense to just call this maxLogsPerUpkeep? Or is that too broad?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I wanted to keep our terminology stable cross components, for each component it might be represented with a better name but then we have multiple names for the same variable.

See AUTO-7207 for more information

Copy link
Contributor

@infiloop2 infiloop2 Jan 17, 2024

Choose a reason for hiding this comment

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

Do we want to keep the overall limit in the buffer (maxLogsPerBlock before), NumOfLogUpkeeps * FastExecLogsHigh in ticket?
I think we had some discussion remaining and can finalise the exact NumOfLogUpkeeps terminology

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I started with NumOfLogUpkeeps but reduced it in f422a54

We should keep it for the log provider but for the buffer it seems redundant, as we anyway cap the number of logs per upkeep and the number of upkeeps in another place

Copy link
Contributor

Choose a reason for hiding this comment

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

Is the number of upkeeps a hard cap? What do we expect if upkeeps go bigger than that cap, would we want the log buffer to increase indefinitely in size?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've reverted this part, means we will have hard limit based on the number of log upkeeps specified in the config

@@ -109,7 +109,7 @@ func NewLogProvider(lggr logger.Logger, poller logpoller.LogPoller, packer LogDa
threadCtrl: utils.NewThreadControl(),
lggr: lggr.Named("KeepersRegistry.LogEventProvider"),
packer: packer,
buffer: newLogEventBuffer(lggr, int(opts.LookbackBlocks), maxLogsPerBlock, maxLogsPerUpkeepInBlock),
buffer: newLogEventBuffer(lggr, int(opts.LookbackBlocks), defaultFastExecLogsHigh),
Copy link
Collaborator

Choose a reason for hiding this comment

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

I always find vars being passed as params a little deceptive; if the business logic only passes defaultFastExecLogsHigh as the parameter here, does it make sense to reduce the complexity here and just drop the parameter from this function, and then in your tests, change the value of the defaultFastExecLogsHigh per test?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is the first PR introducing this variable, in future PRs we will get this value in the log provider constructor and pass it over to log buffer constructor, i.e. this default value will be used only from within the buffer constructor in case the passed value is nil/0

ferglor
ferglor previously approved these changes Jan 16, 2024
@cl-sonarqube-production
Copy link

@amirylm amirylm added this pull request to the merge queue Jan 19, 2024
Merged via the queue into develop with commit d805141 Jan 19, 2024
82 checks passed
@amirylm amirylm deleted the AUTO-8229-align-log-buffer-to-work-with-logs-limits-config branch January 19, 2024 13:27
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.

3 participants