Return-Path: X-Original-To: apmail-httpd-dev-archive@www.apache.org Delivered-To: apmail-httpd-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4A2721059C for ; Thu, 22 Oct 2015 16:03:39 +0000 (UTC) Received: (qmail 14108 invoked by uid 500); 22 Oct 2015 16:03:38 -0000 Delivered-To: apmail-httpd-dev-archive@httpd.apache.org Received: (qmail 14038 invoked by uid 500); 22 Oct 2015 16:03:38 -0000 Mailing-List: contact dev-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@httpd.apache.org list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list dev@httpd.apache.org Received: (qmail 14028 invoked by uid 99); 22 Oct 2015 16:03:38 -0000 Received: from Unknown (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 22 Oct 2015 16:03:38 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 5C8761A24D8 for ; Thu, 22 Oct 2015 16:03:38 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -0.109 X-Spam-Level: X-Spam-Status: No, score=-0.109 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, T_RP_MATCHES_RCVD=-0.01, URIBL_BLOCKED=0.001] autolearn=disabled Authentication-Results: spamd2-us-west.apache.org (amavisd-new); dkim=pass (1024-bit key) header.d=greenbytes.de Received: from mx1-us-west.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id oFH-ZF0duvHc for ; Thu, 22 Oct 2015 16:03:29 +0000 (UTC) Received: from mail.greenbytes.de (mail.greenbytes.de [217.91.35.233]) by mx1-us-west.apache.org (ASF Mail Server at mx1-us-west.apache.org) with ESMTPS id A1ADC20751 for ; Thu, 22 Oct 2015 16:03:28 +0000 (UTC) Received: from [192.168.1.42] (unknown [217.91.35.233]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mail.greenbytes.de (Postfix) with ESMTPSA id DA7C715A0485 for ; Thu, 22 Oct 2015 18:03:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=greenbytes.de; s=mail; t=1445529806; bh=xPrqRxZBin9wJgsvidhme7C7TBdqDzq1nKcwIVIv88w=; h=Subject:From:In-Reply-To:Date:References:To:From; b=ZE5UMKmr5PW1LfYG7ZwqdrfYWe5plsoPgEl9ir1+wzqdvnWohmBpC2Kxw0+Myjq6B 8RN51jfIUWA3X3fH1V8QcEVk4EzHV5nwQnOmfrGCQYDowWp0mH3c7Ox747hO1yu3u0 7KoezjKq5x2BEqexhQeHAV4yFyMJZxddPTXkgSMA= Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 9.1 \(3096.5\)) Subject: Re: buckets and connections (long post) From: Stefan Eissing In-Reply-To: <8C00B305-BECC-4A48-9A03-8A7CA99EADE4@sharp.fm> Date: Thu, 22 Oct 2015 18:03:26 +0200 Content-Transfer-Encoding: quoted-printable Message-Id: <8642583F-79A4-4A8D-A7CF-43CD79029673@greenbytes.de> References: <7B24F4D1-6904-4C00-A337-88F712026BE9@greenbytes.de> <0D5B13DA-8642-4662-9606-6B5DF94EB87B@sharp.fm> <4D37F1D6-E2FB-408B-9D82-9F7ABABFFE1E@greenbytes.de> <8C00B305-BECC-4A48-9A03-8A7CA99EADE4@sharp.fm> To: dev@httpd.apache.org X-Mailer: Apple Mail (2.3096.5) > Am 21.10.2015 um 16:48 schrieb Graham Leggett : >=20 > On 21 Oct 2015, at 4:18 PM, Stefan Eissing = wrote: >> 6. pool buckets are very tricky to optimize, as pool creation/destroy = is not thread-safe in general >> and it depends on how the parent pools and their allocators are set = up.=20 >> Early hopes get easily crushed under load. >=20 > As soon as I see =E2=80=9Cbuckets aren=E2=80=99t thread safe=E2=80=9D = I read it as =E2=80=9Cbuckets are being misused=E2=80=9D or =E2=80=9Cpool = lifetimes are being mixed up". >=20 > Buckets arise from allocators, and you must never try add a bucket = from one allocator into a brigade sourced from another allocator. For = example, if you have a bucket allocated from the slave connection, you = need to copy it into a different bucket allocated from the master = connection before trying to add it to a master brigade. >=20 > Buckets are also allocated from pools, and pools have different = lifetimes depending on what they were created for. If you allocate a = bucket from the request pool, that bucket will vanish when the request = pool is destroyed. Buckets can be passed from one pool to another, that = is what =E2=80=9Csetaside=E2=80=9D means. >=20 > It is really important to get the pool lifetimes right. Allocate = something accidentally from the master connection pool on a slave = connection and it appears to work, because generally the master outlives = the slave. Until the master is cleaned up first, and suddenly memory = vanishes unexpectedly in the slave connections - and you crash. >=20 > There were a number of subtle bugs in the proxy where buckets had been = allocated from the wrong pool, and all sorts of weirdness ensued. Make = sure your pool lifetimes are allocated correctly and it will work. This is all true and correct - as long as all this happens in a single = thread. If you have multiple threads and create sub pools for each from = a main pool, each and every create and destroy of these sub-pools, plus = any action on the main pool must be mutex protected. I found out.=20 Similar with buckets. When you create a bucket in one thread, you may = not destroy it in another - *while* the bucket_allocator is being used. = bucket_allocators are not thread-safe, which means bucket_brigades are = not, which means that all buckets from the same brigade must only be = used inside a single thread. This means for example that, even though mod_http2 manages the pool = lifetime correctly, it cannot pass a response bucket from a request pool = in thread A for writing onto the main connection in thread B, *as long = as* the response is not complete and thread A is still producing more = buckets with the same allocator. etc. etc. That is what I mean with not-thread-safe. //Stefan=