Skip to content

All hash tables should use tal#5868

Merged
rustyrussell merged 12 commits intoElementsProject:masterfrom
rustyrussell:htable-use-tal
Jan 12, 2023
Merged

All hash tables should use tal#5868
rustyrussell merged 12 commits intoElementsProject:masterfrom
rustyrussell:htable-use-tal

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 <[email protected]>
We want to change the htable allocator to use tal, which will need
this.

Signed-off-by: Rusty Russell <[email protected]>
We want to change the htable allocator to use tal, which will need
this.

Signed-off-by: Rusty Russell <[email protected]>
We want to change the htable allocator to use tal, which will need
this.

Signed-off-by: Rusty Russell <[email protected]>
Since it gets resized during traverse, we would crash by
keeping a pointer to the old one.

Signed-off-by: Rusty Russell <[email protected]>
We want to change the htable allocator to use tal, which will need
this.

Signed-off-by: Rusty Russell <[email protected]>
@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.

Copy link
Collaborator

@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 <[email protected]>
We want to change the htable allocator to use tal, which will need
this.

Signed-off-by: Rusty Russell <[email protected]>
We want to change the htable allocator to use tal, which will need
this.

Signed-off-by: Rusty Russell <[email protected]>
This makes them easier to clean up.

Signed-off-by: Rusty Russell <[email protected]>
Thanks C committee!

Signed-off-by: Rusty Russell <[email protected]>
@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