Functions: speedup multi-function procedure executor
This improves performance of the procedure executor on secondary metrics (i.e. not for the main use case when many elements are processed together, but for the use case when a single element is processed at a time). In my benchmark I'm measuring a 50-60% improvement: * Procedure with a single function (executed many times): `5.8s -> 2.7s`. * Procedure with 1000 functions (executed many times): `2.4 -> 1.0s`. The speedup is mainly achieved in multiple ways: * Store an `Array` of variable states, instead of a map. The array is indexed with indices stored in each variable. This also avoids separately allocating variable states. * Move less data around in the scheduler and use a `Stack` instead of `Map`. `Map` was used before because it allows for some optimizations that might be more important in the future, but they don't matter right now (e.g. joining execution paths that diverged earlier). * Avoid memory allocations by giving the `LinearAllocator` some memory from the stack.
This commit is contained in:
@@ -173,7 +173,7 @@ MFVariable &MFProcedure::new_variable(MFDataType data_type, std::string name)
|
||||
MFVariable &variable = *allocator_.construct<MFVariable>().release();
|
||||
variable.name_ = std::move(name);
|
||||
variable.data_type_ = data_type;
|
||||
variable.id_ = variables_.size();
|
||||
variable.index_in_graph_ = variables_.size();
|
||||
variables_.append(&variable);
|
||||
return variable;
|
||||
}
|
||||
@@ -753,7 +753,7 @@ class MFProcedureDotExport {
|
||||
ss << "null";
|
||||
}
|
||||
else {
|
||||
ss << "$" << variable->id();
|
||||
ss << "$" << variable->index_in_procedure();
|
||||
if (!variable->name().is_empty()) {
|
||||
ss << "(" << variable->name() << ")";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user