Resize algorithms for ISTL backend assume that size(prefix) is cheap
Summary
In PDELab, we moved from custom resize methods for ISTL backends to the more generic dune-functions
resize algorithms pdelab/dune-pdelab!555 (merged). However, these algorithms make the assumption that size(prefix)
is a very cheap method and can be called even for every leaf of the container tree. While it makes sense to check these cases to debug incorrect programs, it does not perform well with complex bases that store dynamic information (e.g. all bases on PDELab). Even a simple benchmark between BlockVector<double>
and BlockVector<FieldVector<double,1>>
already shows the problem:
Vector Type (n=67125249) | Resize Time (s) |
---|---|
BlockVector<FieldVector<double, 1>> (with loop on FieldVector ) |
19.6169 |
BlockVector<FieldVector<double, 1>> (without loop on FieldVector ) |
0.453318 |
BlockVector<double> (with scalar check) |
2.09717 |
BlockVector<double> (without scalar check) |
0.22933 |
My proposal would be to:
- make these checks on debug mode or with an additional pre-processor definition
- stop recursion earlier when deeper containers are known to be non-resizable
What do you think about this?
Edited by Santiago Ospina De Los Ríos