DaemonForums  

Go Back   DaemonForums > FreeBSD > FreeBSD General

FreeBSD General Other questions regarding FreeBSD which do not fit in any of the categories below.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 6th July 2010
vikashb vikashb is offline
New User
 
Join Date: Jul 2010
Posts: 1
Thanked 0 Times in 0 Posts
Default syslog strangeness on freebsd 8.0 and 8.1-RC

Can someone please assist me with some strangeness on FreeBSD 8.0 and 8.1-RC2

using a threaded test code code, I see the that freebsd 8.x seems to be using more memory when using the syslog() call from a c program:


Results:

7.2
without syslog()
PID USERNAME THR PRI NICE SIZE RES STATE TIME WCPU COMMAND
26872 vikashb 1001 8 0 128M 14236K RUN 0:00 0.00% a.out

with syslog()
PID USERNAME THR PRI NICE SIZE RES STATE TIME WCPU COMMAND
26881 vikashb 1001 44 0 128M 26236K RUN 0:00 0.00% a.out

8.0-RELEASE-p3
without syslog()
PID USERNAME THR PRI NICE SIZE RES STATE TIME WCPU COMMAND
61529 vikashb 1001 44 0 129M 14840K RUN 0:01 0.00% a.out

with syslog()
PID USERNAME THR PRI NICE SIZE RES STATE TIME WCPU COMMAND
61507 vikashb 1001 44 0 257M 42708K RUN 0:30 0.00% a.out

8.1-RC2
without syslog()
PID USERNAME THR PRI NICE SIZE RES STATE TIME WCPU COMMAND
33062 vikashb 1001 44 0 129M 14804K RUN 0:00 0.00% a.out

with syslog()
PID USERNAME THR PRI NICE SIZE RES STATE TIME WCPU COMMAND
33056 vikashb 1001 44 0 257M 42708K RUN 0:03 0.00% a.out


I have not been able to find any reasonable information via google.

Why does syslog result in more memory being consumed on 8.x as opposed to 7.2 ?
is this a bug ?

C code below
PHP Code:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
#include <stdarg.h>
#include <errno.h>
#include <syslog.h>
#include <signal.h>
#include <pthread.h>

char *ProgramName "WTF";

int loop 0;
int LogToSTDOUT 1;

void LogMessage(int debug, const char *fmt,...) {
   
extern int LogToSTDOUT;

   
char message[8192];

   
memset(message0sizeof(message));

   
va_list args;

   
va_start(argsfmt);
   
vsnprintf(messagesizeof(message), fmtargs);
   
va_end(args);

   if ( 
LogToSTDOUT )
   {
      
printf("%s\n"message);
   }

   
syslog(LOG_NOTICE"%s"message);

}

unsigned long int getTimeNow()
{
   
struct timeval tv;

   if ( 
gettimeofday(&tvNULL) == -)
   {
      
LogMessage(0"ERROR(%d) %s\n"errnostrerror(errno));
      
tv.tv_sec 0;
   }

   return 
tv.tv_sec;
}

void HandleSignal(int sig)
{
   
loop 0;
   
LogMessage(0"loop  = %d\n"loop);
   
signal(sigSIG_IGN);
   
usleep(1000);
}

void *worker(int n)
{
   while ( 
loop )
   {
      
LogMessage(0"worker #%d logging"n);
      
usleep(1000);
   }

   
pthread_exit(0);
}

int main(int argccharargv[])
{
   
pthread_ttpool;

   
int workers 1000irc;

   
openlog(ProgramNameLOG_PIDLOG_MAIL);

   
unsigned long int duration 120StartTimeTimeNow;

   
signal(SIGINTHandleSignal);
   
signal(SIGTERMHandleSignal);
   
signal(SIGHUPHandleSignal);
   
signal(SIGQUITHandleSignal);

   
StartTime getTimeNow();

   
tpool = (pthread_t*)malloc(workers sizeof(pthread_t));

   if ( 
tpool == NULL )
   {
      
LogMessage(0"malloc failed \n");
      
closelog();
      exit(-
1);
   }

   
memset(tpool0sizeof(pthread_t) * workers);

   
loop 1;

   for ( 
0workersi++ )
   {
      
rc pthread_create(&tpool[i], NULL, (void *(*)(void*))&worker, (void*)i);

      if ( 
rc != )
      {
         
LogMessage(0"pthread_create #%d failed\n");
         
pthread_cancel(tpool[i]);
      }
      else
      {
         
pthread_detach(tpool[i]);
      }
   }

   
LogMessage(0"loop  = %d\n"loop);

   while ( 
loop )
   {
      
TimeNow getTimeNow();

      if ( ( 
TimeNow StartTime )  > duration )
      {
          
loop 0;
      }

      
usleep(1000);
   }

   for ( 
0workersi++ )
   {
      
pthread_cancel(tpool[i]);
   }

   for ( 
0workersi++ )
   {
      
pthread_join(tpool[i], NULL);
   }

   
free(tpool);
   
closelog();
   exit(
0);

Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Syslog-ng Monitor plexter OpenBSD Packages and Ports 8 5th February 2010 09:38 PM
Cisco Secure ACS 4.1 syslog OpenBSD 3.9 cyberpaisalegionair OpenBSD General 1 24th July 2008 06:42 PM
good old syslog-ng issue amiga505 OpenBSD Packages and Ports 7 4th July 2008 06:01 PM
SYSLOG disappearance jaymax FreeBSD General 6 26th June 2008 02:53 AM


All times are GMT. The time now is 10:40 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick