ctdb: Adding memory pool for queue callback

Swen Schillig swen at vnet.ibm.com
Wed Nov 7 15:27:19 UTC 2018


On Wed, 2018-11-07 at 16:09 +0100, Volker Lendecke wrote:
> On Wed, Nov 07, 2018 at 04:07:51PM +0100, Volker Lendecke via samba-
> technical wrote:
> > On Wed, Nov 07, 2018 at 04:01:02PM +0100, Swen Schillig wrote:
> > > In the area where the pool is introduced we almost always have
> > > the
> > > situation that no memory from the pool is used (all mem
> > > available)
> > > and we just want to make use of the fact that we re-use this
> > > memory.
> > 
> > Right, and this is what the talloc speedtest under
> > lib/talloc/testsuite.c:855ff also attempts.
> > 
> > > I just wrote a quick program which is simulating this scenrario
> > > with
> > > the 3 different options with which we could get such memory with
> > > the
> > > following result
> > > 
> > > [swen at linux ~]$ ./a.out
> > > It took 2.219697 seconds to execute 10 million talloc/free
> > > cycles.
> > > It took 1.450206 seconds to execute 10 million talloc(pool)/free
> > > cycles.
> > 
> > There must be a significant difference to the test program in
> > lib/talloc/testsuite.c and yours. Why is your difference closer to
> > a
> > factor of 2 and not 2% like in lib/talloc/testsuite.c, and does
> > that
> > precisely match 
> 
> oops, sentence cut of... "and does that precisely match the ctdb use
> pattern" was what I wanted to say.
> 
Well here is my test code, judge for yourself.

	TALLOC_CTX *pool_ctx = talloc_pool(NULL, 1024);

	if (pool_ctx == NULL) {
		printf("No memory.\n");
		exit(1);
	}

	t = clock();
	for (i = 0; i < 100000000; i++) {
		ts = talloc(NULL, struct test_struct);
		talloc_free(ts);
	}
	t = clock() - t;
	tt = ((double) t) / CLOCKS_PER_SEC;
	printf("It took %f seconds to execute 10 million talloc/free cycles.\n", tt);

	t = clock();
	for (i = 0; i < 100000000; i++) {
		ts = talloc(pool_ctx, struct test_struct);
		talloc_free(ts);
	}
	t = clock() - t;
	tt = ((double) t) / CLOCKS_PER_SEC;
	printf("It took %f seconds to execute 10 million talloc(pool)/free cycles.\n", tt);

	t = clock();
	for (i = 0; i < 100000000; i++) {
		ts = malloc(sizeof(struct test_struct));
		free(ts);
	}
	t = clock() - t;
	tt = ((double) t) / CLOCKS_PER_SEC;
	printf("It took %f seconds to execute 10 million malloc/free cycles.\n", tt);


Cheers Swen





More information about the samba-technical mailing list