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 AD63917B69 for ; Tue, 6 Oct 2015 11:02:24 +0000 (UTC) Received: (qmail 28516 invoked by uid 500); 6 Oct 2015 11:02:24 -0000 Delivered-To: apmail-httpd-dev-archive@httpd.apache.org Received: (qmail 28447 invoked by uid 500); 6 Oct 2015 11:02:24 -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 28437 invoked by uid 99); 6 Oct 2015 11:02:24 -0000 Received: from Unknown (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 Oct 2015 11:02:24 +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 C014BC39FE for ; Tue, 6 Oct 2015 11:02:23 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -0.1 X-Spam-Level: X-Spam-Status: No, score=-0.1 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, SPF_PASS=-0.001, URIBL_BLOCKED=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-us-east.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id iEiFrQIiOQzh for ; Tue, 6 Oct 2015 11:02:18 +0000 (UTC) Received: from mail-qg0-f44.google.com (mail-qg0-f44.google.com [209.85.192.44]) by mx1-us-east.apache.org (ASF Mail Server at mx1-us-east.apache.org) with ESMTPS id E0AA2439E9 for ; Tue, 6 Oct 2015 11:02:17 +0000 (UTC) Received: by qgez77 with SMTP id z77so171019269qge.1 for ; Tue, 06 Oct 2015 04:02:11 -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 :content-type:content-transfer-encoding; bh=jKNc5Rw5XCXRklXA+7V63rnsbudSBBfzFgjgRgWt5aY=; b=CcVKdRgzk/qbiLKfKfhqBmRGqRbXDabLRMixdyZY7fCsPtVeJdtU2Put3wDSzlmVqV iKzqZZHxVs7+ANSXurHUH8wnTlcHlGDLapIQIwf8QsNG8ukL6a+vqAsFYEDF2Ty79JSG HncuVu5xTitxEVwApI68BXP+hJcXwRRIiiM+qzBwYlTfaq6FR6sFk/gh7zgixImswH2N h9hf7lJBPo16gY9b5GZz60nn61w5LfH+jy9TUXy07IRNxrI+T62QA6mataUqCBL6f0MV ap0d6lVRxcaA4xwm7GLAXv0ZOtaULh4sY7teDivluf5vN6nN1B96bmJN7bD0Iyt3UQhU 5pwg== MIME-Version: 1.0 X-Received: by 10.140.131.198 with SMTP id 189mr48598246qhd.83.1444129331422; Tue, 06 Oct 2015 04:02:11 -0700 (PDT) Received: by 10.55.72.20 with HTTP; Tue, 6 Oct 2015 04:02:11 -0700 (PDT) In-Reply-To: <2791C826-8CFB-4DC9-B6AF-566DF625B154@sharp.fm> References: <2791C826-8CFB-4DC9-B6AF-566DF625B154@sharp.fm> Date: Tue, 6 Oct 2015 13:02:11 +0200 Message-ID: Subject: Re: svn commit: r1706669 - in /httpd/httpd/trunk: ./ include/ modules/http/ modules/ssl/ server/ server/mpm/event/ server/mpm/motorz/ server/mpm/simple/ From: Yann Ylavic To: dev@httpd.apache.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Tue, Oct 6, 2015 at 12:15 PM, Graham Leggett wrote: > On 06 Oct 2015, at 1:39 AM, Yann Ylavic wrote: > >>> + >>> + /** Buffered data associated with the current filter. */ >>> + apr_bucket_brigade *bb; >>> + >>> + /** Dedicated pool to use for deferred writes. */ >>> + apr_pool_t *deferred_pool; >> >> Could we make these opaque, eg: [] >> >> This would prevent them from being mangled anywhere (they are >> internals to util_filter.c anyway). > > There weren=E2=80=99t originally internal to util_filter.c, it=E2=80=99s = only subsequently turned out that way. Doing that comes at a cost of a furt= her 8 bytes per filter per request through, which starts adding up. 8 or a few more bytes is a concern, really? > > I would rather finish the filter suspension work before doing any optimis= ing like this, it=E2=80=99s too soon at this stage. Fair enough. > >> It could also possibly avoid walking the brigade for every >> ap_filter_reinstate_brigade() call=E2=80=A6 > > Unfortunately you can=E2=80=99t avoid walking the brigade in the ap_filte= r_reinstate_brigade(), as this is the flow control logic that keeps the ser= ver safe from consuming too much data. Well, there are only invariants here, the loop always computes the same values for the buffered_bb or am I missing something? > >> Also it seems that we leak the hash iterator here (on c->pool). > > We don=E2=80=99t, when you create an iterator with a NULL pool it uses an= iterator internal to the hash. If we passed c->pool to apr_hash_first(), w= e would leak. Correct, R=C3=BCdiger spotted it already, my bad. > >> Shouldn't we call filters_cleanup() from ap_remove_output_filter() too? > > I deliberately decided not to. > > The majority of calls to ap_remove_output_filter() are made when filters = step out the way before data starts flowing, and if we tried to run the cle= anup we=E2=80=99d be performing an unnecessary apr_hash_set() on every invo= cation before the filter was ever added to the hash. > > The point at which it would make a difference is after the EOS bucket is = handled, but at this point it doesn=E2=80=99t matter, all we=E2=80=99re doi= ng is saving one NULL check in the MPM on a loop with a handful of iteratio= ns, it=E2=80=99s not worth the expense. > >> Why not simply use: >> key =3D apr_pmemdup(pool, &f, sizeof f); >> apr_hash_set(f->c->filters, &key, sizeof key, f) >> here, and: >> ap_filter_t *f =3D data; >> apr_hash_set(f->c->filters, &f, sizeof f, NULL); >> in filters_cleanup() above? > > We could but it=E2=80=99s more expensive. The memdup part is replaced by = simply assigning a pointer. Not sure about the overhead, memcpy is optimized for small sizes anyway. At least both "sizeof(ap_filter_t **)" here and in filters_cleanup() should be replaced by "sizeof(ap_filter_t *)" which is syntactically more correct (even if both are equal in C). > >>> + *flush_upto =3D NULL; >>> + >>> + bytes_in_brigade =3D 0; >>> + non_file_bytes_in_brigade =3D 0; >>> + eor_buckets_in_brigade =3D 0; >>> + morphing_bucket_in_brigade =3D 0; >> >> Per the ealier suggestion to make ap_filter_data opaque, these could >> be part of the struct (and reentrant). >> We could then PREPEND after the loop below, and avoid potentially to >> walk the same buckets each time. > > Alas as described above that=E2=80=99s not possible, as it breaks the flo= w control mechanism that prevents the server generating too much data. Unless what's in buffered_bb is opaque (immutable between calls)... Regards, Yann.