Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove states from RPC logs, include only rule unique IDs (#484)
This PR removes the states from Booster's rewrite and equation traces. Only rule unique IDs are included in the RPC logs now. Here's a quick performance comparison on the execute request `test-fountry-bug-report/state-007.send` with `log-successful-rewrites` and `log-successful-simplifications` set to `true`: | Git revision | Time | Comment | |:--------------------------------------|:-----------|----------------------------------------------------| | georgy/rpc-logs-only-labels | 3.286555 s | this PR | | main (0ef6ecd) | 3.259145294| Georgy's log fix reverted | | 0096f93 | 35s | logs with states, `-N` still there | The performance with unique IDs only seems to be on par with not collecting traces at all. I have also checked that: - [x] we still emit rewrite logs with states to `stderr` when `-l Rewrite/RewriteSuccess` is passed and `log-successful/failed-rewrites: false` - [x] we still emit simplification logs with states to `stderr` when `-l Simplify/SimplifySuccess` is passed and `log-successful/failed-simplifications: false ` # Summary of changes The idea is to stop accumulating states in `RewriteTrace`s and `EquationTrace`s while still keeping the possibility to emit them in `stderr` logs and possibly stream them to the client in future. ## Refactoring of `EquationTrace` * the `EquationMetadata` type is introduced to hold an equation's location, rule label and unique id information * `EquationTrace` is split into two constructors, `EquationApplied` and `EquationNotApplied`, where the former can hold the post-term, and the latter an `ApplyEquationResult` * `EquationTrace` is made parametric in the term type, similar to `RewriteTrace`. The old `EquationTrace` now becomes `EquationTrace Term` * a function `eraseStates :: EquationTrace Term -> EquationTrace ()` is added to remove the terms from a trace, leaving only metadata. This function will be called in the rewriting code to erase the states from the equation traces. ## Refactoring of `RewriteTrace` * The `RewriteSimplified` data constructor is changed to accommodate the parametricity of `EquationTrace`. Since `EquationTrace` usually holds a `Term`, rather than a `Pattern`, we need the `TracePayload` type family to connect the two. The intention is to use `RewriteTrace ()` everywhere, and all the parametricity is only needed to make the code changes minimal. Once we are happy with the API, we could remove parameters from both `RewriteTrace` and `EquationTrace`. * As with `EquationTrace`, a we now have the `eraseStates :: RewriteTrace Pattern -> RewriteTrace ()` function that drops the patters from the traces. It also erases the states in euqational traces stored in `RewriteSimplified` constructors. # Future work The `ApplyEquationResult` holds one success and several error cases: ```haskell data ApplyEquationResult = Success Term | FailedMatch MatchFailReason | IndeterminateMatch | IndeterminateCondition [Predicate] | ConditionFalse Predicate | EnsuresFalse Predicate | RuleNotPreservingDefinedness | MatchConstraintViolated Constrained VarName ``` I think it would be cleaner to factor out the error cases into a separate type: ```haskell data ApplyEquationFailureReason = FailedMatch MatchFailReason | IndeterminateMatch | IndeterminateCondition [Predicate] | ConditionFalse Predicate | EnsuresFalse Predicate | RuleNotPreservingDefinedness | MatchConstraintViolated Constrained VarName data ApplyEquationResult = ApplyEquationSuccess Term | ApplyEquationFailure ApplyEquationFailureReason ``` This would make `EquationTrace` cleaner, as currently it can have represent absurd case of `EquationNotApplied ... Success`. --------- Co-authored-by: Samuel Balco <goodlyrottenapple@gmail.com>
- Loading branch information