All hash tables should use tal#5868
Merged
rustyrussell merged 12 commits intoElementsProject:masterfrom Jan 12, 2023
Merged
Conversation
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]>
Closed
902a0b8 to
fc74f69
Compare
endothermicdev
approved these changes
Jan 11, 2023
Collaborator
endothermicdev
left a comment
There was a problem hiding this comment.
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; |
Collaborator
There was a problem hiding this comment.
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.
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]>
Signed-off-by: Rusty Russell <[email protected]>
Thanks C committee! Signed-off-by: Rusty Russell <[email protected]>
fc74f69 to
410e94d
Compare
Contributor
Author
|
Added the typo fix that @vincenzopalazzo found! Ack 410e94d |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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