Return-Path: X-Original-To: apmail-httpd-modules-dev-archive@minotaur.apache.org Delivered-To: apmail-httpd-modules-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 68AA11847F for ; Thu, 24 Mar 2016 09:08:48 +0000 (UTC) Received: (qmail 80432 invoked by uid 500); 24 Mar 2016 09:08:47 -0000 Delivered-To: apmail-httpd-modules-dev-archive@httpd.apache.org Received: (qmail 80293 invoked by uid 500); 24 Mar 2016 09:08:47 -0000 Mailing-List: contact modules-dev-help@httpd.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: modules-dev@httpd.apache.org Delivered-To: mailing list modules-dev@httpd.apache.org Received: (qmail 79378 invoked by uid 99); 24 Mar 2016 09:08:47 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 24 Mar 2016 09:08:47 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 099E2C2A8A; Thu, 24 Mar 2016 09:08:47 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.179 X-Spam-Level: * X-Spam-Status: No, score=1.179 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=2, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd1-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id jOdvOG2voxgE; Thu, 24 Mar 2016 09:08:46 +0000 (UTC) Received: from mail-lb0-f182.google.com (mail-lb0-f182.google.com [209.85.217.182]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id B41A25F247; Thu, 24 Mar 2016 09:08:45 +0000 (UTC) Received: by mail-lb0-f182.google.com with SMTP id qe11so25840979lbc.3; Thu, 24 Mar 2016 02:08:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to; bh=pd9253ROeZnZfVOx6PTIFyugJsIQ4FCCar0dFqfc8VA=; b=ItViJA54/dQHX/DAsdMndK7/VmDokHLoVdLN8O1T82ZN6J6bCe1U5ld8uHpa5rE8QE KvcBwEx0tQSUqOuqyeU8RmkkvB3cgK9JiRtmJa7ty78ULsPDvVTO2Aby/1CvJs9ApPmK MO39VneJpCasb1Hm4U7Vu0vSnt9O7P8/0z7/cnzOvTVyEgwLK0FuCJf4o8iApUSdgMld Lnky5q/PTOkgKTjVoUNDcmu8+PM2dQ6De1D2sP5FeLzTueS9O16UO3W8OgFlrtRj8Qdd VhjGZZkyPECk03kn4B4btv71oX/bKBWHJIFhEIeFo1ToPiyDxXqbFiNhNGVGeMNelMOV 8JJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to; bh=pd9253ROeZnZfVOx6PTIFyugJsIQ4FCCar0dFqfc8VA=; b=jnQ8lr/A9RcSdBFtiM1S3g6E1HQczVx6AnUWxlLcTh93IF62OQC9Orr8YIkMnjxbgf AB7FnlyDrJDCPekt45HamEwzYbekBSoTSpo9kGvl8Q/uoJJ/HQ2KdfyntDljr3NMh4Ko dOCSgaxXI9Fy7HiZ+7C7bAleNXKfBdYFFrFY7GoTSZFAlKlc3v+Q0+0OqYr4Xpq10d3o 4+qE0YQbpehdWzyxl31+8jaU6kitVUFDm68Ynpwlty0mGX3QdbAPQkAnNLNvDndwfTib 4lDRzQ4wnVjiNKPfYMPcpUzIwdITSQO6KuUBQeB65gSJ7zzPVjZAhl6tIDDVhG6aSdxJ OnAA== X-Gm-Message-State: AD7BkJKHE7Mo+C7lqYQMS1Bq/yIqTuhtSfcudUE0gafmKJbzEelYZMEePUIGUkKGPkgRW2NIH0ynmuh/6zXcbw== MIME-Version: 1.0 X-Received: by 10.112.163.135 with SMTP id yi7mr2852282lbb.122.1458810524222; Thu, 24 Mar 2016 02:08:44 -0700 (PDT) Received: by 10.25.31.135 with HTTP; Thu, 24 Mar 2016 02:08:44 -0700 (PDT) In-Reply-To: References: Date: Thu, 24 Mar 2016 10:08:44 +0100 Message-ID: Subject: Re: apr_global_mutex_create vs apr_proc_mutex_create From: Luca Toscano To: modules-dev@httpd.apache.org, dev@httpd.apache.org Content-Type: multipart/alternative; boundary=089e01183bc8174e5d052ec7cbde --089e01183bc8174e5d052ec7cbde Content-Type: text/plain; charset=UTF-8 +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 --089e01183bc8174e5d052ec7cbde--