mirror of
https://github.com/verilator/verilator.git
synced 2026-10-06 10:03:44 +02:00
Internals: Optimize temporary memory allocations (#6517)
This patch gets rid of over 80% of temporary dynamic memory allocations (when a malloced node is immediately freed with no other malloc in between). It also gets rid of over 20% of all calls to malloc. It's worth ~3% average verilation speed up with tcmalloc, and more without tcmalloc.
This commit is contained in:
@@ -160,12 +160,7 @@ class StatsReport final {
|
||||
|
||||
public:
|
||||
// METHODS
|
||||
static void addStat(const V3Statistic& stat) {
|
||||
// Avoid memory blow-up when called frequently with zero adds,
|
||||
// e.g. from V3Const invoked on individual expressions.
|
||||
if (stat.sumit() && stat.value() == 0.0) return;
|
||||
s_allStats.push_back(stat);
|
||||
}
|
||||
static void addStat(const V3Statistic& stat) { s_allStats.push_back(stat); }
|
||||
|
||||
static double getStatSum(const string& name) {
|
||||
// O(n^2) if called a lot; present assumption is only a small call count
|
||||
|
||||
Reference in New Issue
Block a user