optimize model-init runtime (#985)
`model-init` run-times have been observed to be too high when running systems with many synapses. The main culprit is the `sort_by` function (fvm_layout:723). When testing on a model with 1024 cells and 10000 synapses, 65% of model-init is spent in this function. Comparing two `std::map<std::string, double>` is really expensive. We can replace the string map `synapse_instance.param_value` with a sorted `std::vector<std::pair<unsigned, double>>`, and have an additional `std::map<std::string, unsigned> param_map` to keep track of all the param_name -> unsigned mappings. `model-init` run-time is 2.5x faster (tested on my 4 core i7-7600U laptop): ``` 10000 synapses/cell -------------------------------------------------------------------- | num cells | model-init before (s) | model-init after (s) | -------------------------------------------------------------------- | 1024 | 12 | 5 | | 2048 | 25.5 | 10.8 | | 4096 | 55.5 | 23.2 | | 8192 | 121.8 | 49 | -------------------------------------------------------------------- ```
Please register or sign in to comment