Remove QType initialization mutex #579

Closed
Habbie opened this Issue Apr 26, 2013 · 5 comments

Projects

None yet

1 participant

@Habbie
Member
Habbie commented Apr 26, 2013

Patch against pdns-3.1 svn tag

I noticed that there were a very high number of mutex hits on the QType object when running with mutrace. This is because every time the class is instantiated it checks to see if the static data has been initialized (and does this using a mutex). The attached patch converts the initialization process into a static constructor which removes the need for any mutex.

@Habbie Habbie was assigned Apr 26, 2013
@Habbie Habbie closed this Apr 26, 2013
@Habbie
Member
Habbie commented Apr 26, 2013

Attachment '' (qtype-mutex-remove.patch) https://gist.github.com/5466795

@Habbie
Member
Habbie commented Apr 26, 2013

Author: anon
Reported & patched by Mark Zealey

@Habbie
Member
Habbie commented Apr 26, 2013

Author: ahu
Mark, have you benchmarked this? It so turns out that a static initializer internally devolves into a .. mutex ;)

So this might not actually help.

bert

@Habbie
Member
Habbie commented Apr 26, 2013

Author: ahu
ok, you did something else, sorry - but it might now be that someone uses a qtype from global scope before it is initialized. this 'should not happen' though ;-)

@Habbie
Member
Habbie commented Apr 26, 2013

Author: ahu
Applied, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment