From 9b3c54b2fc836e20a0a7895aa759938e62eaacf9 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Mon, 1 Mar 2010 18:42:18 -0800 Subject: PR11246 cont'd: Separate script/stapconf caching I'm separating the caching and creation logic for stapconf, so it can be conditionalized on s.use_cache instead of s.use_script_cache. * session.h (systemtap_session): Store base_hash for better reuse. * hash.cxx (get_base_hash): Get the base from the session, or build it. (find_hash): Split into separate script/stapconf versions. * cache.cxx (add_to_cache, get_from_cache): Ditto. * main.cxx (main): Adapt caller, and delay stapconf until pass-4. --- hash.cxx | 40 ++++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 22 deletions(-) (limited to 'hash.cxx') diff --git a/hash.cxx b/hash.cxx index 36a71a42..6c37dbc7 100644 --- a/hash.cxx +++ b/hash.cxx @@ -104,9 +104,15 @@ void create_hash_log(const string &type_str, const string &parms, const string & log_file.close(); } -static void -get_base_hash (systemtap_session& s, hash& h) +static const hash& +get_base_hash (systemtap_session& s) { + if (s.base_hash) + return *s.base_hash; + + s.base_hash = new hash(); + hash& h = *s.base_hash; + // Hash kernel release and arch. h.add(s.kernel_release); h.add(s.kernel_build_tree); @@ -141,6 +147,8 @@ get_base_hash (systemtap_session& s, hash& h) // know exactly where we're getting run from, we'll use // /proc/self/exe. h.add_file("/proc/self/exe"); + + return h; } @@ -178,10 +186,10 @@ create_hashdir (systemtap_session& s, const string& result, string& hashdir) } -static void -find_script_hash (systemtap_session& s, const string& script, const hash &base) +void +find_script_hash (systemtap_session& s, const string& script) { - hash h(base); + hash h(get_base_hash(s)); struct stat st; // Hash getuid. This really shouldn't be necessary (since who you @@ -260,10 +268,10 @@ find_script_hash (systemtap_session& s, const string& script, const hash &base) } -static void -find_stapconf_hash (systemtap_session& s, const hash& base) +void +find_stapconf_hash (systemtap_session& s) { - hash h(base); + hash h(get_base_hash(s)); // Add any custom kbuild flags for (unsigned i = 0; i < s.kbuildflags.size(); i++) @@ -282,21 +290,10 @@ find_stapconf_hash (systemtap_session& s, const hash& base) } -void -find_hash (systemtap_session& s, const string& script) -{ - hash base; - get_base_hash(s, base); - find_stapconf_hash(s, base); - find_script_hash(s, script, base); -} - - string find_tracequery_hash (systemtap_session& s, const vector& headers) { - hash h; - get_base_hash(s, h); + hash h(get_base_hash(s)); // Add the tracepoint headers to the computed hash for (size_t i = 0; i < headers.size(); ++i) @@ -321,8 +318,7 @@ find_tracequery_hash (systemtap_session& s, const vector& headers) string find_typequery_hash (systemtap_session& s, const string& name) { - hash h; - get_base_hash(s, h); + hash h(get_base_hash(s)); // Add the typequery name to distinguish the hash h.add(name); -- cgit