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

Stack allocate dict iterators #917

Merged
merged 1 commit into from
Jan 26, 2021

Conversation

bjosv
Copy link
Contributor

@bjosv bjosv commented Jan 25, 2021

Replacing the get & release functions with an initiation function.
Simplifies the code and will make sure we run subscription callbacks in OOM scenarios.

Replacing the get & release functions with an initiation
function. Simplifies the code and will make sure we
run subscription callbacks in OOM scenarios.
Copy link
Contributor

@zuiderkwast zuiderkwast left a comment

Choose a reason for hiding this comment

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

Nice! Using stack instead of heap is usually a good idea.

I think the same can be done in Redis itself.

@michael-grunder michael-grunder self-assigned this Jan 26, 2021
@michael-grunder
Copy link
Collaborator

This looks good. The only thing to worry about is symbol conflict when hiredis is built as part of Redis, but we aren't exporting dictGetIterator and Redis doesn't have dictInitIterator anyway so we should be good.

000000000000b2b0 l     F .text	0000000000000085              dictFind
000000000000b560 l     F .text	00000000000001a3              dictExpand
000000000000b710 l     F .text	00000000000000ca              _dictClear.isra.0

@michael-grunder michael-grunder merged commit 7d99b56 into redis:master Jan 26, 2021
@michael-grunder
Copy link
Collaborator

Merged, thanks!

@bjosv bjosv deleted the stack-alloc-dict-iter branch January 26, 2021 21:39
@zuiderkwast
Copy link
Contributor

zuiderkwast commented Jan 26, 2021

Good. Adding dictInitIterator to Redis won't cause any conflict either, will it? It would be equally useful there..

@bjosv
Copy link
Contributor Author

bjosv commented Jan 27, 2021

I thought about if there could be a clash of the two, very different, dict types in redis and hiredis, but came to the conclusion that it seems to work already today.
The pre-processor in a Redis build should pick its own dict.h first, even that hiredis dict.h is in the include path,
and the linkage step have dict.o before libhiredis.a

It exists a compability layer for the two different sds string types, but I guess thats only needed because that type is transferred between two entities, and dict's are only used within each entity?

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