[sheepdog] [PATCH] sheep: use 1M log space for non-debug mode startup
Liu Yuan
namei.unix at gmail.com
Wed Jun 19 03:49: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 | 3 ++-
lib/logger.c | 2 +-
sheep/sheep.c | 5 +++--
shepherd/shepherd.c | 6 ++++--
4 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/include/logger.h b/include/logger.h
index 03e9686..090fd9b 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
diff --git a/lib/logger.c b/lib/logger.c
index ba9f5db..2a50159 100644
--- a/lib/logger.c
+++ b/lib/logger.c
@@ -593,7 +593,7 @@ void early_log_init(const char *format_name, struct logger_user_info *user_info)
}
notrace int log_init(const char *program_name, int size, bool to_stdout,
- int level, char *outfile)
+ int level, char *outfile)
{
char log_dir[PATH_MAX], tmp[PATH_MAX];
diff --git a/sheep/sheep.c b/sheep/sheep.c
index 0792d21..13577fb 100644
--- a/sheep/sheep.c
+++ b/sheep/sheep.c
@@ -519,6 +519,7 @@ int main(int argc, char **argv)
struct option *long_options;
const char *log_format = "default";
static struct logger_user_info sheep_info;
+ int log_size = LOG_SPACE_SIZE;
install_crash_handler(crash_handler);
signal(SIGPIPE, SIG_IGN);
@@ -567,6 +568,7 @@ int main(int argc, char **argv)
case 'd':
/* removed soon. use loglevel instead */
log_level = SDOG_DEBUG;
+ log_size = LOG_SPACE_DEBUG_SIZE;
break;
case 'D':
sys->backend_dio = true;
@@ -690,8 +692,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, log_size, to_stdout, log_level, path);
if (ret)
exit(1);
diff --git a/shepherd/shepherd.c b/shepherd/shepherd.c
index 418d3ad..90a4311 100644
--- a/shepherd/shepherd.c
+++ b/shepherd/shepherd.c
@@ -789,6 +789,7 @@ int main(int argc, char **argv)
struct option *long_options;
const char *short_options;
+ int log_size = LOG_SPACE_SIZE;
printf(TEXT_BOLD_RED "** WARNING: shepherd is still only suitable for "
"testing and review **" TEXT_NORMAL "\n");
@@ -808,6 +809,7 @@ int main(int argc, char **argv)
break;
case 'd':
log_level = SDOG_DEBUG;
+ log_size = LOG_SPACE_DEBUG_SIZE;
break;
case 'f':
daemonize = false;
@@ -853,8 +855,8 @@ 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, log_size, !daemonize, log_level,
+ (char *)log_file);
if (ret)
panic("initialize logger failed: %m");
--
1.7.9.5
More information about the sheepdog
mailing list