I see serious performance regressions.
On Fri, 2009-04-03 at 20:36 +0200, Fabio M. Di Nitto wrote:
> Hi guys,
>
> this is a major rework, and hopefully the last one, for logsys.
>
> The patch is big, so I strongly recommend to read the new code rather
> than looking at the diff itself.
>
> Those are the major changes:
>
> logsys.h:
> - add lots of comments and make it more tidy.
> - drop of the whole NOSUBSYS concept. Absorbed into code.
> - reduce the Internal API exports.
> - drop logsys_init and logsys_conf.
> - drop logsys_atsegv as it was a 100% dup of logsys_atexit.
> - add all possible runtime configuration options.
> - from logsys.h: LOGSYS_DECLARE_SUBSYS needs a feature review (see
> below).
>
> logsys.c:
> - increase SUBSYS_MAX to 63. Allocate one extra for SYSTEM (or default
> settings).
> - make it so that SYSTEM holds the application defaults and SUBSYSTEM
> can override SYSTEM settings (see also below).
> - unify the concept of SYSTEM and SUBSYSTEM within the same data
> structure.
> - make output to targets flexible by subsystem/system priority.
> - fix a bug (also present in current implementation) where loglevel was
> being augmented by one for no reasons (decreasing the output).
> - add a bunch of static helper functions to reduce code duplications a
> lot.
> - add _logsys_system_setup helper to init system and defaults. This
> reduces the amount of code to be built in the construct header.
> - SUBSYSTEM creation automatically inherit default settings from SYSTEM.
> - cleanup usage of subsys and subsysid to be consistent in functions
> interfaces.
> - give a pretty good boost to error return codes.
>
> So generally an example code with the new interface will look like:
>
> #include <corosync/engine/logsys.h>
>
> LOGSYS_DECLARE_SYSTEM("FOO",
> LOG_MODE_OUTPUT_FILE | LOG_MODE_OUTPUT_SYSLOG |
> LOG_MODE_OUTPUT_STDERR | LOG_MODE_THREADED |
> LOG_MODE_FORK,
> 0, /* debug */
> "/root/test.log", /* logfile */
> LOG_LEVEL_INFO, /* logfile_priority */
> LOG_DAEMON, /* syslog facility */
> LOG_LEVEL_INFO, /* syslog level */
> 0, /* tags */
> NULL, /* use default format */
> 1000000); /* flight recorder size */
>
> and this will set and init the logging for the whole application.
>
> Optionally for each file you can create a subsystem:
>
> LOGSYS_DECLARE_SUBSYS("main")
>
> if not specified the file.c will automatically use the main settings.
>
> The new API allows configuration changes to all entries both for the
> SYSTEM and SUBSYSTEM settings..
>
> So it means that you can do at runtime:
>
> logsys_config_file_set("FOO", &err, "/root/newfile.log");
> or
> logsys_config_file_set(NULL, &err, "/root/newfile.log");
>
> (the two calls above are equivalent. you can either specify the SYSTEM
> name or pass NULL and default to SYSTEM).
>
> and everything outside a subsystem will start use the new logfile.
>
> the SUBSYSTEM "main" is not affected by the change.
>
> This is now true for all options in a consistent way.
>
> ----
>
> This new implementation allows a great deal of flexibility and maintain
> all the core features of logsys v2 such as threading and flight
> recorder.
>
> At this point in time I have only a bunch of test files to use against
> the new implementation.
>
> Before porting corosync/openais, I'd like to finalize the interface in
> case something is not right.
>
> Specifically I am not able to make up my mind about
> LOGSYS_DECLARE_SUBSYS. Should it provide a similar interface as
> DECLARE_SYSTEM to allow immediate overrides? or should we keep it simple
> and just let the user do runtime config changes to the SUBSYSTEM when
> required? Both and pro and cons..
> I have also consider this option (pseudo code warning):
>
> #define LOGSYS_DECLARE_SUBSYS(subsys,config_override_function)
> [SNIP]
> if config_override_function {
> config_override_function(subsys);
> }
>
> Cheers
> Fabio
> _______________________________________________
> Openais mailing list
> [email protected]
> https://lists.linux-foundation.org/mailman/listinfo/openais
/*
* Copyright (c) 2008, 2009 Red Hat, Inc.
*
* All rights reserved.
*
* Author: Steven Dake ([email protected])
*
* This software licensed under BSD license, the text of which follows:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* - Neither the name of the MontaVista Software, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <config.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <sys/time.h>
#include <time.h>
#include <corosync/engine/logsys.h>
LOGSYS_DECLARE_SYSTEM ("logtest_rec",
LOG_MODE_OUTPUT_STDERR | LOG_MODE_THREADED,
0, /* debug */
NULL,
LOG_LEVEL_INFO, /* logfile_priority */
LOG_DAEMON, /* syslog facility */
LOG_LEVEL_INFO, /* syslog level */
0, /* tags */
NULL, /* use default format */
1000000); /* flight recorder size */
#define LOGREC_ID_CHECKPOINT_CREATE 2
#define LOGREC_ARGS_CHECKPOINT_CREATE 2
#define ITERATIONS 1000000
static struct timeval tv1, tv2, tv_elapsed;
#define timersub(a, b, result) \
do { \
(result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \
(result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \
if ((result)->tv_usec < 0) { \
--(result)->tv_sec; \
(result)->tv_usec += 1000000; \
} \
} while (0)
static void bm_start (void)
{
gettimeofday (&tv1, NULL);
}
static void bm_finish (const char *operation)
{
gettimeofday (&tv2, NULL);
timersub (&tv2, &tv1, &tv_elapsed);
if (strlen (operation) > 22) {
printf ("%s\t\t", operation);
} else {
printf ("%s\t\t\t", operation);
}
printf ("%9.3f operations/sec\n",
((float)ITERATIONS) / (tv_elapsed.tv_sec + (tv_elapsed.tv_usec / 1000000.0)));
}
static char buffer[256];
int main (void)
{
int i;
char buf[1024];
printf ("heating up cache with logrec functionality\n");
for (i = 0; i < ITERATIONS; i++) {
log_rec (LOGREC_ID_CHECKPOINT_CREATE,
"recordA", 8, "recordB", 8, LOG_REC_END);
}
bm_start();
for (i = 0; i < ITERATIONS; i++) {
log_rec (LOGREC_ID_CHECKPOINT_CREATE,
buffer, 7, LOG_REC_END);
}
bm_finish ("log_rec 1 arguments:");
bm_start();
for (i = 0; i < ITERATIONS; i++) {
log_rec (LOGREC_ID_CHECKPOINT_CREATE,
"recordA", 8, LOG_REC_END);
}
bm_finish ("log_rec 2 arguments:");
bm_start();
for (i = 0; i < 10; i++) {
log_rec (LOGREC_ID_CHECKPOINT_CREATE,
"recordA", 8, "recordB", 8, LOG_REC_END);
}
bm_start();
for (i = 0; i < ITERATIONS; i++) {
log_rec (LOGREC_ID_CHECKPOINT_CREATE,
"recordA", 8, "recordB", 8, "recordC", 8, LOG_REC_END);
}
bm_finish ("log_rec 3 arguments:");
bm_start();
for (i = 0; i < ITERATIONS; i++) {
log_rec (LOGREC_ID_CHECKPOINT_CREATE,
"recordA", 8, "recordB", 8, "recordC", 8, "recordD", 8, LOG_REC_END);
}
bm_finish ("log_rec 4 arguments:");
/*
* sprintf testing
*/
printf ("heating up cache with sprintf functionality\n");
for (i = 0; i < ITERATIONS; i++) {
snprintf (buf, sizeof(buf), "Some logging information %s", "recordA");
}
bm_start();
for (i = 0; i < ITERATIONS; i++) {
snprintf (buf, sizeof(buf), "Some logging information %s", "recordA");
}
bm_finish ("sprintf 1 argument:");
bm_start();
for (i = 0; i < ITERATIONS; i++) {
sprintf (buf, "Some logging information %s %s", "recordA", "recordB");
}
bm_finish ("sprintf 2 arguments:");
bm_start();
for (i = 0; i < ITERATIONS; i++) {
sprintf (buf, "Some logging information %s %s %s", "recordA", "recordB", "recordC");
}
bm_finish ("sprintf 3 arguments:");
bm_start();
for (i = 0; i < ITERATIONS; i++) {
sprintf (buf, "Some logging information %s %s %s %s", "recordA", "recordB", "recordC", "recordD");
}
bm_finish ("sprintf 4 arguments:");
bm_start();
for (i = 0; i < ITERATIONS; i++) {
sprintf (buf, "Some logging information %s %s %s %d", "recordA", "recordB", "recordC", i);
}
bm_finish ("sprintf 4 arguments (1 int):");
logsys_log_rec_store ("fdata");
/* TODO
currently fails under some circumstances
bm_start();
for (i = 0; i < ITERATIONS; i++) {
log_printf (LOG_LEVEL_NOTICE, "test %d", i);
}
bm_finish("log_printf");
*/
return (0);
}
_______________________________________________
Openais mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/openais