From 0e14e0793ffb891bccd465cf518480685e3cd49e Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Mon, 8 Jun 2009 15:36:42 -0700 Subject: Let query_module abort early for simple matches query_module was already returning DW_CB_ABORT when a simple match was found, but dwflpp::iterate_over_modules was ignoring that and instead forcing the module loop to restart. The only way out of the loop was with the pending_interrupts flag, which is only for signalled interrupts. Now iterate_over_modules will only attempt the dwfl_getmodules loop once, since that loop will only abort if the CB returns DW_CB_ABORT. Then query_module is also modified to return ABORT if pending_interrupts is flagged. My trusty test, stap -l syscall.*, is nearly 2x faster with this change. Empirically, I found that the kernel object is always the first "module" returned, so the syscall probepoints always gets to short-circuit the loop right away. --- dwflpp.cxx | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'dwflpp.cxx') diff --git a/dwflpp.cxx b/dwflpp.cxx index 3af26053..1a589771 100644 --- a/dwflpp.cxx +++ b/dwflpp.cxx @@ -397,13 +397,8 @@ dwflpp::iterate_over_modules(int (* callback)(Dwfl_Module *, void **, void *), base_query *data) { - ptrdiff_t off = 0; - do - { - if (pending_interrupts) return; - off = dwfl_getmodules (dwfl, callback, data, off); - } - while (off > 0); + dwfl_getmodules (dwfl, callback, data, 0); + // Don't complain if we exited dwfl_getmodules early. // This could be a $target variable error that will be // reported soon anyway. -- cgit From f517ee24c58413f7de89ede71c728579c12ace5b Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Mon, 8 Jun 2009 16:37:00 -0700 Subject: Remove dwflpp::default_name It was just a basic NULL check, but creating its string temporaries was causing a fair slowdown. Removing this function and adjusting the callers shaves ~5% off the syscall.* elaboration time. --- dwflpp.cxx | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) (limited to 'dwflpp.cxx') diff --git a/dwflpp.cxx b/dwflpp.cxx index 1a589771..74294384 100644 --- a/dwflpp.cxx +++ b/dwflpp.cxx @@ -84,15 +84,6 @@ dwflpp::~dwflpp() } -string const -dwflpp::default_name(char const * in, char const *) -{ - if (in) - return in; - return string(""); -} - - void dwflpp::get_module_dwarf(bool required, bool report) { @@ -129,10 +120,8 @@ dwflpp::focus_on_module(Dwfl_Module * m, module_info * mi) mod_info = mi; if (m) { - module_name = default_name(dwfl_module_info(module, NULL, - &module_start, &module_end, - NULL, NULL, NULL, NULL), - "module"); + module_name = dwfl_module_info(module, NULL, &module_start, &module_end, + NULL, NULL, NULL, NULL) ?: "module"; } else { @@ -162,7 +151,7 @@ dwflpp::focus_on_cu(Dwarf_Die * c) assert(module); cu = c; - cu_name = default_name(dwarf_diename(c), "CU"); + cu_name = dwarf_diename(c) ?: "CU"; // Reset existing pointers and names function_name.clear(); @@ -181,7 +170,7 @@ dwflpp::focus_on_function(Dwarf_Die * f) assert(cu); function = f; - function_name = default_name(dwarf_diename(function), "function"); + function_name = dwarf_diename(function) ?: "function"; } -- cgit