From patchwork Tue Mar 19 12:36:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Milan Zamazal X-Patchwork-Id: 19773 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 9A6DFC3272 for ; Tue, 19 Mar 2024 12:37:43 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5307B6305E; Tue, 19 Mar 2024 13:37:43 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="D1zSebEG"; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id CD1FA62CA7 for ; Tue, 19 Mar 2024 13:37:41 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710851860; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=G0yImgZkvIz9scyIzliYmfyOITw5DAJIqXQDUmWHqfM=; b=D1zSebEG4hB6RBuLTp4OSwqZ3eNgI5Ik3QX8n0PC+tWrSJyGQQKoImR5QLpFvsfAcKBCIh YzgMGbKG0zTPD+vd+4NDtYXyP57YLEEi5eblciFBGGDvO10pWt3OgHsRYvXWsCsPmjXe/G r9BlA+JW0o0jihHlfZnq3Q64MkPg+yI= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-259-OPaaI1JnMY62OLo6WZCclQ-1; Tue, 19 Mar 2024 08:37:35 -0400 X-MC-Unique: OPaaI1JnMY62OLo6WZCclQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 065858007B8; Tue, 19 Mar 2024 12:37:35 +0000 (UTC) Received: from nuthatch.redhat.com (unknown [10.45.226.119]) by smtp.corp.redhat.com (Postfix) with ESMTP id EB49A1C060A6; Tue, 19 Mar 2024 12:37:32 +0000 (UTC) From: Milan Zamazal To: libcamera-devel@lists.libcamera.org Cc: Hans de Goede , Andrey Konovalov , Bryan O'Donoghue , Maxime Ripard , Milan Zamazal , Pavel Machek , Kieran Bingham , Stefan Klug Subject: [PATCH v6 16/18] libcamera: Add "Software ISP benchmarking" documentation Date: Tue, 19 Mar 2024 13:36:03 +0100 Message-ID: <20240319123622.675599-17-mzamazal@redhat.com> In-Reply-To: <20240319123622.675599-1-mzamazal@redhat.com> References: <20240319123622.675599-1-mzamazal@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" From: Hans de Goede Add a "Software ISP benchmarking" documentation section which describes the performance/power consumption measurements used during the Software ISP's development. Reviewed-by: Milan Zamazal Signed-off-by: Hans de Goede Reviewed-by: Stefan Klug Reviewed-by: Laurent Pinchart --- Documentation/index.rst | 1 + Documentation/meson.build | 1 + Documentation/software-isp-benchmarking.rst | 82 +++++++++++++++++++++ 3 files changed, 84 insertions(+) create mode 100644 Documentation/software-isp-benchmarking.rst diff --git a/Documentation/index.rst b/Documentation/index.rst index 63fac72d..5442ae75 100644 --- a/Documentation/index.rst +++ b/Documentation/index.rst @@ -24,3 +24,4 @@ Lens driver requirements Python Bindings Camera Sensor Model + SoftwareISP Benchmarking diff --git a/Documentation/meson.build b/Documentation/meson.build index 7a58fec8..3872e0a8 100644 --- a/Documentation/meson.build +++ b/Documentation/meson.build @@ -80,6 +80,7 @@ if sphinx.found() 'lens_driver_requirements.rst', 'python-bindings.rst', 'sensor_driver_requirements.rst', + 'software-isp-benchmarking.rst', '../README.rst', ] diff --git a/Documentation/software-isp-benchmarking.rst b/Documentation/software-isp-benchmarking.rst new file mode 100644 index 00000000..a9a5edbe --- /dev/null +++ b/Documentation/software-isp-benchmarking.rst @@ -0,0 +1,82 @@ +.. SPDX-License-Identifier: CC-BY-SA-4.0 + +.. _software-isp-benchmarking: + +Software ISP benchmarking +========================= + +The Software ISP is particularly sensitive to performance regressions +therefore it is a good idea to always benchmark the Software ISP +before and after making changes to it and ensure that there are +no performance regressions. + +DebayerCpu class builtin benchmark +---------------------------------- + +The DebayerCpu class has a builtin benchmark. This benchmark +measures the time spent on processing (collecting statistics +and debayering) only, it does not measure the time spent on +capturing or outputting the frames. + +The builtin benchmark always runs. So this can be used by simply +running "cam" or "qcam" with a pipeline using the Software ISP. + +When it runs it will skip measuring the first 30 frames to +allow the caches and the CPU temperature (turbo-ing) to warm-up +and then it measures 30 fps and shows the total and per frame +processing time using an info level log message: + +.. code-block:: text + + INFO Debayer debayer_cpu.cpp:907 Processed 30 frames in 244317us, 8143 us/frame + +To get stable measurements it is advised to disable any other processes which +may cause significant CPU usage (e.g. disable wifi, bluetooth and browsers). +When possible it is also advisable to disable CPU turbo-ing and +frequency-scaling. + +For example when benchmarking on a Lenovo ThinkPad X1 Yoga Gen 8, with +the charger plugged in, the CPU can be fixed to run at 2 GHz using: + +.. code-block:: shell + + sudo x86_energy_perf_policy --turbo-enable 0 + sudo cpupower frequency-set -d 2GHz -u 2GHz + +with these settings the builtin bench reports a processing time of ~7.8ms/frame +on this laptop for FHD SGRBG10 (unpacked) bayer data. + +Measuring power consumption +--------------------------- + +Since the Software ISP is often used on mobile devices it is also +important to measure power consumption and ensure that that does +not regress. + +For example to measure power consumption on a Lenovo ThinkPad X1 Yoga Gen 8 +it needs to be running on battery and it should be configured with its +platform-profile (/sys/firmware/acpi/platform_profile) set to balanced and +with its default turbo and frequency-scaling behavior to match real world usage. + +Then start qcam to capture a FHD picture at 30 fps and position the qcam window +so that it is fully visible. After this run the following command to monitor +the power consumption: + +.. code-block:: shell + + watch -n 10 cat /sys/class/power_supply/BAT0/power_now /sys/class/hwmon/hwmon6/fan?_input + +Note this not only measures the power consumption in µW it also monitors +the speed of this laptop's 2 fans. This is important because depending on +the ambient temperature the 2 fans may spin up while testing and this +will cause an additional power consumption of approx. 0.5 W messing up +the measurement. + +After starting qcam + the watch command let the laptop sit without using +it for 2 minutes for the readings to stabilize. Then check that the fans +have not turned on and manually take a couple of consecutive power readings +and average these. + +On the example Lenovo ThinkPad X1 Yoga Gen 8 laptop this results in +a measured power consumption of approx. 13 W while running qcam versus +approx. 4-5 W while setting idle with its OLED panel on.