Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

All hash tables should use tal #5868

Merged
merged 12 commits into from
Jan 12, 2023

Conversation

rustyrussell
Copy link
Contributor

@rustyrussell rustyrussell commented Jan 3, 2023

This would catch memory leaks like the one found by @whitslack in #5865 but requires us to allocate htable structs rather than embed them.

Changelog-None

We want to change the htable allocator to use tal, which will need
this.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
We want to change the htable allocator to use tal, which will need
this.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
We want to change the htable allocator to use tal, which will need
this.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
We want to change the htable allocator to use tal, which will need
this.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Since it gets resized during traverse, we would crash by
keeping a pointer to the old one.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
We want to change the htable allocator to use tal, which will need
this.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
@rustyrussell rustyrussell added this to the v23.02 milestone Jan 3, 2023
@rustyrussell rustyrussell mentioned this pull request Jan 3, 2023
@rustyrussell rustyrussell force-pushed the htable-use-tal branch 3 times, most recently from 902a0b8 to fc74f69 Compare January 9, 2023 01:42
Copy link
Collaborator

@endothermicdev endothermicdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks solid. I love how much simplification the htable_set_allocator call brings to clean up. It's a shame the chan_arr memory can't be recovered for nodes with hashtables, but I doubt it makes sense to optimize here (with many small nodes on the network.)

ACK fc74f69

*/
struct chan *chan_arr[6];
/* If we have more thn that, we use a hash. */
struct chan_map *chan_map;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the original chan array was sized according to the overhead of the htable - I suppose to make the union work out nicely. It looks like this is a net decrease of 1 (or maybe 2 depending on architecture) channels before transitioning to a hash table. Simpler to follow along now, and appreciate the documentation here.

gossipd/routing.h Outdated Show resolved Hide resolved
Copy link
Contributor

@vincenzopalazzo vincenzopalazzo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK fc74f69

We actually reduce the size of struct node by 1 pointer, which
is mildly smaller.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
We want to change the htable allocator to use tal, which will need
this.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
We want to change the htable allocator to use tal, which will need
this.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This makes them easier to clean up.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Thanks C committee!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
@rustyrussell rustyrussell enabled auto-merge (rebase) January 12, 2023 01:13
@rustyrussell
Copy link
Contributor Author

Added the typo fix that @vincenzopalazzo found!

Ack 410e94d

@rustyrussell rustyrussell merged commit 6044184 into ElementsProject:master Jan 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants