[ofa-general] Re: [PATCH v3] opensm/osm_qos_policy.c: log matched QoS criteria

Sasha Khapyorsky sashak at voltaire.com
Sat Jun 28 06:16:19 PDT 2008


On 09:30 Sun 22 Jun     , Yevgeny Kliteynik wrote:
> ULP section of the policy file doesn't have separate qos-matching-rule
> and separate qos-level. Each line in this section internally generates
> matching rule, and links it to one of the pre-generated simple qos levels
> that has only SL.
> Do I want to explain it to the user? No. That's the whole point of the ULP
> section - the user is not aware of the full policy file syntax and 
> semantics.

I can understand your motivation, but putting such "pure" debug code
unconditionally on a fast flow paths is bad idea. Just look an example
below (there difference between 'log-test 1' and 'log-test 10' execution
times is x100).

BTW another interesting test is to run OSM_LOG() with level higher
than active (so it will actually do nothing) and to see a difference
with OSM_LOG() free code. It is also huge.

All this means that we should be very careful with adding such stuff.
IMHO OpenSM is already overloaded by various (useful and not really
useful) OSM_LOG() messages.

Sasha


#include <stdio.h>
#include <stdlib.h>
#include <opensm/osm_log.h>

int log_test(osm_log_t *log, unsigned num)
{
	int x = 0;
	char buf[999];
	int n = 0;
	
	buf[0] = '\0';

	while(num--) {
		x += num;
		if (osm_log_is_active(log, OSM_LOG_DEBUG)) {
			n += snprintf(buf + n, sizeof(buf) - n, "%u %s", n,
				"1111111111111111111111111111111111111111111"
				"1111111111111111111111111111111111111111111");
			if (n > sizeof(buf))
				n = sizeof(buf);
		}
	}

	if (osm_log_is_active(log, OSM_LOG_DEBUG))
		OSM_LOG(log, OSM_LOG_DEBUG, "buf: %s\n", buf);

	return x;
}

int main(int argc, char *argv[])
{
	osm_log_t log;
	osm_log_level_t level = 0;
	unsigned n = 10000;
	int ret;

	if (argc > 1)
		level = strtoul(argv[1], NULL, 0);

	ret = osm_log_init_v2(&log, 0, level, "log.file", 0, 0);
	if (ret)
		return ret;

	while (n--)
		ret += log_test(&log, 1000);

	osm_log_destroy(&log);

	return ret;
}



More information about the general mailing list