runtimeverification / runtimeverification/llvm-backend

Performance overhead in proof_trace_callback_writer

Open
#1,197 1 comment 0 reactions 0 assignees View on GitHub

A pull request for this has already been merged.

  • #1198 by @stevenmeker — merged
Dominant language
C++
Stars
43
Forks
22
PR merge metrics
No merged PRs in 30d

Description

The MPG team have reported a substantial overhead with this class, even when the callback functions are empty. The code in this class does very little but makes use of std::vector<> instantiations for function symbol arguments and substitutions. Putting data in a freshly allocated std::vector<> object implies a heap allocation which much be handled by malloc() and deallocated by free(). One or more malloc()/free() call pairs per rewrite would likely account for the overhead.

One possible resolution is to have a class in the MPG inherit directly from the abstract base class, proof_trace_writer, and cut out proof_trace_callback_writer altogether.

An alternative resolution is to have the needed std::vector<> objects allocated just once inside proof_trace_callback_writer and then resized and reused as needed for each callback. Resizing a vector that already has sufficient memory attached is cheap. Futhermore std::vector<> objects can be moved efficiently with std::move(). However this means that data structures can only be loaned to the MPG in a callback and will not be valid after the callback returns, because they will have be moved or reused.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Locate proof_trace_callback_writer and its relationship to the proof_trace_writer base class and MPG callbacks. Compare the allocation behavior of the callback path, including empty callbacks, then determine which proposed design preserves callback data semantics while removing the overhead. Done means the overhead is reduced and callback behavior remains correct.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
backend, performance
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.