Re: apr_global_mutex_create vs apr_proc_mutex_create
Thanks Luca and William, Thats very informative!
Re: apr_global_mutex_create vs apr_proc_mutex_create
proc_mutex can only be used to block on a cross process event. It can be used in a threaded server, but cannot be held in multiple threads, you might use it to block in a single thread queue per-process. Thread_mutex will not block between processes, this is used for the mutex-per-process logic such as a across accept wait queues. Global_mutex will block, across threads and across processes, as appropriate. On Mar 24, 2016 04:08, "Luca Toscano"wrote: > +httpd-dev@ > > Hello! > > 2016-03-23 21:49 GMT+01:00 Ali Shah : > >> Hi Module maintainers, >> >> I'm writing a simple apache module and I'd like to aggregate some >> statistics. >> I saw an example module that does this ( >> https://wiki.apache.org/httpd/ModuleLife) using shared memory. >> >> My question for those on this list following: >> >> What is the main difference between using mutexes created >> via apr_global_mutex_create and apr_proc_mutex_create in terms of >> performance and safety of the resource that being protected? >> >> The docs seem to discourage usage of apr_global_mutex_create: >> "There is considerable overhead in using this API if only cross-process or >> cross-thread mutual exclusion is required." >> >> Is the overhead purely in code setup (since global mutex should be >> initialized in post_config), or is this describing some performance >> penalties as well? >> > > From what I can see in [1] a global lock uses both apr_proc_mutex_create > and apr_thread_mutex_create, so this is why the documentation suggests the > use of a more specialized one if only cross-process or cross-thread sync is > needed. > > Not a great explanation I know, somebody else with more experience will > give you a better answer on this list :) > > Luca > > > > [1]: > https://github.com/apache/apr/blob/7951861fb029fd0fb60e5ec8da73015d03afa28d/locks/unix/global_mutex.c#L46 > > >
Re: apr_global_mutex_create vs apr_proc_mutex_create
proc_mutex can only be used to block on a cross process event. It can be used in a threaded server, but cannot be held in multiple threads, you might use it to block in a single thread queue per-process. Thread_mutex will not block between processes, this is used for the mutex-per-process logic such as a across accept wait queues. Global_mutex will block, across threads and across processes, as appropriate. On Mar 24, 2016 04:08, "Luca Toscano"wrote: > +httpd-dev@ > > Hello! > > 2016-03-23 21:49 GMT+01:00 Ali Shah : > >> Hi Module maintainers, >> >> I'm writing a simple apache module and I'd like to aggregate some >> statistics. >> I saw an example module that does this ( >> https://wiki.apache.org/httpd/ModuleLife) using shared memory. >> >> My question for those on this list following: >> >> What is the main difference between using mutexes created >> via apr_global_mutex_create and apr_proc_mutex_create in terms of >> performance and safety of the resource that being protected? >> >> The docs seem to discourage usage of apr_global_mutex_create: >> "There is considerable overhead in using this API if only cross-process or >> cross-thread mutual exclusion is required." >> >> Is the overhead purely in code setup (since global mutex should be >> initialized in post_config), or is this describing some performance >> penalties as well? >> > > From what I can see in [1] a global lock uses both apr_proc_mutex_create > and apr_thread_mutex_create, so this is why the documentation suggests the > use of a more specialized one if only cross-process or cross-thread sync is > needed. > > Not a great explanation I know, somebody else with more experience will > give you a better answer on this list :) > > Luca > > > > [1]: > https://github.com/apache/apr/blob/7951861fb029fd0fb60e5ec8da73015d03afa28d/locks/unix/global_mutex.c#L46 > > >
Re: apr_global_mutex_create vs apr_proc_mutex_create
+httpd-dev@ Hello! 2016-03-23 21:49 GMT+01:00 Ali Shah: > Hi Module maintainers, > > I'm writing a simple apache module and I'd like to aggregate some > statistics. > I saw an example module that does this ( > https://wiki.apache.org/httpd/ModuleLife) using shared memory. > > My question for those on this list following: > > What is the main difference between using mutexes created > via apr_global_mutex_create and apr_proc_mutex_create in terms of > performance and safety of the resource that being protected? > > The docs seem to discourage usage of apr_global_mutex_create: > "There is considerable overhead in using this API if only cross-process or > cross-thread mutual exclusion is required." > > Is the overhead purely in code setup (since global mutex should be > initialized in post_config), or is this describing some performance > penalties as well? > >From what I can see in [1] a global lock uses both apr_proc_mutex_create and apr_thread_mutex_create, so this is why the documentation suggests the use of a more specialized one if only cross-process or cross-thread sync is needed. Not a great explanation I know, somebody else with more experience will give you a better answer on this list :) Luca [1]: https://github.com/apache/apr/blob/7951861fb029fd0fb60e5ec8da73015d03afa28d/locks/unix/global_mutex.c#L46
apr_global_mutex_create vs apr_proc_mutex_create
Hi Module maintainers, I'm writing a simple apache module and I'd like to aggregate some statistics. I saw an example module that does this ( https://wiki.apache.org/httpd/ModuleLife) using shared memory. My question for those on this list following: What is the main difference between using mutexes created via apr_global_mutex_create and apr_proc_mutex_create in terms of performance and safety of the resource that being protected? The docs seem to discourage usage of apr_global_mutex_create: "There is considerable overhead in using this API if only cross-process or cross-thread mutual exclusion is required." Is the overhead purely in code setup (since global mutex should be initialized in post_config), or is this describing some performance penalties as well? Thanks! Ali