[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] r9612: Another optimization suggested by Shark output: shave off >9 (in tor/trunk: . src/common)
- To: or-cvs@xxxxxxxxxxxxx
- Subject: [or-cvs] r9612: Another optimization suggested by Shark output: shave off >9 (in tor/trunk: . src/common)
- From: nickm@xxxxxxxx
- Date: Wed, 21 Feb 2007 00:57:16 -0500 (EST)
- Delivered-to: archiver@seul.org
- Delivered-to: or-cvs-outgoing@seul.org
- Delivered-to: or-cvs@seul.org
- Delivery-date: Wed, 21 Feb 2007 00:57:26 -0500
- Reply-to: or-talk@xxxxxxxxxxxxx
- Sender: owner-or-cvs@xxxxxxxxxxxxx
Author: nickm
Date: 2007-02-21 00:57:12 -0500 (Wed, 21 Feb 2007)
New Revision: 9612
Modified:
tor/trunk/
tor/trunk/ChangeLog
tor/trunk/src/common/log.c
tor/trunk/src/common/log.h
Log:
r11860@catbus: nickm | 2007-02-21 00:56:15 -0500
Another optimization suggested by Shark output: shave off >90% of uses of logv by cutting down on calls to log_debug when log actually debugging. This is showing up in some profiles bug not others, and might be as much as 2.5%.
Property changes on: tor/trunk
___________________________________________________________________
svk:merge ticket from /tor/trunk [r11860] on 8246c3cf-6607-4228-993b-4d95d33730f1
Modified: tor/trunk/ChangeLog
===================================================================
--- tor/trunk/ChangeLog 2007-02-21 05:57:08 UTC (rev 9611)
+++ tor/trunk/ChangeLog 2007-02-21 05:57:12 UTC (rev 9612)
@@ -56,6 +56,9 @@
o Minor bugfixes (performance):
- Call router_have_min_dir_info half as often. (This is showing up in
some profiles, but not others.)
+ - When using GCC, make log_debug and never get called at all, and its
+ arguments never get evaluated, when no debug logs are configured.
+ (This is showing up in some profiles, but not others.)
o Minor features:
- Remove some never-implemented options. Mark PathlenCoinWeight as
Modified: tor/trunk/src/common/log.c
===================================================================
--- tor/trunk/src/common/log.c 2007-02-21 05:57:08 UTC (rev 9611)
+++ tor/trunk/src/common/log.c 2007-02-21 05:57:12 UTC (rev 9612)
@@ -86,6 +86,9 @@
static int syslog_count = 0;
#endif
+/* What's the lowest log level anybody cares about? */
+int _log_global_min_severity = LOG_NOTICE;
+
static void delete_log(logfile_t *victim);
static void close_log(logfile_t *victim);
@@ -405,6 +408,8 @@
lf->file = stream;
lf->next = logfiles;
logfiles = lf;
+
+ _log_global_min_severity = get_min_log_level();
}
/** Add a log handler to receive messages during startup (before the real
@@ -415,6 +420,8 @@
{
add_stream_log(LOG_NOTICE, LOG_ERR, "<temp>", stdout);
logfiles->is_temporary = 1;
+
+ _log_global_min_severity = get_min_log_level();
}
/**
@@ -433,6 +440,8 @@
lf->callback = cb;
lf->next = logfiles;
logfiles = lf;
+
+ _log_global_min_severity = get_min_log_level();
return 0;
}
@@ -449,6 +458,8 @@
lf->max_loglevel = loglevelMax;
}
}
+
+ _log_global_min_severity = get_min_log_level();
}
/** Close any log handlers added by add_temp_log or marked by mark_logs_temp */
@@ -468,6 +479,8 @@
p = &((*p)->next);
}
}
+
+ _log_global_min_severity = get_min_log_level();
}
/** Make all currently temporary logs (set to be closed by close_temp_logs)
@@ -506,6 +519,7 @@
if (log_tor_version(logfiles, 0) < 0) {
delete_log(logfiles);
}
+ _log_global_min_severity = get_min_log_level();
return 0;
}
@@ -528,6 +542,8 @@
lf->is_syslog = 1;
lf->next = logfiles;
logfiles = lf;
+
+ _log_global_min_severity = get_min_log_level();
return 0;
}
#endif
Modified: tor/trunk/src/common/log.h
===================================================================
--- tor/trunk/src/common/log.h 2007-02-21 05:57:08 UTC (rev 9611)
+++ tor/trunk/src/common/log.h 2007-02-21 05:57:12 UTC (rev 9612)
@@ -120,6 +120,8 @@
#define log _log /* hack it so we don't conflict with log() as much */
#ifdef __GNUC__
+extern int _log_global_min_severity;
+
void _log_fn(int severity, uint32_t domain,
const char *funcname, const char *format, ...)
CHECK_PRINTF(4,5);
@@ -127,8 +129,11 @@
* of the current function name. */
#define log_fn(severity, domain, args...) \
_log_fn(severity, domain, __PRETTY_FUNCTION__, args)
-#define log_debug(domain, args...) \
- _log_fn(LOG_DEBUG, domain, __PRETTY_FUNCTION__, args)
+#define log_debug(domain, args...) \
+ do { \
+ if (PREDICT(_log_global_min_severity == LOG_DEBUG, 0)) \
+ _log_fn(LOG_DEBUG, domain, __PRETTY_FUNCTION__, args); \
+ } while (0)
#define log_info(domain, args...) \
_log_fn(LOG_INFO, domain, __PRETTY_FUNCTION__, args)
#define log_notice(domain, args...) \
@@ -155,13 +160,6 @@
#define log_notice _log_notice
#define log_warn _log_warn
#define log_err _log_err
-/*
-#define debug _debug
-#define info _info
-#define notice _notice
-#define warn _warn
-#define err _err
-*/
#else
/* We don't have GCC's varargs macros, so use a global variable to pass the
* function name to log_fn */
@@ -175,13 +173,6 @@
#define log_notice (_log_fn_function_name=__func__),_log_notice
#define log_warn (_log_fn_function_name=__func__),_log_warn
#define log_err (_log_fn_function_name=__func__),_log_err
-/*
-#define debug (_log_fn_function_name=__func__),_debug
-#define info (_log_fn_function_name=__func__),_info
-#define notice (_log_fn_function_name=__func__),_notice
-#define warn (_log_fn_function_name=__func__),_warn
-#define err (_log_fn_function_name=__func__),_err
-*/
#endif
#endif /* !GNUC */