-
Notifications
You must be signed in to change notification settings - Fork 248
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[query] Use
sourcecode.Enclosing
to handle timed blocks implicitly (#…
…14683) ### Change Description This change exists as part of larger refactoring work. Herein, I've exchanged hard-coded contextual strings passed to `ExecutionTimer.time` with implict contexts, drawing inspiration from scalatest. These contexts are now supplied after entering functions like `Compile` and `Emit` instead of before (see `ExecuteContext.time`). By sprinking calls to `time` throughout the codebase after entering functions, we obtain a nice trace of the timings with `sourcecode.Enclosing`, minus the previous verbosity. See [1] for more information about what pre-built macros are available. We can always build our own later. See comments in [pull request id] for example output. Note that `ExectionTimer.time` still accepts a string to support uses like `Optimise` and `LoweringPass` where those contexts are provided already. It is also exception-safe now. This change exposed many similarities between the implementations of query execution across all three backends. I've stopped short of full unification which is a greater work, I've instead simplified and moved duplicated result encoding into the various backend api implementations. More interesting changes are to `ExecuteContext`, which now supports - `time`, as discussed above - `local`, a generalisation for temporarily overriding properties of an `ExecuteContext` (inspired by [2]). While I've long wanted this for testing, we were doing some questionable things when reporting timings back to python, for which locally overriding the `timer` of a `ctx` has been very useful. We also follow this pattern for local regions [1] https://github.com/com-lihaoyi/sourcecode [2] https://hackage.haskell.org/package/mtl-2.3.1/docs/Control-Monad-Reader.html#v:local ### Security Assessment This change has no security impact as it's confined to refactoring of existing non-security-related code.
- Loading branch information
Showing
38 changed files
with
4,113 additions
and
4,221 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.