redis-rb / redis-client

Simple low level client for Redis 6+
MIT License
124 stars 60 forks source link

hiredis: Implement GC compaction #98

Closed casperisfine closed 1 year ago

casperisfine commented 1 year ago

This should allow to avoid pinning response objects.

cc @peterzhu2118 @eightbitraptor, I'd appreciate if you had a minute to review this.

casperisfine commented 1 year ago

Why are task->obj and task->privdata being declared as void *?

Because we don't have control over those, they are members in the hiredis library that we vendored. It's not uncommon for this kind of libraries to have some kind of void *privdata field to help bindings such as this gem. libxml2 do similar things, which Nokogiri uses.

redisReadTask has a parent member which also points to a redisReadTask, how are these being marked/moved

Right, so so read tasks have a parent, but it's basically just a list, not a tree, and we do have all the pointers from the redisReader:

typedef struct redisReader {
    // snip
    redisReadTask **task;
    int tasks; /* length of the task list */

    int ridx; /* Index of current read task */
} redisReader;

So we mark reader->task[0..reader-ridx] and I believe that account for all potential reference. See https://github.com/redis-rb/redis-client/commit/963f1936473d550a4ef0388fe5a3bb72e2b49df0