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

Cache RuleTypeEngine instances in Executor #3741

Merged
merged 3 commits into from
Jul 16, 2024
Merged

Cache RuleTypeEngine instances in Executor #3741

merged 3 commits into from
Jul 16, 2024

Conversation

dmjb
Copy link
Contributor

@dmjb dmjb commented Jun 28, 2024

This simplifies an upcoming PR, and also addresses a comment in the code about the need to cache rule type lookups. This PR changes the executor to load all relevant rule types before evaluation, and construct RuleTypeEngine instances for each. The RuleTypeEngine instances are stored in a cache and reused during rule evaluation, instead of the current approach which constructs a new RuleTypeEngine for each rule instance which is evaluated.

Certain aspects of this change (specifically, the need to query for the rule type ID) are a bit clunky, but will be simplified in an upcoming PR.

Summary

Provide a brief overview of the changes and the issue being addressed.
Explain the rationale and any background necessary for understanding the changes.
List dependencies required by this change, if any.

Fixes #(related issue)

Change Type

Mark the type of change your PR introduces:

  • Bug fix (resolves an issue without affecting existing features)
  • Feature (adds new functionality without breaking changes)
  • Breaking change (may impact existing functionalities or require documentation updates)
  • Documentation (updates or additions to documentation)
  • Refactoring or test improvements (no bug fixes or new functionality)

Testing

Outline how the changes were tested, including steps to reproduce and any relevant configurations.
Attach screenshots if helpful.

Review Checklist:

  • Reviewed my own code for quality and clarity.
  • Added comments to complex or tricky code sections.
  • Updated any affected documentation.
  • Included tests that validate the fix or feature.
  • Checked that related changes are merged.

@coveralls
Copy link

coveralls commented Jul 9, 2024

Coverage Status

coverage: 52.811% (+0.04%) from 52.769%
when pulling 33eb277 on rule-engine-cache
into 3be7c67 on main.

@dmjb dmjb force-pushed the rule-engine-cache branch 6 times, most recently from 744d070 to e1a9e0e Compare July 15, 2024 10:44
This simplifies an upcoming PR, and also addresses a comment in the code
about avoiding continuously re-querying for rule types. This PR changes
the executor to load all relevant rule types before evaluation and
construct RuleTypeEngine instances for each. These are then stored in a
cache and used during rule evaluation.

Certain aspects of this change (specifically, the need to query for the
rule type ID) are a bit clunky, but will be simplified in an upcoming
PR.
@dmjb dmjb marked this pull request as ready for review July 15, 2024 11:46
@dmjb dmjb requested a review from a team as a code owner July 15, 2024 11:46
Copy link
Contributor

@JAORMX JAORMX left a comment

Choose a reason for hiding this comment

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

LGTM. Let's run some smoke tests before merging this. Wanna make sure we're in a good state before this.

@@ -131,7 +131,6 @@ type EvalStatusParams struct {
Result *Result
Profile *pb.Profile
Rule *pb.Profile_Rule
RuleTypeName string
Copy link
Contributor Author

@dmjb dmjb Jul 15, 2024

Choose a reason for hiding this comment

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

Populating the eval params struct with the rule type name was awkward with in the new codepath for loading rule types, and it was only used in one place for evaluation telemetry. I decided instead to pass the rule type name via a different mechanism to the telemetry code.

@dmjb dmjb merged commit e25716e into main Jul 16, 2024
20 checks passed
@dmjb dmjb deleted the rule-engine-cache branch July 16, 2024 09:13
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