[{"id":35440,"web_url":"https://patchwork.libcamera.org/comment/35440/","msgid":"<a452ea45-326b-4b0d-a23d-c9ab12b6758a@ideasonboard.com>","date":"2025-08-15T11:45:39","subject":"Re: [PATCH v2 6/8] utils: codegen: ipc: Optimize constructors of IPA\n\tinterface structures","submitter":{"id":216,"url":"https://patchwork.libcamera.org/api/people/216/","name":"Barnabás Pőcze","email":"barnabas.pocze@ideasonboard.com"},"content":"Hi\n\n2025. 08. 15. 13:33 keltezéssel, Laurent Pinchart írta:\n> IPA interface structures store copies of data. For members that are not\n> PODs, such as vectors or strings, the constructors take const references\n> to a container class storing the data, and copies it internally. This is\n> inefficient if the caller constructs the container for the sole purpose\n> of passing it to the IPA interface structure constructor, as it forces a\n> copy of the data.\n> \n> Replace the const reference argument with a plain instance, and move it\n> in the constructor. This allows getting rid of the data copy if the\n> caller uses std::move().\n\nPlease see https://patchwork.libcamera.org/patch/24066/. Thoughts?\n\n\nRegards,\nBarnabás Pőcze\n\n\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> ---\n>   .../generators/libcamera_templates/definition_functions.tmpl  | 4 ++--\n>   1 file changed, 2 insertions(+), 2 deletions(-)\n> \n> diff --git a/utils/codegen/ipc/generators/libcamera_templates/definition_functions.tmpl b/utils/codegen/ipc/generators/libcamera_templates/definition_functions.tmpl\n> index 8b8509f3ded6..31c70e152d4f 100644\n> --- a/utils/codegen/ipc/generators/libcamera_templates/definition_functions.tmpl\n> +++ b/utils/codegen/ipc/generators/libcamera_templates/definition_functions.tmpl\n> @@ -36,12 +36,12 @@ public:\n>   \n>   \t{{struct.mojom_name}}(\n>   {%- for field in struct.fields -%}\n> -{{\"const \" if not field|is_pod}}{{field|name}} {{\"&\" if not field|is_pod}}_{{field.mojom_name}}{{\", \" if not loop.last}}\n> +{{field|name}} _{{field.mojom_name}}{{\", \" if not loop.last}}\n>   {%- endfor -%}\n>   )\n>   \t\t:\n>   {%- for field in struct.fields -%}\n> -{{\" \" if loop.first}}{{field.mojom_name}}(_{{field.mojom_name}}){{\", \" if not loop.last}}\n> +{{\" \" if loop.first}}{{field.mojom_name}}({{\"std::move(\" if not field|is_pod}}_{{field.mojom_name}}{{\")\" if not field|is_pod}}){{\", \" if not loop.last}}\n>   {%- endfor %}\n>   \t{\n>   \t}","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 90246BDCC1\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 15 Aug 2025 11:45:44 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4F95469257;\n\tFri, 15 Aug 2025 13:45:44 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5B15B61443\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 15 Aug 2025 13:45:42 +0200 (CEST)","from [192.168.33.21] (185.221.141.188.nat.pool.zt.hu\n\t[185.221.141.188])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 5D3AC605;\n\tFri, 15 Aug 2025 13:44:47 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"U1GUk/bF\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1755258287;\n\tbh=LE5uBaxVtNj39FlyWTFRM+M+IOYK/DJwR89Ps0/QJOg=;\n\th=Date:Subject:To:Cc:References:From:In-Reply-To:From;\n\tb=U1GUk/bF08heNMc6PDCX94aKnBWifSmw/1ntp37UJasgAUKlMT/vF03dbkAX9cWcH\n\t1VO6ohodAqtV2p2BuZGX5CHdDe5ZwbgdTaeivh9KHpAc3rUM6zxuTZ4dcgSOvbwpM4\n\t8gX1tsKkaQxi0UVIndujXbo3HwY+bKL4CMIQBh4k=","Message-ID":"<a452ea45-326b-4b0d-a23d-c9ab12b6758a@ideasonboard.com>","Date":"Fri, 15 Aug 2025 13:45:39 +0200","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH v2 6/8] utils: codegen: ipc: Optimize constructors of IPA\n\tinterface structures","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Cc":"=?utf-8?q?Daniel_R=C3=A1kos?= <daniel.rakos@rastergrid.com>","References":"<20250815113400.20623-1-laurent.pinchart@ideasonboard.com>\n\t<20250815113400.20623-7-laurent.pinchart@ideasonboard.com>","From":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","Content-Language":"en-US, hu-HU","In-Reply-To":"<20250815113400.20623-7-laurent.pinchart@ideasonboard.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"8bit","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":35460,"web_url":"https://patchwork.libcamera.org/comment/35460/","msgid":"<20250815230646.GP6201@pendragon.ideasonboard.com>","date":"2025-08-15T23:06:46","subject":"Re: [PATCH v2 6/8] utils: codegen: ipc: Optimize constructors of IPA\n\tinterface structures","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"On Fri, Aug 15, 2025 at 01:45:39PM +0200, Barnabás Pőcze wrote:\n> 2025. 08. 15. 13:33 keltezéssel, Laurent Pinchart írta:\n> > IPA interface structures store copies of data. For members that are not\n> > PODs, such as vectors or strings, the constructors take const references\n> > to a container class storing the data, and copies it internally. This is\n> > inefficient if the caller constructs the container for the sole purpose\n> > of passing it to the IPA interface structure constructor, as it forces a\n> > copy of the data.\n> > \n> > Replace the const reference argument with a plain instance, and move it\n> > in the constructor. This allows getting rid of the data copy if the\n> > caller uses std::move().\n> \n> Please see https://patchwork.libcamera.org/patch/24066/. Thoughts?\n\nSeems possibly better :-) I'll review that.\n\n> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > ---\n> >   .../generators/libcamera_templates/definition_functions.tmpl  | 4 ++--\n> >   1 file changed, 2 insertions(+), 2 deletions(-)\n> > \n> > diff --git a/utils/codegen/ipc/generators/libcamera_templates/definition_functions.tmpl b/utils/codegen/ipc/generators/libcamera_templates/definition_functions.tmpl\n> > index 8b8509f3ded6..31c70e152d4f 100644\n> > --- a/utils/codegen/ipc/generators/libcamera_templates/definition_functions.tmpl\n> > +++ b/utils/codegen/ipc/generators/libcamera_templates/definition_functions.tmpl\n> > @@ -36,12 +36,12 @@ public:\n> >   \n> >   \t{{struct.mojom_name}}(\n> >   {%- for field in struct.fields -%}\n> > -{{\"const \" if not field|is_pod}}{{field|name}} {{\"&\" if not field|is_pod}}_{{field.mojom_name}}{{\", \" if not loop.last}}\n> > +{{field|name}} _{{field.mojom_name}}{{\", \" if not loop.last}}\n> >   {%- endfor -%}\n> >   )\n> >   \t\t:\n> >   {%- for field in struct.fields -%}\n> > -{{\" \" if loop.first}}{{field.mojom_name}}(_{{field.mojom_name}}){{\", \" if not loop.last}}\n> > +{{\" \" if loop.first}}{{field.mojom_name}}({{\"std::move(\" if not field|is_pod}}_{{field.mojom_name}}{{\")\" if not field|is_pod}}){{\", \" if not loop.last}}\n> >   {%- endfor %}\n> >   \t{\n> >   \t}","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id D608EBDCC1\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 15 Aug 2025 23:07:08 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 9248D69257;\n\tSat, 16 Aug 2025 01:07:08 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id AB7A06924E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 16 Aug 2025 01:07:06 +0200 (CEST)","from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi\n\t[81.175.209.231])\n\tby perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id 56272594;\n\tSat, 16 Aug 2025 01:06:11 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"eN3i2PFY\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1755299171;\n\tbh=VfX/nx6tfXLqAgD9Iy4umyW9dA0fBP2GMcMSRGPmX4k=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=eN3i2PFYGfQIBh0qt6LGFkv5JUDhS4iXI0i+gAL9EydGNv6GFV6FTWWEg3wNqW4VD\n\t9VnjIB6PlaJKhKIBCn6s2gtbOrs428gMc8Qm+W6FJlwfJDaSOf8cxEYgtV3xcGPKFi\n\tnZmNQNVqDIZeRf4j9TQvdwcGIrP2sdQgljOHmYrE=","Date":"Sat, 16 Aug 2025 02:06:46 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org, Daniel =?utf-8?b?UsOha29z?=\n\t<daniel.rakos@rastergrid.com>","Subject":"Re: [PATCH v2 6/8] utils: codegen: ipc: Optimize constructors of IPA\n\tinterface structures","Message-ID":"<20250815230646.GP6201@pendragon.ideasonboard.com>","References":"<20250815113400.20623-1-laurent.pinchart@ideasonboard.com>\n\t<20250815113400.20623-7-laurent.pinchart@ideasonboard.com>\n\t<a452ea45-326b-4b0d-a23d-c9ab12b6758a@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<a452ea45-326b-4b0d-a23d-c9ab12b6758a@ideasonboard.com>","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]