C++ Logo


Advanced search

Subject: [std-proposals] Feedback on P1609R1, C++ Should Support Just-in-Time Compilation
From: Avi Kivity (avi_at_[hidden])
Date: 2019-09-21 13:37:09


First, this would be very useful to me. There is a class of servers,
which includes databases, that need to serve a wide variety of queries.
There queries involve processing an interpreted language, and so have a
high abstraction cost: copying, comparators, arithmetic operators all
involve virtual calls, and all must be prepared for the most complex
data types. It is not feasible to specialize these queries ahead of time
as every user has their own schema and their own queries.

My feedback:

1. Although it is implied, I would like it to be explicit that non-type
template parameters of class type are legitimate run-time template
parameters for jit. For example, I'd like an expression class that
defines some expression to be evaluated, and then

 Â Â  template <expression e>

 Â Â  [[jit]]

 Â Â  value evaluate(std::vector<value> inputs) {

 Â Â Â Â Â Â Â Â  ...

 Â Â  }

would allow me to specialize evaluation at runtime. `expression` would
be a tree-type object including nested expression objects, so it would
need the full power of C++2a constexpr containers.

2. The proposal asks whether the jit indicator should be in the
declaration, or point of use. I believe it should be at the point of
use. This would allow using a type-erased version of the template
function compiled ahead of time, while some other thread invokes the jit
compiler and waits for compilation to complete. Or perhaps, the server
would only compile the function after the type-erased version has been
executed a sufficient amount of times to warrant jit. This also allows
limiting server memory allocated to jit functions.

3. Some mechanism should be allocated to ask how much memory a jit
function uses, and to allow unlinking and deallocating a jit function
after it is no longer used.

Thanks for the proposal! I hope it makes it into C++23 or even some
earlier technical specification.

STD-PROPOSALS list run by herb.sutter at gmail.com

Standard Proposals Archives on Google Groups