Commit 0f6d854a authored by Rusty Russell's avatar Rusty Russell

tal: simplify.

All the effort trying to keep the header size down to 2 pointers turns
out to be wasted.  In addition, getting the parent of a tal pointer is
now much faster.

./samba-allocs talloc.dump --tal-size:
Before:
	Virtual size = 9633792, RSS = 3952640
After:
	Virtual size = 9793536, RSS = 3948544

And we're much faster now, esp. on free.

./samba-allocs talloc.dump --tal:
Before:
	Tal time:                2718068ns
	Tal_free time:           3360258ns
	Single tal_free time:    1667412ns
After:
	Tal time:                2788287ns
	Tal_free time:           2290167ns
	Single tal_free time:    1566998ns
Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>


Header from folded patch 'tal-fix-set-destroying-bit.patch':

tal: fix destroying bit usage.

Actually looking at a destroying contexts' parent didn't work, and a couple
of places didn't filter out the destroying bit.
Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
parent 932d65dd
......@@ -18,10 +18,10 @@
* tal_free(X->name) would free X->name as expected, by tal_free(X) would
* free X and X->name.
*
* With an overhead of approximately 2.1 pointers per object (vs. talloc's
* 12 pointers), it's a little slower in freeing single objects, though
* comparable for allocation and freeing whole object trees). It does not
* support talloc's references or failing destructors.
* With an overhead of approximately 4 pointers per object
* (vs. talloc's 12 pointers), it uses dynamic allocation for
* destructors and child lists, so those operations can fail. It does
* not support talloc's references or failing destructors.
*
* Example:
* #include <stdio.h>
......@@ -92,7 +92,6 @@ int main(int argc, char *argv[])
if (strcmp(argv[1], "depends") == 0) {
printf("ccan/compiler\n");
printf("ccan/hash\n");
printf("ccan/likely\n");
printf("ccan/list\n");
printf("ccan/str\n");
......
......@@ -6,8 +6,8 @@ LDLIBS=-lrt
all: speed samba-allocs
speed: speed.o tal.o talloc.o time.o hash.o list.o take.o
samba-allocs: samba-allocs.o tal.o talloc.o time.o hash.o list.o take.o
speed: speed.o tal.o talloc.o time.o list.o take.o
samba-allocs: samba-allocs.o tal.o talloc.o time.o list.o take.o
tal.o: ../tal.c
$(CC) $(CFLAGS) -c -o $@ $<
......@@ -15,8 +15,6 @@ talloc.o: ../../talloc/talloc.c
$(CC) $(CFLAGS) -c -o $@ $<
time.o: ../../time/time.c
$(CC) $(CFLAGS) -c -o $@ $<
hash.o: ../../hash/hash.c
$(CC) $(CFLAGS) -c -o $@ $<
list.o: ../../list/list.c
$(CC) $(CFLAGS) -c -o $@ $<
take.o: ../../take/take.c
......
This diff is collapsed.
......@@ -40,7 +40,6 @@ int main(void)
strcpy(c[0], "hello");
tal_free(c[0]);
ok1(tal_first(parent) == NULL);
tal_free(parent);
return exit_status();
......
......@@ -6,21 +6,14 @@
int main(void)
{
char *p[NUM], *iter;
char *p[NUM] = { NULL }, *iter;
int i;
plan_tests(NUM + 1 + NUM);
/* Create a random tree, but make sure we get multiple
* top-level groups! */
/* Create a random tree */
for (i = 0; i < NUM; i++) {
p[i] = tal(NULL, char);
*p[i] = '0';
if (next_group(&null_parent.c.group) != &null_parent.c.group)
break;
}
for (i++; i < NUM; i++) {
p[i] = tal(p[rand() % i], char);
p[i] = tal(p[rand() % (i + 1)], char);
*p[i] = '0';
}
......
......@@ -9,7 +9,7 @@ int main(void)
plan_tests(9);
p[0] = NULL;
p[0] = tal(NULL, char);
for (i = 1; i < 5; i++)
p[i] = tal(p[i-1], char);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment