(2023Q1) Gas effort: Snoop usages
This is a sub-milestone of %(2023Q1) Gas effort. It can be seen as a continuation of %(OKR 2022Q3 - 4.2) - Gas effort: Codegen and %(OKR 2022Q4 - ???) Gas Effort: Consolidate Snoop's models and inference strategy.
This milestone is being continued in %(2023Q2) Gas effort: simplify Snoop UX for core developers, with a lot also being backlogged in %(2023Q2) Gas effort.
Work break down
Some technical details are reported below.
-
Auto-generation of gas cost functions. - Auto-generated code can now go in
lib_protocoland compiles🎉 - Focus on the biggest module:
Michelson_v1_gas_costs_generated.-
Move manually edited functions to Michelson_v1_gas_costs: #4683 (closed).
-
- Auto-generated code can now go in
-
Allow Snoop to directly work on models or parameters. -
Register models in Snoop independently of the benchmarks: #4073 (closed). - There exists two different kinds of models, we only register models that can be code-generated.
-
Deduce (and run) benchmarks needed for the inference of a model or parameter: #4075 (closed). -
Code generation from multiple solution files: !7527 (merged). -
Fix build rule for auto-generated code: #4684 (closed).
-
-
Simplify Snoop's usage. -
Higher-level registration process: !7752 (merged). -
Migrate all benchmarks with the new registration process.
-
- Make gas represent hardware-independent time consumption (brainstorming ideas for now).
- Plan a meeting with experts.
- Report the possible strategies to tackle the issue.
- Postponed to Q2.
Context
Auto-generation of gas cost functions
Not only benchmarking and inferencing the gas cost parameters, Snoop can generate cost functions automatically from the solutions. We must integrate this auto-generation into our code base and update the cost functions not by changing parameters by hand but by giving the updated solution files.
Some cost functions cannot be auto-generatable. Some are for optimizations. Some are by technical difficulties. We must split these hand-edited functions from the auto-generatable ones. And forbid any hand-edition of the generated functions.
Most of the cost functions are for Michelson and we are currently working on the auto-generation of its cost functions, but the other features (such as the global constants and roll-ups) have also cost functions derived from Snoop benchmarks. We would like to auto-generate their cost functions, too.
Allow Snoop to directly work on models or parameters
Another work direction related to Snoop concerns the usage of the tool. In Snoop, a set of benchmarks is defined with a name, and contains all the models to benchmark, each of these models also declared with a name.
For instance, the skip_list_benchmarks.ml registers a set of benchmarks named next, that in turn allows to benchmark the Skip_list.next function against a log_n model named skip_list_next.
Then, the command to trigger the benchmarking takes as input the name of the set of benchmarks (next).
Inferring gas parameter values based on the benchmark results takes as input the model name (skip_list_next). It returns values whose names depend on the model used.
Generating the corresponding OCaml code outputs a name defined in the benchmarks by the developer.
We would like Snoop to be able to work directly given the name of a gas parameter, as fed to the code generator. Or also given the name of the cost function generated.
Make gas represent hardware-independent time consumption
For the moment, gas represents computing time on a dedicated, reference machine. This drastically limits the possibilities to run the benchmarks more often, as part of the continuous integration for instance, or even for a developer to run a specific benchmark on her machine and add the corresponding generated code into the protocol.
We would like to lift this limitation.
Technical details
This section gives more details on specific items from the Work break down section.
- Auto-generation of gas cost functions.
- Focus on the biggest module:
Michelson_v1_gas_costs_generated.-
Add comments to manually edited cost functions: #4711 (closed).
-
- Focus on the biggest module:
- Allow Snoop to directly work on models or parameters.
-
Add a command to investigate solution files: !7528 (merged). -
Clean-up: make sure all benchmarks, models and parameters are appropriately named: #4178 (closed). - Important step before the next one
-
Move the dependency graph computation from bin_snooptolib_benchmark: #4074 (closed). -
Unit test for config file: #4176 (closed) (follow-up). - Blocked by a "bug" in
json_data_encoding, fix proposed in nomadic-labs/json-data-encoding!46.
- Blocked by a "bug" in
-
Use a set for namespaces instead of a list: #4303 (closed) (follow-up).
-