Skip to content

Commit

Permalink
fix: disable bool simplifier due to performance issue. Fixes #1339 (#…
Browse files Browse the repository at this point in the history
…1363)

* fix: disable bool simplifier due to performance issue

Signed-off-by: Derek Wang <[email protected]>
  • Loading branch information
whynowy authored Sep 29, 2021
1 parent d556788 commit a1af470
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 15 deletions.
11 changes: 2 additions & 9 deletions sensors/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -416,15 +416,8 @@ func (sensorCtx *SensorContext) getDependencyExpression(ctx context.Context, tri
}
depExpression = strings.Join(deps, "&&")
}
logger.Infof("Dependency expression for trigger %s before simplification: %s", trigger.Template.Name, depExpression)
boolSimplifier, err := common.NewBoolExpression(depExpression)
if err != nil {
logger.Errorw("Invalid dependency expression", zap.Error(err))
return "", err
}
result := boolSimplifier.GetExpression()
logger.Infof("Dependency expression for trigger %s after simplification: %s", trigger.Template.Name, result)
return result, nil
logger.Infof("Dependency expression for trigger %s: %s", trigger.Template.Name, depExpression)
return depExpression, nil
}

func convertEvent(event cloudevents.Event) *v1alpha1.Event {
Expand Down
9 changes: 3 additions & 6 deletions sensors/listener_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,8 @@ func TestGetDependencyExpression(t *testing.T) {
sensorCtx := &SensorContext{
sensor: obj,
}
expr, err := sensorCtx.getDependencyExpression(context.Background(), *fakeTrigger)
_, err := sensorCtx.getDependencyExpression(context.Background(), *fakeTrigger)
assert.NoError(t, err)
assert.Equal(t, "dep1 && dep2", expr)
})

t.Run("get complex expression", func(t *testing.T) {
Expand All @@ -110,9 +109,8 @@ func TestGetDependencyExpression(t *testing.T) {
sensor: obj,
}
trig := fakeTrigger.DeepCopy()
expr, err := sensorCtx.getDependencyExpression(context.Background(), *trig)
_, err := sensorCtx.getDependencyExpression(context.Background(), *trig)
assert.NoError(t, err)
assert.Equal(t, "dep1 && dep1a && dep2", expr)
})

t.Run("get conditions expression", func(t *testing.T) {
Expand Down Expand Up @@ -144,8 +142,7 @@ func TestGetDependencyExpression(t *testing.T) {
}
trig := fakeTrigger.DeepCopy()
trig.Template.Conditions = "dep-1 || dep-1a || dep-3"
expr, err := sensorCtx.getDependencyExpression(context.Background(), *trig)
_, err := sensorCtx.getDependencyExpression(context.Background(), *trig)
assert.NoError(t, err)
assert.Equal(t, "dep_1a || dep-3 || dep-1", expr)
})
}

0 comments on commit a1af470

Please sign in to comment.