From unknown Sun Jun 15 08:27:09 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#38322 <38322@debbugs.gnu.org> To: bug#38322 <38322@debbugs.gnu.org> Subject: Status: GCC optimize levels makes huge impact on performance Reply-To: bug#38322 <38322@debbugs.gnu.org> Date: Sun, 15 Jun 2025 15:27:09 +0000 retitle 38322 GCC optimize levels makes huge impact on performance reassign 38322 grep submitter 38322 Bal=C3=A1zs Vinarz severity 38322 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Fri Nov 22 12:04:54 2019 Received: (at submit) by debbugs.gnu.org; 22 Nov 2019 17:04:54 +0000 Received: from localhost ([127.0.0.1]:55422 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iYCMV-0006XW-Tt for submit@debbugs.gnu.org; Fri, 22 Nov 2019 12:04:54 -0500 Received: from lists.gnu.org ([209.51.188.17]:38404) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iYBNL-00051v-Ig for submit@debbugs.gnu.org; Fri, 22 Nov 2019 11:01:41 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46989) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iYBNJ-00044L-UO for bug-grep@gnu.org; Fri, 22 Nov 2019 11:01:38 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: * X-Spam-Status: No, score=1.1 required=5.0 tests=BAYES_50, FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM autolearn=disabled version=3.3.2 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iYBNI-0000gE-Fq for bug-grep@gnu.org; Fri, 22 Nov 2019 11:01:37 -0500 Received: from mail-il1-x12f.google.com ([2607:f8b0:4864:20::12f]:40917) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iYBNI-0000ex-BY for bug-grep@gnu.org; Fri, 22 Nov 2019 11:01:36 -0500 Received: by mail-il1-x12f.google.com with SMTP id v17so3536381ilg.7 for ; Fri, 22 Nov 2019 08:01:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=BmuuUO3S5GxxlVodOyqZZtJp9h6ttSXFqOxvWKSuLMQ=; b=EZC8UY9rihy9j7z0lfCIjNaBiPjRJmQMOTAWEVRJFe3MIy7qxEid5acZoKQuuBwSEy pkuClm3huSZPK6Szq0PAnt7OIC9iGaYH5QfwBpgjk7EcnvoOJWMRFNpD1xLr+ynPQ2g5 gG/ezqQk8UP1o1c8wsXc8J6peVfljPSZe6o+ov2av1vpWHPkOnKZknkz8DuKJUAXrBLX V09A40pDTOW4ZRO0bFabq5mN8WjDUSW2lqjoUqFv/UXmsYDULPTOpC2es49JrAWkcy/5 aZxokRcIX5tXpR9nDQsjF3CfOqiuJhaHjhFTC+BZUhpdDTB9xvKIsVBfWhv25Z8Bz6Hj CmzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=BmuuUO3S5GxxlVodOyqZZtJp9h6ttSXFqOxvWKSuLMQ=; b=mzdIXYNNSsCwLBs0XRnNehRF9pIj6UFx8zzZMLQlwZOXvvAesxfxp+aJypG5k5QMFv 0U4o5JsHZ9WnMnmmWOnmtVQ/c9Li3AHlGbtEVoHA2gRrfB8yrfra16pqGDE8uDF1QvEO BEOs4z4wHKD7fMViLjQKs3MoLkTUE9OfyajesRwrToOhVoSlKw3M8nF7Jx5ElAtt4iMI Y+EYXDEucDbdyZ2DlROnibBSyTZcco4ygYGU5U9tzn6K/boHnRmazTecvXxkYoigHR7p kN5Ih45x3Horx1rZMsVIifjPR5TV+zk/TdxJLeRzOrrxGuVOZNoH16QphgrEKtv1ope9 0mFA== X-Gm-Message-State: APjAAAVznKbNd4ugLpXUD04WYgEAPlzDaSZ7MzzE6tw+dR52MImuCVOV KYAPvibc0FGVzYBDePJ5DURbAdGF0RxizOf98kZY8mI= X-Google-Smtp-Source: APXvYqz0ddqcyequ3VBZrTdp5Pf1AZzoUMcCFYKRo4OnkoPrVYx+KxEiMSS2r36rzFeUODSVFAxrstFDKQsVjzv4Fc0= X-Received: by 2002:a92:c10f:: with SMTP id p15mr16845017ile.119.1574438492532; Fri, 22 Nov 2019 08:01:32 -0800 (PST) MIME-Version: 1.0 From: =?UTF-8?Q?Bal=C3=A1zs_Vinarz?= Date: Fri, 22 Nov 2019 18:00:29 +0200 Message-ID: Subject: GCC optimize levels makes huge impact on performance To: bug-grep@gnu.org Content-Type: text/plain; charset="UTF-8" X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::12f X-Spam-Score: 0.9 (/) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Fri, 22 Nov 2019 12:04:50 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.1 (--) Hello there! Today I was working on two bigger, plain text, csv-like database files (file1: ~175k lines and 15MB, file2: ~ 168k lines and 14MB). I just searched for lines, using grep -f $file2 $file1. I was so surprised when I realized the search was running for minutes already without a single line at the standard output. I decided to have a try with custom compiled binaries, because in my mind the size optimized binaries are the fastest. In the end grep (3.1) was running for: - 4m50s if I used the one was coming from Ubuntu, - 4m29s in case of custom recompiled with GCC7.4 and CFLAGS="O2" and - 3m17s in case of custom recompiled with GCC7.4 and CFLAGS="Os". I repeated the runs multiple times, I would say it's accurate. The files were located on tmpfs. Binary sizes are: 215K for Ubuntu, 184K for O2 and 150K for Os. CPU: Intel I5-8350U OS: Ubuntu 18.04.3 LTS Would you mind change the default optimize level on the make configuration? Did somebody ever measured the benefits using different GCC optimalization levels? I know that this is a special use case, but the improvement is huge. I'm looking forward for your feedback. Best regards From debbugs-submit-bounces@debbugs.gnu.org Fri Nov 22 20:53:05 2019 Received: (at 38322) by debbugs.gnu.org; 23 Nov 2019 01:53:05 +0000 Received: from localhost ([127.0.0.1]:55739 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iYKbh-0004ey-3y for submit@debbugs.gnu.org; Fri, 22 Nov 2019 20:53:05 -0500 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:41966) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iYKbd-0004eP-2a for 38322@debbugs.gnu.org; Fri, 22 Nov 2019 20:53:03 -0500 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 431B016027C; Fri, 22 Nov 2019 17:52:54 -0800 (PST) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id 7Sh17jm83X6Y; Fri, 22 Nov 2019 17:52:53 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 861C616017F; Fri, 22 Nov 2019 17:52:53 -0800 (PST) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id kEpo_Et32CFm; Fri, 22 Nov 2019 17:52:53 -0800 (PST) Received: from Penguin.CS.UCLA.EDU (Penguin.CS.UCLA.EDU [131.179.64.200]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 6D57A16027C; Fri, 22 Nov 2019 17:52:53 -0800 (PST) Subject: Re: bug#38322: GCC optimize levels makes huge impact on performance To: =?UTF-8?Q?Bal=c3=a1zs_Vinarz?= References: From: Paul Eggert Organization: UCLA Computer Science Department Message-ID: Date: Fri, 22 Nov 2019 17:52:53 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 38322 Cc: 38322@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) On 11/22/19 8:00 AM, Bal=C3=A1zs Vinarz wrote: > Would you mind change the default optimize level on the make > configuration? Did somebody ever measured the benefits using different > GCC optimalization levels? Lots of measurements have been done. They often disagree. Even if grep=20 changed the default optimization level (which I'm not sure is a good=20 idea), distros like Ubuntu often override the default and if so, changes=20 to the default wouldn't help you. > I know that this is a special use case, but the improvement is huge. > I'm looking forward for your feedback. It sounds like you're using grep to do set subtraction; is this a=20 common-enough usage to be worth special-casing grep for? (One could=20 argue that it's easy enough to do set subtraction with Awk or Python or=20 whatever....) If we do want to tune grep for set-like operations, that=20 suggests doing some surgery to its internals rather than merely fiddling=20 with -O flags. From debbugs-submit-bounces@debbugs.gnu.org Thu Jan 02 05:08:36 2020 Received: (at 38322-done) by debbugs.gnu.org; 2 Jan 2020 10:08:36 +0000 Received: from localhost ([127.0.0.1]:38260 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1imxPA-0004Qw-FI for submit@debbugs.gnu.org; Thu, 02 Jan 2020 05:08:36 -0500 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:50796) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1imxP8-0004Qg-Qr for 38322-done@debbugs.gnu.org; Thu, 02 Jan 2020 05:08:35 -0500 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 9F4BE160054; Thu, 2 Jan 2020 02:08:28 -0800 (PST) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id BtRsLaOI0XOC; Thu, 2 Jan 2020 02:08:28 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id F09B8160058; Thu, 2 Jan 2020 02:08:27 -0800 (PST) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 73q1MyH7BXME; Thu, 2 Jan 2020 02:08:27 -0800 (PST) Received: from [192.168.1.9] (cpe-23-242-74-103.socal.res.rr.com [23.242.74.103]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id CA177160054; Thu, 2 Jan 2020 02:08:27 -0800 (PST) Subject: Re: bug#38322: GCC optimize levels makes huge impact on performance From: Paul Eggert To: =?UTF-8?Q?Bal=c3=a1zs_Vinarz?= References: Organization: UCLA Computer Science Department Message-ID: <418a248b-adfc-1800-3a8e-61afc82b3145@cs.ucla.edu> Date: Thu, 2 Jan 2020 02:08:27 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 38322-done Cc: 38322-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) On 11/22/19 5:52 PM, Paul Eggert wrote: > If we do want to tune grep for set-like operations, that suggests doing some > surgery to its internals rather than merely fiddling with -O flags. Since I last wrote, some of that surgery has been done by another grep contributor, and a simple 'grep -f file1 file2' benchmark that I just now tried sped up from 47 seconds (for grep 3.1) to 2.3 seconds (for the next version of grep). So this algorithmic change should far outweigh any GCC optimization level change. Anyway, the topic seems to have died down so I'm closing the bug report. From debbugs-submit-bounces@debbugs.gnu.org Thu Jan 02 10:48:42 2020 Received: (at 38322) by debbugs.gnu.org; 2 Jan 2020 15:48:42 +0000 Received: from localhost ([127.0.0.1]:39945 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1in2iI-0000b3-3y for submit@debbugs.gnu.org; Thu, 02 Jan 2020 10:48:42 -0500 Received: from mail-il1-f172.google.com ([209.85.166.172]:34084) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1in2iG-0000an-FD for 38322@debbugs.gnu.org; Thu, 02 Jan 2020 10:48:41 -0500 Received: by mail-il1-f172.google.com with SMTP id s15so34421293iln.1 for <38322@debbugs.gnu.org>; Thu, 02 Jan 2020 07:48:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=zl+OJ7FUNVbd2AbhNZ8q++rEZxYsB1D3pCvAoztt8XI=; b=axuWu37hSlKaJz7BCxH20ZA/p5907U14f8qjhgPSL5H22TVfyFiIhF7wRB2XbleWO2 Cbo7EUDfEvpUG0s65vQXynxW11sMijpBPzGaYTH+hJBB64yxoH/gaRUHYRIaHP9sukMq U0lelKiiSrqOH931ytwGVRyv/1qodALm952HAX/1pCORwlZL4AnmfLIr6HUdf+D023VX x1CAsjNUzcEdwkYFo0gv2YIb12y9Hjw2QytO21P3OHwkrV75q08UPaL9whmuxWjl9cC0 PHqW6lxIs+DOxzhjVQ+r3QtGnoU5n8BDLwtGlEbMQ2HKfhmyBOJ7y/AZ0qHu/NTVteIc 6YfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=zl+OJ7FUNVbd2AbhNZ8q++rEZxYsB1D3pCvAoztt8XI=; b=P4nWZ0F3XB9XqBzbBZFAng7JTiZ/1Rc0BwyUHO0l6v2ypUjTpaMI2OETXGdXL0aDXH mUD9GFXkIRIEd0smSvmTBlOxJi/3+Y3mKbvxrbIKJ0WM4DrDe+IVA1T7wok3/cZiatrM bvLKr+7NvRva0Fi7GV7o6vlywntWDd2sDYvIuWfMyzu3eVeGXtJl2LWyv5CnuAQ6v4Dw McKjdh3/8dgQ3cETKRKHs7E5jVnwD4jdHJiXJbi1fRLfLB1Rw8jBn1YkjpBRUcUpW0Fi +TM6Dz2kVZ3mRC9Akrx0rk181x88PZnwaeUAmmuigLQeVextytdSvBgHHukuw51guoaX 4akQ== X-Gm-Message-State: APjAAAUbUjmmqFE/vSwqXSefgw/rb7IzpqCxW9qqCeqQksQFoW3sZW4V Xq8KWXIi39gDbv+7M9X7lPWFJEUb+uPFgC9Hhn6broql+A== X-Google-Smtp-Source: APXvYqwTtV2ge3tWNP6mO4I+SqJv/p4ip2+NFFZtKFCY0+f7r1b50oyIRMzboICj6n88GuqRCVEs/pjSQFhRSSW+xVI= X-Received: by 2002:a92:9184:: with SMTP id e4mr73587423ill.70.1577980114499; Thu, 02 Jan 2020 07:48:34 -0800 (PST) MIME-Version: 1.0 From: =?UTF-8?Q?Bal=C3=A1zs_Vinarz?= Date: Thu, 2 Jan 2020 16:48:18 +0100 Message-ID: Subject: To: 38322@debbugs.gnu.org Content-Type: multipart/alternative; boundary="0000000000002ffd16059b2a2007" X-Spam-Score: 2.3 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Thank you Paul, I wish you a happy new year! Best regards Thank you Paul, I wish you a happy new year! Content analysis details: (2.3 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (vinibali1[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit (vinibali1[at]gmail.com) 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 HTML_MESSAGE BODY: HTML included in message -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.166.172 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.166.172 listed in wl.mailspike.net] 2.0 BLANK_SUBJECT Subject is present but empty X-Debbugs-Envelope-To: 38322 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.3 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Thank you Paul, I wish you a happy new year! Best regards Thank you Paul, I wish you a happy new year! Content analysis details: (1.3 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.166.172 listed in wl.mailspike.net] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.166.172 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (vinibali1[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit (vinibali1[at]gmail.com) 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 HTML_MESSAGE BODY: HTML included in message -1.0 MAILING_LIST_MULTI Multiple indicators imply a widely-seen list manager 2.0 BLANK_SUBJECT Subject is present but empty --0000000000002ffd16059b2a2007 Content-Type: text/plain; charset="UTF-8" Thank you Paul, I wish you a happy new year! Best regards --0000000000002ffd16059b2a2007 Content-Type: text/html; charset="UTF-8"
Thank you Paul,
I wish you a happy new year!
Best regards
--0000000000002ffd16059b2a2007-- From unknown Sun Jun 15 08:27:09 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Fri, 31 Jan 2020 12:24:04 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator