[go: up one dir, main page]

RISC-V: Configure memory in a nicer way

Closes RV-497

What

Replaces the MainMemoryLayout trait with the new configuration mechanism mechanism MemoryConfig. The new mechanism is defined in the crate::machine_state::memory namespace.

Why

As part of the Supervisor work, the memory configuration needs significant extensions which are harder to achieve with the existing MainMemoryLayout. See the How section for more details.

How

MainMemoryLayout treats memory configuration and layout as the same type. As the configuration evolves, so must the layout and its associated code. We can achieve higher code reuse by separating configuration and layout. An associated Layout type can be implemented using existing layout types and therefore inherit Layout, ProofLayout and CommitmentLayout implementations.

MainMemoryLayout covers implementation of low-level details but not the "Memory" interface. This requires a 3-way split of the memory implementation into a) low-level interface, b) low-level implementation and c) high-level memory interface. With the mechanism we only need a high-level memory interface and implementation. This makes it much more concise and easier to swap out as the high-level interface is inherently more stable.

Review Advice

I split the changes into two commits:

  1. Introduce the memory configuration mechanism
  2. Migrate everything to the new mechanism

I recommend looking at commit 1 in isolation first.

Manually Testing

make -C src/riscv all

Benchmarking

There is a small performance improvement measurable on the reference machine.

master This MR Improvement
M3 MBP 5.223 TPS 5.207 TPS -0.31%
Benchmark Machine 3.415 TPS 3.450 TPS +1.02%

Tasks for the Author

  • Link all Linear issues related to this MR using magic words (e.g. part of, relates to, closes).
  • Eliminate dead code and other spurious artefacts introduced in your changes.
  • Document new public functions, methods and types.
  • Make sure the documentation for updated functions, methods, and types is correct.
  • Add tests for bugs that have been fixed.
  • Put in reasonable effort to ensure that CI will pass.
    • make -C src/riscv
    • dune build src/lib_riscv
    • dune build src/rust_deps
  • Benchmark performance and populate the table above if needed.
  • Explain changes to regression test captures when applicable.
  • Write commit messages to reflect the changes they're about.
  • Self-review your changes to ensure they are high-quality.
  • Complete all of the above before assigning this MR to reviewers.
Edited by Ole Krüger

Merge request reports

Loading