| 169 | } |
| 170 | |
| 171 | void ContentionProfiler::dump_and_destroy(SampledContention* c) { |
| 172 | init_if_needed(); |
| 173 | // Categorize the contention. |
| 174 | SampledContention** p_c2 = _dedup_map.seek(c); |
| 175 | if (p_c2) { |
| 176 | // Most contentions are caused by several hotspots, this should be |
| 177 | // the common branch. |
| 178 | SampledContention* c2 = *p_c2; |
| 179 | c2->duration_ns += c->duration_ns; |
| 180 | c2->count += c->count; |
| 181 | c->destroy(); |
| 182 | } else { |
| 183 | _dedup_map.insert(c, c); |
| 184 | } |
| 185 | if (_dedup_map.size() > MAX_CACHED_CONTENTIONS) { |
| 186 | flush_to_disk(false); |
| 187 | } |
| 188 | } |
| 189 | |
| 190 | void ContentionProfiler::flush_to_disk(bool ending) { |
| 191 | BT_VLOG << "flush_to_disk(ending=" << ending << ")"; |