diff options
author | Josh Stone <jistone@redhat.com> | 2010-03-30 14:54:39 -0700 |
---|---|---|
committer | Josh Stone <jistone@redhat.com> | 2010-03-30 15:16:35 -0700 |
commit | 4df79aaf86a9b6dfbccc3c51946024a30ba43726 (patch) | |
tree | 970c39eac7b4d55337b82f1bf7ed0e05f6656d64 /dwflpp.cxx | |
parent | 5898b6e1087175bc85e35ba147334fe87e3d7d06 (diff) | |
download | systemtap-steved-4df79aaf86a9b6dfbccc3c51946024a30ba43726.tar.gz systemtap-steved-4df79aaf86a9b6dfbccc3c51946024a30ba43726.tar.xz systemtap-steved-4df79aaf86a9b6dfbccc3c51946024a30ba43726.zip |
Use a wider cache for simple function lookups
When we have many individual function lookups, like the nearly 1000 with
syscall.*, each one will iterate every CU in the module (M) and then do a
cache lookup in N entries. That's a thousand MlogN lookups.
We can instead keep the functions in a module-wide map, and then the
complexity is just a thousand logMN lookups.
Before:
$ ./run-stap -l 'syscall.**' --vp 01 >/dev/null
Pass 2: analyzed script: 793 probe(s), 11 function(s), 20 embed(s),
0 global(s) using 245872virt/147304res/78272shr kb,
in 1390usr/60sys/1448real ms.
After:
$ ./run-stap -l 'syscall.**' --vp 01 >/dev/null
Pass 2: analyzed script: 793 probe(s), 11 function(s), 20 embed(s),
0 global(s) using 246228virt/147616res/78276shr kb,
in 720usr/60sys/782real ms.
* dwflpp.cxx (dwflpp::iterate_single_function): Do a simple function
lookup based on a module-wide cache.
(dwflpp::mod_function_caching_callback): Helper for above.
* tapsets.cxx (dwarf_query::query_module_functions): Query a single
function from the module-wide cache.
(dwarf_query::query_module_dwarf): Use above for simple cases.
Diffstat (limited to 'dwflpp.cxx')
-rw-r--r-- | dwflpp.cxx | 60 |
1 files changed, 60 insertions, 0 deletions
@@ -99,6 +99,7 @@ dwflpp::~dwflpp() { delete_map(module_cu_cache); delete_map(cu_function_cache); + delete_map(mod_function_cache); delete_map(cu_inl_function_cache); delete_map(global_alias_cache); delete_map(cu_die_parent_cache); @@ -796,6 +797,14 @@ dwflpp::cu_function_caching_callback (Dwarf_Die* func, void *arg) int +dwflpp::mod_function_caching_callback (Dwarf_Die* cu, void *arg) +{ + dwarf_getfuncs (cu, cu_function_caching_callback, arg, 0); + return DWARF_CB_OK; +} + + +int dwflpp::iterate_over_functions (int (* callback)(Dwarf_Die * func, base_query * q), base_query * q, const string& function) { @@ -855,6 +864,57 @@ dwflpp::iterate_over_functions (int (* callback)(Dwarf_Die * func, base_query * } +int +dwflpp::iterate_single_function (int (* callback)(Dwarf_Die * func, base_query * q), + base_query * q, const string& function) +{ + int rc = DWARF_CB_OK; + assert (module); + + get_module_dwarf(false); + if (!module_dwarf) + return rc; + + cu_function_cache_t *v = mod_function_cache[module_dwarf]; + if (v == 0) + { + v = new cu_function_cache_t; + mod_function_cache[module_dwarf] = v; + iterate_over_cus (mod_function_caching_callback, v); + if (sess.verbose > 4) + clog << "module function cache " << module_name + << " size " << v->size() << endl; + } + + cu_function_cache_t::iterator it; + cu_function_cache_range_t range = v->equal_range(function); + if (range.first != range.second) + { + for (it = range.first; it != range.second; ++it) + { + Dwarf_Die cu_mem; + Dwarf_Die& die = it->second; + if (sess.verbose > 4) + clog << "module function cache " << module_name + << " hit " << function << endl; + + // since we're iterating out of cu-context, we need each focus + focus_on_cu(dwarf_diecu(&die, &cu_mem, NULL, NULL)); + + rc = (*callback)(& die, q); + if (rc != DWARF_CB_OK) break; + } + } + + // undo the focus_on_cu + this->cu = NULL; + this->function_name.clear(); + this->function = NULL; + + return rc; +} + + /* This basically only goes one level down from the compile unit so it * only picks up top level stuff (i.e. nothing in a lower scope) */ int |