]> arthur.barton.de Git - netdata.git/blobdiff - src/main.c
jemalloc and tcmalloc configure best practices applied
[netdata.git] / src / main.c
index 5dbd575805c870d90891d086528aa02c4f5d7123..3e6aa5046845b29fbf552c01c2364829c060db24 100644 (file)
@@ -283,14 +283,9 @@ int main(int argc, char **argv)
     size_t wanted_stacksize = 0, stacksize = 0;
     pthread_attr_t attr;
 
-    // global initialization
-    get_HZ();
-
     // set the name for logging
     program_name = "netdata";
 
-    // parse command line.
-
     // parse depercated options
     // TODO: Remove this block with the next major release.
     {
@@ -379,7 +374,7 @@ int main(int argc, char **argv)
                     break;
                 case 'v':
                     // TODO: Outsource version to makefile which can compute version from git.
-                    printf("netdata 1.3.1_master\n");
+                    printf("netdata %s\n", VERSION);
                     return 0;
                 case 'W':
                     {
@@ -412,6 +407,16 @@ int main(int argc, char **argv)
         load_config(NULL, 0);
 
     {
+        char *pmax = config_get("global", "glibc malloc arena max for plugins", "1");
+        if(pmax && *pmax)
+            setenv("MALLOC_ARENA_MAX", pmax, 1);
+
+#if defined(HAVE_C_MALLOPT)
+        int i = config_get_number("global", "glibc malloc arena max for netdata", 1);
+        if(i > 0)
+            mallopt(M_ARENA_MAX, 1);
+#endif
+
         char *config_dir = config_get("global", "config directory", CONFIG_DIR);
 
         // prepare configuration environment variables for the plugins
@@ -472,6 +477,10 @@ int main(int argc, char **argv)
         global_host_prefix = config_get("global", "host access prefix", "");
         setenv("NETDATA_HOST_PREFIX", global_host_prefix, 1);
 
+        get_system_HZ();
+        get_system_cpus();
+        get_system_pid_max();
+        
         // --------------------------------------------------------------------
 
         stdout_filename    = config_get("global", "debug log",  LOG_DIR "/debug.log");