[sheepdog] [PATCH v2] sheep: use 1M log space for non-debug mode startup
Liu Yuan
namei.unix at gmail.com
Thu Jun 20 04:44:46 CEST 2013
This will save a lot of memory footprint of sheep daemon
Signed-off-by: Liu Yuan <namei.unix at gmail.com>
---
include/logger.h | 6 +++---
lib/logger.c | 5 +++--
sheep/sheep.c | 3 +--
shepherd/shepherd.c | 3 +--
4 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/include/logger.h b/include/logger.h
index 03e9686..5c9aab6 100644
--- a/include/logger.h
+++ b/include/logger.h
@@ -19,7 +19,8 @@
#include "util.h"
-#define LOG_SPACE_SIZE (32 * 1024 * 1024)
+#define LOG_SPACE_SIZE (1 * 1024 * 1024)
+#define LOG_SPACE_DEBUG_SIZE (32 * 1024 * 1024)
#define MAX_MSG_SIZE 1024
#define MAX_THREAD_NAME_LEN 20
@@ -29,8 +30,7 @@ struct logger_user_info {
void early_log_init(const char *format_name,
struct logger_user_info *user_info);
-int log_init(const char *progname, int size, bool to_stdout, int level,
- char *outfile);
+int log_init(const char *progname, bool to_stdout, int level, char *outfile);
void log_close(void);
void dump_logmsg(void *);
void log_write(int prio, const char *func, int line, const char *fmt, ...)
diff --git a/lib/logger.c b/lib/logger.c
index ba9f5db..3db2614 100644
--- a/lib/logger.c
+++ b/lib/logger.c
@@ -592,10 +592,11 @@ void early_log_init(const char *format_name, struct logger_user_info *user_info)
exit(1);
}
-notrace int log_init(const char *program_name, int size, bool to_stdout,
- int level, char *outfile)
+notrace int log_init(const char *program_name, bool to_stdout, int level,
+ char *outfile)
{
char log_dir[PATH_MAX], tmp[PATH_MAX];
+ int size = level == SDOG_DEBUG ? LOG_SPACE_DEBUG_SIZE : LOG_SPACE_SIZE;
log_level = level;
diff --git a/sheep/sheep.c b/sheep/sheep.c
index 0792d21..bb3dd87 100644
--- a/sheep/sheep.c
+++ b/sheep/sheep.c
@@ -690,8 +690,7 @@ int main(int argc, char **argv)
if (lock_and_daemon(is_daemon, dir))
exit(1);
- ret = log_init(program_name, LOG_SPACE_SIZE, to_stdout, log_level,
- path);
+ ret = log_init(program_name, to_stdout, log_level, path);
if (ret)
exit(1);
diff --git a/shepherd/shepherd.c b/shepherd/shepherd.c
index 418d3ad..ffe48f3 100644
--- a/shepherd/shepherd.c
+++ b/shepherd/shepherd.c
@@ -853,8 +853,7 @@ int main(int argc, char **argv)
shepherd_info.port = port;
early_log_init(log_format, &shepherd_info);
- ret = log_init(progname, LOG_SPACE_SIZE, !daemonize,
- log_level, (char *)log_file);
+ ret = log_init(progname, !daemonize, log_level, (char *)log_file);
if (ret)
panic("initialize logger failed: %m");
--
1.7.9.5
More information about the sheepdog
mailing list