Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cnrBw-0003SI-7M for pgsql-hackers@arkaria.postgresql.org; Tue, 14 Mar 2017 18:29:04 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cnrBv-0007Mz-Kv for pgsql-hackers@arkaria.postgresql.org; Tue, 14 Mar 2017 18:29:03 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cnrBt-0007M2-Oi for pgsql-hackers@postgresql.org; Tue, 14 Mar 2017 18:29:01 +0000 Received: from mail-lf0-x243.google.com ([2a00:1450:4010:c07::243]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1cnrBq-0000hm-VN for pgsql-hackers@postgresql.org; Tue, 14 Mar 2017 18:29:00 +0000 Received: by mail-lf0-x243.google.com with SMTP id y193so14663161lfd.1 for ; Tue, 14 Mar 2017 11:28:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:references:from:cc:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=hJ/gwXEUsWoUEYkP3CHjqI8WiDgR7X/vjFLf+HBoTu8=; b=Jnw3M2xOl51OGQX9vsp06OCIx/1I0VYoupe/oyZhLEqgEMe8h+UnFtCl5+ghxVYN6x KTuHcDAO/MzLV2rXaz4/ChyAQiGHyXpC5lGDaMzQB8Q8gqu1rNfvjEdfV+8L+/lkU819 nDhPASlVMJiQaib2Sa79qckQHGnU9ZBU6K0JK+FYL1s3QDxrrgEUSteHlgOKaGH37w5b TnOyS+ioqCuIX9GGvGiBUS8S2+AwWvdaQUvdpgP/P9KToeJ6Wm9YmpN55zsO/wjSIJd2 FCZU7B1CAkzROo2xNk+KwVpC3Cfr2dGWCQ/AfbXcN09au9Rop4+M9mP0SP1sSRsyu79K xJng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:references:from:cc:message-id :date:user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=hJ/gwXEUsWoUEYkP3CHjqI8WiDgR7X/vjFLf+HBoTu8=; b=fkjDCvToZ9ohCeHB381lh3qvbai9G7nBhn/OzeGtdLO0Lk34WCvoUXnSfCQOEvHyaP fMVbZ/OcKr/8sMfMcI+0h2n+31FCZ6432fmRElP7+1pO5wR1YGtSlJkAFgYSvpzVECVN ZqB4HyemIBIvhRp4AA9V25GtpOWWDjv5HpvUIXabZixOHqP7G82eDn86hDkLNMJeOgOL a/YcqoHJ5RrbhBzdUjeywrMSWiF6UtIv7xm/mbbhpbup8kkPB+U2yw3ja4L58PPjhjWy YKFrpc6aCufxbJ+6GpFbPPzooPSfAET0bxgYRYp4vGXdzx4BBBb2+fQ11BubtS08kX7S RMWA== X-Gm-Message-State: AMke39nL3OugpaSsLauHWhUUzwvZ1a0HNQpHcJdm268Nb8EDch1N2h3vbeRk8ggM0KQi8Q== X-Received: by 10.46.9.74 with SMTP id 71mr12189352ljj.30.1489516136420; Tue, 14 Mar 2017 11:28:56 -0700 (PDT) Received: from [192.168.1.99] (dsl-hkibrasgw1-50df7f-241.dhcp.inet.fi. [80.223.127.241]) by smtp.gmail.com with ESMTPSA id v136sm4364650lfa.66.2017.03.14.11.28.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 Mar 2017 11:28:55 -0700 (PDT) Subject: Re: WIP: Faster Expression Processing v4 To: Andres Freund References: <20161206034955.bh33paeralxbtluv@alap3.anarazel.de> <20170209003312.rr7atqepgbrf4xqe@alap3.anarazel.de> <20170307030137.lpo4japv5oqgbqpz@alap3.anarazel.de> <2090fd00-4dec-7b42-f700-64308958504c@2ndquadrant.com> <20170313080351.4g5oubxcj4xj5y7t@alap3.anarazel.de> <20170314065259.ffef4tfhgbsaieoe@alap3.anarazel.de> <69b7bb0e-8dab-3d39-1a89-3c6ab6409f64@iki.fi> <20170314173137.5r5jtgkgx6siuwsy@alap3.anarazel.de> From: Heikki Linnakangas Cc: Tomas Vondra , pgsql-hackers@postgresql.org Message-ID: <58f9a171-edd7-e07d-3e21-52a451cd7c58@iki.fi> Date: Tue, 14 Mar 2017 20:28:51 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.6.0 MIME-Version: 1.0 In-Reply-To: <20170314173137.5r5jtgkgx6siuwsy@alap3.anarazel.de> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.4 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org On 03/14/2017 07:31 PM, Andres Freund wrote: > On 2017-03-14 16:58:54 +0200, Heikki Linnakangas wrote: >> * How tight are we on space in the ExprEvalStep union? Currently, the >> jump-threading preparation replaces the opcodes with the goto labels, but it >> would be really nice to keep the original opcodes, for debugging purposes if >> nothing else. > > There's nothing left to spare :(. For debugging I've just used > ExecEvalStepOp() - it's inconvenient to directly print the struct > anyway, since gdb prints the whole union... This comment above the union is not accurate: > /* > * Data for an operation. Inline stored data is faster to access, but also > * bloats the size of all instructions. The union should be kept below 48 > * bytes (so the entire struct is below 64bytes, a single cacheline on > * common systems). > */ On my x86-64 system, the whole struct is 64 bytes, but the union is only 40 bytes. The fields before the union occupy 24 bytes. IOW, the union should be kept below 40 bytes, not 48. Hmm. Could we make the instructions variable size? It would allow packing the small instructions even more tight, and we wouldn't need to obsess over a particular maximum size for more complicated instructions. A compromise might be to have the fixed size, but have "continuation" opcodes for the more complicated instructions. An XmlExpr instruction, for example, could have an extra instruction after the primary one, just to hold more fields. When evaluating it, we would just increment the Program Counter by two instead of one, to skip over the extra instruction. For reference, here are the sizes of all the structs in the union: 40: xmlexpr 40: scalararrayop 40: minmax 40: iocoerce 40: convert_rowtype 32: wholerow 32: rowcompare_step 32: row 32: func 32: fieldstore 32: domaincheck 32: boolexpr 32: arrayexpr 32: arraycoerce 24: casewhen 24: casethen 24: arrayref_checksubscript 16: grouping_func 16: fieldselect 16: constval 16: casetest 16: assign_var 16: arrayref 8: window_func 8: subplan 8: sqlvaluefunction 8: param 8: nulltest_row 8: assign_tmp 8: alternative_subplan 8: aggref 4: var 4: rowcompare_final 4: qualexpr 4: fetch 4: coalesce - Heikki -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers