[prev in list] [next in list] [prev in thread] [next in thread]
List: apache-httpd-dev
Subject: Re: svn commit: r1599625 - /httpd/httpd/trunk/server/mpm/event/event.c
From: Christophe JAILLET <christophe.jaillet () wanadoo ! fr>
Date: 2015-09-29 5:17:07
Message-ID: 560A1ED3.9050208 () wanadoo ! fr
[Download RAW message or body]
Hi,
now that SO_REUSEPORT has landed on 2.4.x, it is easier to try to synch
2.4.x and trunk a bit more.
I looked at r1599625 + r1599641, which set the TZ environment variable,
if unset, in order to have a small performance boost.
First, I've not been able to reproduce the 2% performance boost
described in the patch.
My system is Ubuntu 15.04 and $TZ is apparently empty.
Second, I don't think that this patch should be backported as-is because
it may change the timestamp in the log file.
However, I was wondering if we could call tzset() and use tzname[0] or
tzname[1] instead of the hard coded "UTC+0". According to [1], tzset()
first looks at TZ, but, if not set, then at the /localtime/ file.
This way, we could define TZ if it can be a performance boost in some
cases and avoid the change of behavior on existing systems.
However,
- I don't know if this is portable
- I'm unsure about how daylight saving time will be handled
Any thought ?
Best regards,
CJ
[1]: http://linux.die.net/man/3/tzset
Le 03/06/2014 17:49, jim@apache.org a écrit :
> Author: jim
> Date: Tue Jun 3 15:49:25 2014
> New Revision: 1599625
>
> URL:http://svn.apache.org/r1599625
> Log:
> fold in performance hack from eventopt
>
> Modified:
> httpd/httpd/trunk/server/mpm/event/event.c
>
> Modified: httpd/httpd/trunk/server/mpm/event/event.c
> URL:http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/event/event.c?rev=1599625&r1=1599624&r2=1599625&view=diff
> ==============================================================================
> --- httpd/httpd/trunk/server/mpm/event/event.c (original)
> +++ httpd/httpd/trunk/server/mpm/event/event.c Tue Jun 3 15:49:25 2014
> @@ -57,6 +57,8 @@
> #include "apr_atomic.h"
> #define APR_WANT_STRFUNC
> #include "apr_want.h"
> +#include "apr_env.h"
> +
> #include "apr_version.h"
>
> #include <stdlib.h>
> @@ -2418,6 +2420,25 @@ static void join_start_thread(apr_thread
> }
> }
>
> +static void force_set_tz(apr_pool_t *p) {
> + /* If the TZ variable is unset, many operationg systems,
> + * such as Linux, will at runtime read from /etc/localtime
> + * and call fstat on it.
> + *
> + * By forcing the time zone to UTC if it is unset, we gain
> + * about 2% in raw requests/second (since we format log files
> + * in the local time, if present)
> + *
> + * For more info, see:
> + *<http://www.gnu.org/s/hello/manual/libc/TZ-Variable.html>
> + */
> + char *v = NULL;
> +
> + if (apr_env_get(&v, "TZ", p) != APR_SUCCESS) {
> + apr_env_set("TZ", "UTC+0", p);
> + }
> +}
> +
> static void child_main(int child_num_arg)
> {
> apr_thread_t **threads;
> @@ -3566,6 +3587,7 @@ static void event_hooks(apr_pool_t * p)
> */
> static const char *const aszSucc[] = { "core.c", NULL };
> one_process = 0;
> + force_set_tz(p);
>
> ap_hook_open_logs(event_open_logs, NULL, aszSucc, APR_HOOK_REALLY_FIRST);
> /* we need to set the MPM state before other pre-config hooks use MPM query
>
>
>
[Attachment #3 (text/html)]
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">Hi,<br>
<br>
now that SO_REUSEPORT has landed on 2.4.x, it is easier to try to
synch 2.4.x and trunk a bit more.<br>
<br>
I looked at r1599625 + r1599641, which set the TZ environment
variable, if unset, in order to have a small performance boost.<br>
<br>
<br>
First, I've not been able to reproduce the 2% performance boost
described in the patch.<br>
My system is Ubuntu 15.04 and $TZ is apparently empty.<br>
<br>
<br>
Second, I don't think that this patch should be backported as-is
because it may change the timestamp in the log file.<br>
<br>
<br>
However, I was wondering if we could call tzset() and use
tzname[0] or tzname[1] instead of the hard coded "UTC+0".
According to [1], tzset() first looks at TZ, but, if not set, then
at the <i>localtime</i> file.<br>
This way, we could define TZ if it can be a performance boost in
some cases and avoid the change of behavior on existing systems.<br>
<br>
<br>
However,<br>
- I don't know if this is portable<br>
- I'm unsure about how daylight saving time will be handled<br>
<br>
<br>
Any thought ?<br>
<br>
Best regards,<br>
CJ<br>
<br>
<br>
<br>
[1]: <a class="moz-txt-link-freetext" \
href="http://linux.die.net/man/3/tzset">http://linux.die.net/man/3/tzset</a><br> \
<br> Le 03/06/2014 17:49, <a class="moz-txt-link-abbreviated"
href="mailto:jim@apache.org">jim@apache.org</a> a écrit :<br>
</div>
<blockquote cite="mid:20140603154925.B0707238896F@eris.apache.org"
type="cite">
<pre wrap="">Author: jim
Date: Tue Jun 3 15:49:25 2014
New Revision: 1599625
URL: <a class="moz-txt-link-freetext" \
href="http://svn.apache.org/r1599625">http://svn.apache.org/r1599625</a> Log:
fold in performance hack from eventopt
Modified:
httpd/httpd/trunk/server/mpm/event/event.c
Modified: httpd/httpd/trunk/server/mpm/event/event.c
URL: <a class="moz-txt-link-freetext" \
href="http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/event/event.c?rev=1599 \
625&r1=1599624&r2=1599625&view=diff">http://svn.apache.org/viewvc/httpd/ht \
tpd/trunk/server/mpm/event/event.c?rev=1599625&r1=1599624&r2=1599625&view=diff</a>
==============================================================================
--- httpd/httpd/trunk/server/mpm/event/event.c (original)
+++ httpd/httpd/trunk/server/mpm/event/event.c Tue Jun 3 15:49:25 2014
@@ -57,6 +57,8 @@
#include "apr_atomic.h"
#define APR_WANT_STRFUNC
#include "apr_want.h"
+#include "apr_env.h"
+
#include "apr_version.h"
#include <stdlib.h>
@@ -2418,6 +2420,25 @@ static void join_start_thread(apr_thread
}
}
+static void force_set_tz(apr_pool_t *p) {
+ /* If the TZ variable is unset, many operationg systems,
+ * such as Linux, will at runtime read from /etc/localtime
+ * and call fstat on it.
+ *
+ * By forcing the time zone to UTC if it is unset, we gain
+ * about 2% in raw requests/second (since we format log files
+ * in the local time, if present)
+ *
+ * For more info, see:
+ * <a class="moz-txt-link-rfc2396E" \
href="http://www.gnu.org/s/hello/manual/libc/TZ-Variable.html"><http://www.gnu.org/s/hello/manual/libc/TZ-Variable.html></a>
+ */
+ char *v = NULL;
+
+ if (apr_env_get(&v, "TZ", p) != APR_SUCCESS) {
+ apr_env_set("TZ", "UTC+0", p);
+ }
+}
+
static void child_main(int child_num_arg)
{
apr_thread_t **threads;
@@ -3566,6 +3587,7 @@ static void event_hooks(apr_pool_t * p)
*/
static const char *const aszSucc[] = { "core.c", NULL };
one_process = 0;
+ force_set_tz(p);
ap_hook_open_logs(event_open_logs, NULL, aszSucc, APR_HOOK_REALLY_FIRST);
/* we need to set the MPM state before other pre-config hooks use MPM query
</pre>
</blockquote>
<br>
</body>
</html>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic