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
director refcounting #2725
director refcounting #2725
Conversation
now that #2723 is dead, this will need to look slightly diffrent |
I've tried to wrap my head around this and failed. At this point I think that getting back to #2723 would be the cleanest option. Quoting myself on IRC:
|
note to self: this should do it:
|
I've updated the patch as planned:
|
This implementation is centered around the following insights: * Full refcounting is expensive and tidious * For directors, there exist mainly two types of references - long term, from a vcl or a director using another director as a backend - short term for the duration of a VCL task, such as an assignment to (be)req.backend Based on these insights, we implement implicit and explicit references: - Otherwise unreferenced VCL_BACKENDs are put on a cool list (as before for backends), but we now use many cool lists - Each VCL task holds an implicit reference to all VCL_BACKENDs by referencing the current vdi_cool list, thus for any reference with a scope smaller or equal to a TASK, no explicit reference needs to and should be taken - VRT_VDI_Ref/Unref must be called whenever a reference to a VCL_BACKEND with longer scope is kept, for example when adding/removing a VCL_BACKEND to/from a director. Details on coollists: - each task references the current coollist - all VCL_BACKENDs with refcnt == 0 are put on the coollist ref'd by the current task. VCL_BACKENDs with refcnt > 0 are not on any coollist - when a VCL_BACKEND is put on a coollist and the coollist has reached the minimum age, we start a new coollist which is then referenced by all new tasks. This way, the old coollist with the VCL_BACKEND(s) to be killed will eventually get unref'd - We kill backends on unref'd coollists in the order of their creation VCL Backends get created with one initial reference. Dynamic backends get created on the coollist, so their initial scope is just the current task.
v00003.vtc exposes some situation which I have not yet fully understood, but it seems that VBP_Control should only act if anything needs to be done.
panic seen with this patch:
|
20ab2ab very likely helps this patch, will need to get back to it later (not before september release) |
closing this PR as it is not ready any more after recent changes and needs one issue checked |
FTR: We had discussed this idea during the last VDD and @mbgrydeland 's concern was that another per-task mutex operation was unacceptable for performance reasons. I now realized that we could probably combine this with VCL_Ref() / VCL_Rel(), which, besides avoiding another lock operation, could actually simplify the patch also. Might get back to this... |
based upon #2723, description from the main commit's message:
This implementation is centered around the following insights:
Full refcounting is expensive and tidious
For directors, there exist mainly two types of references
long term, from a vcl or a director using another director as a backend
short term for the duration of a VCL task, such as an assignment to (be)req.backend
Based on these insights, we implement implicit and explicit references:
Otherwise unreferenced VCL_BACKENDs are put on a cool list (as before for backends), but we now use many cool lists
Each VCL task holds an implicit reference to all VCL_BACKENDs by referencing the current vdi_cool list, thus for any reference with a scope smaller or equal to a TASK, no explicit reference needs to and should be taken
VRT_VDI_Ref/Unref must be called whenever a reference to a VCL_BACKEND with longer scope is kept, for example when adding/removing a VCL_BACKEND to/from a director.
Details on coollists:
each task references the current coollist
all VCL_BACKENDs with refcnt == 0 are put on the coollist ref'd by the current task. VCL_BACKENDs with refcnt > 0 are not on any coollist
when a VCL_BACKEND is put on a coollist and the coollist has reached the minimum age, we start a new coollist which is then referenced by all new tasks. This way, the old coollist with the VCL_BACKEND(s) to be killed will eventually get unref'd
We kill backends on unref'd coollists in the order of their creation
VCL Backends get created with one initial reference.
Dynamic backends get created on the coollist, so their initial scope is just the current task.