summaryrefslogtreecommitdiffstats
path: root/tapsets.cxx
diff options
context:
space:
mode:
authorJosh Stone <jistone@redhat.com>2010-03-30 14:54:39 -0700
committerJosh Stone <jistone@redhat.com>2010-03-30 15:16:35 -0700
commit4df79aaf86a9b6dfbccc3c51946024a30ba43726 (patch)
tree970c39eac7b4d55337b82f1bf7ed0e05f6656d64 /tapsets.cxx
parent5898b6e1087175bc85e35ba147334fe87e3d7d06 (diff)
downloadsystemtap-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 'tapsets.cxx')
-rw-r--r--tapsets.cxx58
1 files changed, 57 insertions, 1 deletions
diff --git a/tapsets.cxx b/tapsets.cxx
index 8a78e04c..7b04f794 100644
--- a/tapsets.cxx
+++ b/tapsets.cxx
@@ -641,6 +641,8 @@ struct dwarf_query : public base_query
func_info_map_t filtered_functions;
bool choose_next_line;
Dwarf_Addr entrypc_for_next_line;
+
+ void query_module_functions ();
};
@@ -786,7 +788,13 @@ dwarf_query::query_module_dwarf()
// specifier, we have to scan over all the CUs looking for
// the function(s) in question
assert(has_function_str || has_statement_str);
- dw.iterate_over_cus(&query_cu, this);
+
+ // For simple cases, no wildcard and no source:line, we can do a very
+ // quick function lookup in a module-wide cache.
+ if (spec_type == function_alone && !dw.name_has_wildcard(function))
+ query_module_functions();
+ else
+ dw.iterate_over_cus(&query_cu, this);
}
}
@@ -1652,6 +1660,54 @@ query_cu (Dwarf_Die * cudie, void * arg)
}
+void
+dwarf_query::query_module_functions ()
+{
+ try
+ {
+ filtered_srcfiles.clear();
+ filtered_functions.clear();
+ filtered_inlines.clear();
+
+ // Collect all module functions so we know which CUs are interesting
+ int rc = dw.iterate_single_function(query_dwarf_func, this, function);
+ if (rc != DWARF_CB_OK)
+ {
+ query_done = true;
+ return;
+ }
+
+ set<void*> used_cus; // by cu->addr
+ vector<Dwarf_Die> cus;
+ Dwarf_Die cu_mem;
+
+ for (func_info_map_t::iterator i = filtered_functions.begin();
+ i != filtered_functions.end(); ++i)
+ if (dwarf_diecu(&i->die, &cu_mem, NULL, NULL) &&
+ used_cus.insert(cu_mem.addr).second)
+ cus.push_back(cu_mem);
+
+ for (inline_instance_map_t::iterator i = filtered_inlines.begin();
+ i != filtered_inlines.end(); ++i)
+ if (dwarf_diecu(&i->die, &cu_mem, NULL, NULL) &&
+ used_cus.insert(cu_mem.addr).second)
+ cus.push_back(cu_mem);
+
+ // Reset the dupes since we didn't actually collect them the first time
+ alias_dupes.clear();
+ inline_dupes.clear();
+
+ // Run the query again on the individual CUs
+ for (vector<Dwarf_Die>::iterator i = cus.begin(); i != cus.end(); ++i)
+ query_cu(&*i, this);
+ }
+ catch (const semantic_error& e)
+ {
+ sess.print_error (e);
+ }
+}
+
+
static void
validate_module_elf (Dwfl_Module *mod, const char *name, base_query *q)
{