From: Zheng Li <dev@zheng.li>
To: xen-devel@lists.xenproject.org
Cc: Dave Scott <Dave.Scott@citrix.com>, Joe Jin <joe.jin@oracle.com>,
"Luis R. Rodriguez" <mcgrof@suse.com>,
Luonengjun <luonengjun@huawei.com>, Zheng Li <dev@zheng.li>,
Fanhenglong <fanhenglong@huawei.com>,
Ian Jackson <Ian.Jackson@citrix.com>,
"Liuqiming (John)" <john.liuqiming@huawei.com>
Subject: Re: [PATCH v3 9/9] oxenstored: reduce syslog call overhead (fix typo)
Date: Thu, 25 Sep 2014 22:00:22 +0100 [thread overview]
Message-ID: <1411678822-26528-1-git-send-email-dev@zheng.li> (raw)
In-Reply-To: <1411666502-23709-10-git-send-email-dev@zheng.li>
We noticed that, if configured to use syslog as the logging backend, every
single line of access logging (via the syslog C binding) will call stat on
/etc/localtime for 3 times. The rational behind this is probably to detect any
timezone changes over time.
This is a considerable cost we'd like to avoid, given the intensiveness of our
access logging --- we log almost every xenstore status change (for good
reason). Also a running Xen host is rarely a mobile environment, so the little
benefit can hardly justify the cost.
Setting up the TZ environment varialbe to avoid stat calls.
Signed-off-by: Zheng Li <dev@zheng.li>
---
tools/ocaml/xenstored/logging.ml | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/tools/ocaml/xenstored/logging.ml b/tools/ocaml/xenstored/logging.ml
index 3d4a329..76ccc55 100644
--- a/tools/ocaml/xenstored/logging.ml
+++ b/tools/ocaml/xenstored/logging.ml
@@ -130,8 +130,17 @@ let string_of_date () =
tm.Unix.tm_hour tm.Unix.tm_min tm.Unix.tm_sec
(int_of_float (1000.0 *. msec))
+(* We can defer to syslog for log management *)
let make_syslog_logger facility =
- (* We defer to syslog for log management *)
+ (* When TZ is unset in the environment, each syslog call will stat the
+ /etc/localtime file three times during the process. We'd like to
+ avoid this cost given that we are not a mobile environment and we log
+ almost every xenstore entry update/watch. *)
+ let () =
+ let tz_is_set =
+ try String.length (Unix.getenv "TZ") > 0
+ with Not_found -> false in
+ if not tz_is_set then Unix.putenv "TZ" ":/etc/localtime" in
let nothing () = () in
let write ?level s =
let level = match level with
--
2.1.1
next prev parent reply other threads:[~2014-09-25 21:20 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-25 17:34 Some oxenstored improvements (v3) Zheng Li
2014-09-25 17:34 ` [PATCH v3 1/9] oxenstored: add a poll-based select mechanism Zheng Li
2014-09-25 17:34 ` [PATCH v3 2/9] oxenstored: add facilities to raise the max open fds uplimit Zheng Li
2014-09-25 17:34 ` [PATCH v3 3/9] oxenstored: add a --use-select command line flag Zheng Li
2014-09-25 17:34 ` [PATCH v3 4/9] oxenstored: catch the error when a connection is already deleted Zheng Li
2014-09-25 17:34 ` [PATCH v3 5/9] oxenstored: use hash table to store socket connections Zheng Li
2014-09-25 17:34 ` [PATCH v3 6/9] oxenstored: enable domain connection indexing based on eventchn port Zheng Li
2014-09-25 17:35 ` [PATCH v3 7/9] oxenstored: only process domain connections that notify us by events Zheng Li
2014-09-25 17:35 ` [PATCH v3 8/9] oxenstored: add a safe net mechanism for existing ill-behaved clients Zheng Li
2014-09-25 17:35 ` [PATCH v3 9/9] oxenstored: reduce syslog call overhead Zheng Li
2014-09-25 21:00 ` Zheng Li [this message]
2014-09-26 15:16 ` [PATCH v3 9/9] oxenstored: reduce syslog call overhead (fix typo) Ian Jackson
2014-09-26 15:33 ` Zheng Li
2014-09-26 15:57 ` Ian Jackson
2014-09-26 16:29 ` Zheng Li
2014-09-26 16:37 ` Ian Jackson
2014-09-26 16:38 ` Zheng Li
2014-09-29 14:37 ` Some oxenstored improvements (v3) Konrad Rzeszutek Wilk
2014-09-29 20:55 ` Dave Scott
2014-09-30 10:21 ` Zheng Li
2014-10-07 13:24 ` Konrad Rzeszutek Wilk
2014-10-08 12:59 ` Dave Scott
2014-10-08 13:01 ` Konrad Rzeszutek Wilk
2014-10-08 13:42 ` Ian Campbell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1411678822-26528-1-git-send-email-dev@zheng.li \
--to=dev@zheng.li \
--cc=Dave.Scott@citrix.com \
--cc=Ian.Jackson@citrix.com \
--cc=fanhenglong@huawei.com \
--cc=joe.jin@oracle.com \
--cc=john.liuqiming@huawei.com \
--cc=luonengjun@huawei.com \
--cc=mcgrof@suse.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).