From patchwork Thu Mar 18 23:16:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Lepiller X-Patchwork-Id: 27966 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 973AD27BC57; Thu, 18 Mar 2021 23:17:25 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS, T_DKIM_INVALID,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id F1DA527BC55 for ; Thu, 18 Mar 2021 23:17:24 +0000 (GMT) Received: from localhost ([::1]:42674 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lN1tM-0002Rt-7D for patchwork@mira.cbaines.net; Thu, 18 Mar 2021 19:17:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52764) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lN1t0-0002RY-4S for guix-patches@gnu.org; Thu, 18 Mar 2021 19:17:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:36765) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lN1sz-00033H-TU for guix-patches@gnu.org; Thu, 18 Mar 2021 19:17:01 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lN1sz-0000L6-PK for guix-patches@gnu.org; Thu, 18 Mar 2021 19:17:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#47251] [core-updates] [patch] gnu: python: Enable optimizations. Resent-From: Julien Lepiller Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 18 Mar 2021 23:17:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 47251 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 47251@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.16161094091282 (code B ref -1); Thu, 18 Mar 2021 23:17:01 +0000 Received: (at submit) by debbugs.gnu.org; 18 Mar 2021 23:16:49 +0000 Received: from localhost ([127.0.0.1]:48311 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lN1sn-0000Kb-BX for submit@debbugs.gnu.org; Thu, 18 Mar 2021 19:16:49 -0400 Received: from lists.gnu.org ([209.51.188.17]:44286) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lN1sl-0000KT-Ah for submit@debbugs.gnu.org; Thu, 18 Mar 2021 19:16:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52754) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lN1sk-0002Pf-AQ for guix-patches@gnu.org; Thu, 18 Mar 2021 19:16:47 -0400 Received: from lepiller.eu ([2a00:5884:8208::1]:34472) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lN1sf-0002u7-TB for guix-patches@gnu.org; Thu, 18 Mar 2021 19:16:45 -0400 Received: from lepiller.eu (localhost [127.0.0.1]) by lepiller.eu (OpenSMTPD) with ESMTP id 92d4e09d for ; Thu, 18 Mar 2021 23:16:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=lepiller.eu; h=date:from :to:subject:message-id:mime-version:content-type; s=dkim; bh=vZN HBooyBAu/d1FOHpR/wW29LjCCdGxPYoArIV+X0QQ=; b=lf2L2fKw0LL5z3RBDsH TZj1PIXU9FMbuuVhiDZB5VlrAN0M7/SUGwTT1c/wtn255qtJ0YbJuL+6FqnZ9wYP Mp70sA4/bDZt7kp/WBu3nHWTdaOVWsSsBMOmX43xlGqUi4UR0noaIVfJS4X0CpWA gQ0JDBoMCZyXuC+85z+3mCq3ygKwZlIwJOqTE6k+1Fx1pNvmDYYAeqPxmSyizP2A bJpSu7GZr5RKaN4hTgdpYTOUbAYQwEp9FjpfXEDqp5l8JvNkK2a51lDUd+4QLlM2 wh84mN/lnR46vglLTbkbSBnToSIPzvDXLqdlP7t6s1ocXwgPe06MxZnJFSNDsYPT ifA== Received: by lepiller.eu (OpenSMTPD) with ESMTPSA id de649271 (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256:NO) for ; Thu, 18 Mar 2021 23:16:36 +0000 (UTC) Date: Fri, 19 Mar 2021 00:16:22 +0100 From: Julien Lepiller Message-ID: <20210319001622.1c19ad41@tachikoma.lepiller.eu> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:5884:8208::1; envelope-from=julien@lepiller.eu; helo=lepiller.eu X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches Hi Guix! This is the second patch I created in my exploration of our Python package. Here, I noticed that our Python was very slow compared to other distros and I tried to find which options they used. I found some hints from Fedora. In this patch, I enable a few options and add a C/LD flag to make python run faster. I also attached a report of timing running the benchmark from pyperformance on my Fedora machine. For comparison, I have also added the results for Fedora's python3, which is somewhere in between. I noticed that this increases the size of the python package by 20MB, which is due entirely to --with-lto option, which also accounts for half of the speedup. Overall, this python is almost twice as fast on some benchmarks, and always faster on all of them. It's about 1.5 times faster on average. Strangely, the python package from Alpine is twice as small as this package, and they use the --with-lto option. I wonder how they achieve that. Note that I modified python-2, as its flags are inherited by python-3 (and also the bootstrap python from commencement.scm). From c72e34aa0eb0db589557e047c5db0128273d5d12 Mon Sep 17 00:00:00 2001 From: Julien Lepiller Date: Thu, 18 Mar 2021 23:41:40 +0100 Subject: [PATCH 2/2] gnu: python: Enable optimizations. As a result, python execution time of scripts is decreased by 6 to 40%. gnu/packages/python (python-2.7)[arguments]: Add configure and make flags to optimize the resulting python. --- gnu/packages/python.scm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/gnu/packages/python.scm b/gnu/packages/python.scm index da9859b11a..8de0ca343c 100644 --- a/gnu/packages/python.scm +++ b/gnu/packages/python.scm @@ -183,7 +183,10 @@ "--with-system-expat" ;for XML support "--with-system-ffi" ;build ctypes "--with-ensurepip=install" ;install pip and setuptools + "--with-computed-gotos" ;main interpreter loop optimization + "--with-lto" ;increase size by 20MB, but 15% speedup "--enable-unicode=ucs4" + "--enable-optimizations" ;; Prevent the installed _sysconfigdata.py from retaining a reference ;; to coreutils. @@ -197,8 +200,10 @@ "ac_cv_file__dev_ptmx=no" "ac_cv_file__dev_ptc=no") '()) + "CFLAGS=-fno-semantic-interposition" (string-append "LDFLAGS=-Wl,-rpath=" - (assoc-ref %outputs "out") "/lib")) + (assoc-ref %outputs "out") "/lib" + " -fno-semantic-interposition")) ;; With no -j argument tests use all available cpus, so provide one. #:make-flags (list (string-append -- 2.30.0