Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement the support code for generating aggregation data
This patch adds support for aggregations to the D compiler and provides an implementation for the count() and lquantize() aggregation functions as examples on how to use the aggegation support. The aggregation functions (defined as identifiers in dt_open.c) are now enumerated as DT_IDENT_AGGFUNC identifiers using numeric values set by enum dt_aggfid in dt_impl.h. This allows for specifying implementation functions in an array indexed by aggregation function id. The prologue generation code will emit instructions to populate the DTrace context aggregation data pointer if the clause makes use of aggregations. The aggregation data buffer contains two copies of each aggregation, stored as pairs, to allow lock-free and wait-free updates to the data for a specific aggregation (on a per-CPU basis). Data updates will be done twice, once for each data copy while the other copy is marked for reading by the consumer. A latch sequence id is provided so that the consumer can detect whether the data changed while it was being read. Aggregation function implementations consist of two functions: the main aggregation function and a function that emits the BPF instructions to implement the actual functionality. The first function performs checks on any arguments to the aggregation function and performs any set up that is needed (e.g.calling dt_cg_node() to generate instructions for argument expressions). It then uses the DT_CG_AGG_IMPL() macro to call the actual implementation function. The DT_CG_AGG_IMPL macro takes the following arguments: - aid: Identifier for the aggregation being worked on - sz: size of the data chunk used by this aggregation - dlp: IR list - drp: register set - f: name of the implementation function - any arguments to pass to the implementation function (if any) The implementation function f takes as arguments: - dlp: IR list - drp: register set - dreg: register that holds a pointer to the data chunk for this aggregation (the copy to be updated) - any extra arguments that were passed to DT_CG_AGG_IMPL The DT_CG_AGG_IMPL macro will: 1. Prepare the first data copy for writing and redirect the consumer to read from the second copy. A register 'dreg' will be reserved to hold a pointer to the data to be updated. 2. Call f(dlp, drp, dreg, ...) to perform the data update. 3. Prepare the second data copy for writing and redirect the consumer to read from the first copy. A register 'dreg' will be reserved to hold a pointer to the data to be updated. 4. Call f(dlp, drp, dreg, ...) to perform the data update. The main compilation routine has been extended to handle aggregations (nodes of type DT_NODE_AGG) similar to how actions are handled. Support for indexing aggregations by a tuple is not implemented yet. Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com> Reviewed-by: Eugene Loh <eugene.loh@oracle.com>
- Loading branch information