From unknown Sun Jun 22 07:51:58 2025 X-Loop: help-debbugs@gnu.org Subject: bug#6734: "inline" overused in .c files? Resent-From: Paul Eggert Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-coreutils@gnu.org Resent-Date: Mon, 26 Jul 2010 18:54:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 6734 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: 6734@debbugs.gnu.org Cc: Bug-gnulib , Chen Guo X-Debbugs-Original-To: Bug-coreutils Received: via spool by submit@debbugs.gnu.org id=B.128017042321914 (code B ref -1); Mon, 26 Jul 2010 18:54:01 +0000 Received: (at submit) by debbugs.gnu.org; 26 Jul 2010 18:53:43 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OdSo1-0005hP-Gk for submit@debbugs.gnu.org; Mon, 26 Jul 2010 14:53:41 -0400 Received: from mx10.gnu.org ([199.232.76.166]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OdSny-0005hK-VI for submit@debbugs.gnu.org; Mon, 26 Jul 2010 14:53:39 -0400 Received: from lists.gnu.org ([199.232.76.165]:39686) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1OdSo4-0002y0-MZ for submit@debbugs.gnu.org; Mon, 26 Jul 2010 14:53:44 -0400 Received: from [140.186.70.92] (port=36121 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OdSo3-0006ia-E5 for bug-coreutils@gnu.org; Mon, 26 Jul 2010 14:53:44 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_RP_MATCHES_RCVD autolearn=unavailable version=3.3.1 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OdSo2-00020H-9i for bug-coreutils@gnu.org; Mon, 26 Jul 2010 14:53:43 -0400 Received: from kiwi.cs.ucla.edu ([131.179.128.19]:42265) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OdSnz-0001z1-Rc; Mon, 26 Jul 2010 14:53:40 -0400 Received: from [131.179.64.200] (Penguin.CS.UCLA.EDU [131.179.64.200]) by kiwi.cs.ucla.edu (8.13.8+Sun/8.13.8/UCLACS-6.0) with ESMTP id o6QIraRv006025; Mon, 26 Jul 2010 11:53:36 -0700 (PDT) Message-ID: <4C4DD9B0.4040905@cs.ucla.edu> Date: Mon, 26 Jul 2010 11:53:36 -0700 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.10) Gecko/20100527 Thunderbird/3.0.5 MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-detected-operating-system: by eggs.gnu.org: Solaris 10 (beta) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Spam-Score: -5.1 (-----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -5.1 (-----) I noticed thirteen "inline"s in coreutils/src/sort.c. Just for fun, I removed them all. In ten cases, removing "inline" made no difference to the generated machine code on my platform (RHEL 5, x86-64, GCC 4.1.2, compiled with the typical gcc -O2). In the three sort.c functions that were exceptions (queue_insert, write_unique, check_insert), removing "inline" made the overall code a tad shorter with no measurable change to CPU performance. Is there a reason those "inline"s are in there? If not, I'm inclined to remove them. I can see a use for "static inline" in .h files, as this asks the compiler not to warn about unused functions, but as far as I know, it's typically not necessary to use "inline" in .c files these days, as the compiler is typically smart enough. I've checked this only for coreutils/src/sort.c but perhaps the same argument applies to other source files in coreutils or other GNU apps, so I'll CC: this to bug-gnulib for more-general comment. From unknown Sun Jun 22 07:51:58 2025 X-Loop: help-debbugs@gnu.org Subject: bug#6734: "inline" overused in .c files? Resent-From: Paolo Bonzini Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-coreutils@gnu.org Resent-Date: Mon, 26 Jul 2010 19:02:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 6734 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: Paul Eggert Cc: Bug-gnulib , Bug-coreutils , Chen Guo Received: via spool by submit@debbugs.gnu.org id=B.128017086422151 (code B ref -1); Mon, 26 Jul 2010 19:02:02 +0000 Received: (at submit) by debbugs.gnu.org; 26 Jul 2010 19:01:04 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OdSv2-0005kx-V2 for submit@debbugs.gnu.org; Mon, 26 Jul 2010 15:01:04 -0400 Received: from mail.gnu.org ([199.232.76.166] helo=mx10.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OdSv0-0005kq-F0 for submit@debbugs.gnu.org; Mon, 26 Jul 2010 15:00:55 -0400 Received: from lists.gnu.org ([199.232.76.165]:41241) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1OdSv6-00032x-6Q for submit@debbugs.gnu.org; Mon, 26 Jul 2010 15:01:00 -0400 Received: from [140.186.70.92] (port=55970 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OdSv4-0008IH-MC for bug-coreutils@gnu.org; Mon, 26 Jul 2010 15:00:59 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OdSv3-0002jI-Fa for bug-coreutils@gnu.org; Mon, 26 Jul 2010 15:00:58 -0400 Received: from mail-vw0-f41.google.com ([209.85.212.41]:56122) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OdSv3-0002jA-AT; Mon, 26 Jul 2010 15:00:57 -0400 Received: by vws16 with SMTP id 16so2999744vws.0 for ; Mon, 26 Jul 2010 12:00:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:sender:message-id:date:from :user-agent:mime-version:to:cc:subject:references:in-reply-to :content-type:content-transfer-encoding; bh=1pt76IwFlGvxHsscs8uoKc2StHfcfpJQPkgPqVvp+lk=; b=FGJiR0e++cUGjqned76WhnwajtGSk4s4LoD5DaM7UXqyy1i11RWfmZsl0if0wCKFV5 wqk3MvR7XQP/WPPBiFaDJNqJCZuZrfLGxogtbQb59Tw8TN0HB8cZOa5G7vAiSnXTczUS Fr24YW5wZTqYDpLhXHJ3Kwz1jN3Zxt7S2TWbM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; b=v10uc80+87kJpzceaAW9mjsen71J4oAzxySWgZMxev5U0ZITRoafy+oUGzEX/uQFDw /yhuAgqwnxJpe9qWFCpXZmZYzINtNuETZTHWanGq2vLqX1ZUvzmvfO4jJQ87F+TrQ2Hb eVkMT6GchcfSrpS6fNsbaupK0Q3fb88Ye1KQM= Received: by 10.220.125.22 with SMTP id w22mr4460099vcr.18.1280170856187; Mon, 26 Jul 2010 12:00:56 -0700 (PDT) Received: from yakj.usersys.redhat.com (nat-pool-brq-t.redhat.com [209.132.186.34]) by mx.google.com with ESMTPS id d19sm940949vcs.1.2010.07.26.12.00.53 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 26 Jul 2010 12:00:55 -0700 (PDT) Message-ID: <4C4DDB63.8000209@gnu.org> Date: Mon, 26 Jul 2010 21:00:51 +0200 From: Paolo Bonzini User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.10) Gecko/20100621 Fedora/3.0.5-1.fc13 Lightning/1.0b2pre Thunderbird/3.0.5 MIME-Version: 1.0 References: <4C4DD9B0.4040905@cs.ucla.edu> In-Reply-To: <4C4DD9B0.4040905@cs.ucla.edu> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Spam-Score: -4.3 (----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -4.8 (----) On 07/26/2010 08:53 PM, Paul Eggert wrote: > I noticed thirteen "inline"s in coreutils/src/sort.c. Just for fun, I > removed them all. In ten cases, removing "inline" made no difference to > the generated machine code on my platform (RHEL 5, x86-64, GCC 4.1.2, > compiled with the typical gcc -O2). In the three sort.c functions > that were exceptions (queue_insert, write_unique, check_insert), > removing "inline" made the overall code a tad shorter with no > measurable change to CPU performance. > > Is there a reason those "inline"s are in there? If not, I'm inclined > to remove them. I can see a use for "static inline" in .h files, as > this asks the compiler not to warn about unused functions, but as far > as I know, it's typically not necessary to use "inline" in .c files > these days, as the compiler is typically smart enough. Only at -O3, except for special cases like functions called once. However, in general I agree that inline is not beneficial except for bottlenecks that can be identified by profiling. Paolo From unknown Sun Jun 22 07:51:58 2025 X-Loop: help-debbugs@gnu.org Subject: bug#6734: "inline" overused in .c files? Resent-From: =?UTF-8?Q?P=C3=A1draig?= Brady Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-coreutils@gnu.org Resent-Date: Mon, 26 Jul 2010 22:48:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 6734 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: Paul Eggert Cc: Bug-gnulib , Chen Guo , 6734@debbugs.gnu.org Received: via spool by 6734-submit@debbugs.gnu.org id=B6734.128018442628472 (code B ref 6734); Mon, 26 Jul 2010 22:48:02 +0000 Received: (at 6734) by debbugs.gnu.org; 26 Jul 2010 22:47:06 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OdWRt-0007PB-Kh for submit@debbugs.gnu.org; Mon, 26 Jul 2010 18:47:05 -0400 Received: from mail1.slb.deg.dub.stisp.net ([84.203.253.98]) by debbugs.gnu.org with smtp (Exim 4.69) (envelope-from ) id 1OdWRq-0007Oo-Pp for 6734@debbugs.gnu.org; Mon, 26 Jul 2010 18:47:03 -0400 Received: (qmail 51952 invoked from network); 26 Jul 2010 22:47:08 -0000 Received: from unknown (HELO ?192.168.2.25?) (84.203.137.218) by mail1.slb.deg.dub.stisp.net with SMTP; 26 Jul 2010 22:47:08 -0000 Message-ID: <4C4E106A.7090003@draigBrady.com> Date: Mon, 26 Jul 2010 23:47:06 +0100 From: =?UTF-8?Q?P=C3=A1draig?= Brady User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.8) Gecko/20100227 Thunderbird/3.0.3 MIME-Version: 1.0 References: <4C4DD9B0.4040905@cs.ucla.edu> In-Reply-To: <4C4DD9B0.4040905@cs.ucla.edu> X-Enigmail-Version: 1.0.1 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.7 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.7 (--) On 26/07/10 19:53, Paul Eggert wrote: > I noticed thirteen "inline"s in coreutils/src/sort.c. Just for fun, I > removed them all. In ten cases, removing "inline" made no difference to > the generated machine code on my platform (RHEL 5, x86-64, GCC 4.1.2, > compiled with the typical gcc -O2). In the three sort.c functions > that were exceptions (queue_insert, write_unique, check_insert), > removing "inline" made the overall code a tad shorter with no > measurable change to CPU performance. > > Is there a reason those "inline"s are in there? If not, I'm inclined > to remove them. I can see a use for "static inline" in .h files, as > this asks the compiler not to warn about unused functions, but as far > as I know, it's typically not necessary to use "inline" in .c files > these days, as the compiler is typically smart enough. > > I've checked this only for coreutils/src/sort.c but perhaps the same > argument applies to other source files in coreutils or other GNU apps, so > I'll CC: this to bug-gnulib for more-general comment. I never use inline in my own user space apps. I do sometimes in lower level code when I want detailed control of the stack. So please remove them. cheers, Pádraig. From unknown Sun Jun 22 07:51:58 2025 X-Loop: help-debbugs@gnu.org Subject: bug#6734: "inline" overused in .c files? Resent-From: Bruno Haible Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-coreutils@gnu.org Resent-Date: Mon, 26 Jul 2010 23:23:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 6734 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: bug-gnulib@gnu.org Cc: Paul Eggert , Bug-coreutils , Chen Guo Received: via spool by submit@debbugs.gnu.org id=B.128018654129338 (code B ref -1); Mon, 26 Jul 2010 23:23:01 +0000 Received: (at submit) by debbugs.gnu.org; 26 Jul 2010 23:22:21 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OdWzz-0007d9-Uc for submit@debbugs.gnu.org; Mon, 26 Jul 2010 19:22:21 -0400 Received: from mx10.gnu.org ([199.232.76.166]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OdWzx-0007d4-LI for submit@debbugs.gnu.org; Mon, 26 Jul 2010 19:22:18 -0400 Received: from lists.gnu.org ([199.232.76.165]:37537) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1OdX04-0007oZ-1l for submit@debbugs.gnu.org; Mon, 26 Jul 2010 19:22:24 -0400 Received: from [140.186.70.92] (port=37124 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OdX02-00081p-9z for bug-coreutils@gnu.org; Mon, 26 Jul 2010 19:22:23 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OdX00-00011g-NS for bug-coreutils@gnu.org; Mon, 26 Jul 2010 19:22:22 -0400 Received: from mo-p00-ob.rzone.de ([81.169.146.160]:31535) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OdWzx-00010p-1R; Mon, 26 Jul 2010 19:22:17 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; t=1280186534; l=1241; s=domk; d=haible.de; h=Content-Transfer-Encoding:Content-Type:MIME-Version:In-Reply-To: References:Cc:Date:Subject:To:From:X-RZG-CLASS-ID:X-RZG-AUTH; bh=Rbg+F5FuNJ98CpRNYvV767kCkmw=; b=gE0kspQ6+WHXuIbBFCh3PQkEQSNUh/HzXB7Jmf9/bFiAF5OV6VOMMGPA9Js1FJLbidl 4q9c6SiuO7LE7qvH0/YIm8wNeSMU51UAVEsDbOI4fusC1vJvM+synNE2Y9jBieHJrn6jE B4P9ICudIf3qzypy1NQFZAEcMBe8nWYvve8= X-RZG-AUTH: :Ln4Re0+Ic/6oZXR1YgKryK8brksyK8dozXDwHXjf9hj/zDNRbvU449Jbdg== X-RZG-CLASS-ID: mo00 Received: from linuix.haible.de (dslb-088-068-073-150.pools.arcor-ip.net [88.68.73.150]) by post.strato.de (fruni mo29) (RZmta 23.4) with ESMTP id u03c64m6QM0VT7 ; Tue, 27 Jul 2010 01:22:09 +0200 (MEST) From: Bruno Haible Date: Tue, 27 Jul 2010 01:22:07 +0200 User-Agent: KMail/1.9.9 References: <4C4DD9B0.4040905@cs.ucla.edu> In-Reply-To: <4C4DD9B0.4040905@cs.ucla.edu> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <201007270122.08912.bruno@clisp.org> X-detected-operating-system: by eggs.gnu.org: Solaris 10 (beta) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Spam-Score: -2.6 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -4.4 (----) Hi Paul, In some cases, I experienced that a program can be made 5% faster just by marking selected functions as 'inline'. Good candidates are those which are only used at one place, and those which are small and where the function call overhead would be noticeable. In gnulib, we use 'inline' with moderation. > this asks the compiler not to warn about unused functions The absence of this warning when 'static inline' is used is not a problem, because in this case gcc doesn't emit code for the unused function anyway. I don't care much whether a .o file built by a compiler that doesn't understand 'inline' is somewhat bigger, as this affects only few platforms, like HP-UX. So I don't find your argument against the use of 'inline' very strong. But there are two other arguments against too much use of 'inline': 1. It makes debugging harder, at least with many combinations of gcc + gdb. 2. Denoting too many functions 'inline' could lead to not so good compiled code on x86 with gcc 2,/3.x. (Newer versions of gcc know how to save and restore a register even inside a function, where there is register pressure, so the use of 'inline' on large functions is not much of a problem any more.) Bruno From unknown Sun Jun 22 07:51:58 2025 X-Loop: help-debbugs@gnu.org Subject: bug#6734: "inline" overused in .c files? Resent-From: Paul Eggert Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-coreutils@gnu.org Resent-Date: Tue, 27 Jul 2010 01:46:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 6734 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: =?UTF-8?Q?P=C3=A1draig?= Brady Cc: Bug-gnulib , Chen Guo , 6734@debbugs.gnu.org Received: via spool by 6734-submit@debbugs.gnu.org id=B6734.1280195113544 (code B ref 6734); Tue, 27 Jul 2010 01:46:02 +0000 Received: (at 6734) by debbugs.gnu.org; 27 Jul 2010 01:45:13 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OdZEF-00008j-OS for submit@debbugs.gnu.org; Mon, 26 Jul 2010 21:45:12 -0400 Received: from kiwi.cs.ucla.edu ([131.179.128.19]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OdZEC-00008K-8D for 6734@debbugs.gnu.org; Mon, 26 Jul 2010 21:45:10 -0400 Received: from [131.179.64.200] (Penguin.CS.UCLA.EDU [131.179.64.200]) by kiwi.cs.ucla.edu (8.13.8+Sun/8.13.8/UCLACS-6.0) with ESMTP id o6R1jC5w010249; Mon, 26 Jul 2010 18:45:13 -0700 (PDT) Message-ID: <4C4E3A28.7010007@cs.ucla.edu> Date: Mon, 26 Jul 2010 18:45:12 -0700 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.10) Gecko/20100527 Thunderbird/3.0.5 MIME-Version: 1.0 References: <4C4DD9B0.4040905@cs.ucla.edu> <4C4E106A.7090003@draigBrady.com> In-Reply-To: <4C4E106A.7090003@draigBrady.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Spam-Score: -3.4 (---) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -3.4 (---) After Bruno's comments it seems that some typical compilers can benefit from "inline" on some functions, particularly small and commonly used functions, so I removed just the "inline"s that didn't appear like they would help measurably on any typical platform. >From 66e934b61f05ef32583df2a33f371c768b79c452 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 26 Jul 2010 18:38:19 -0700 Subject: [PATCH] sort: omit some "inline"s * src/sort.c (mergelines, queue_destroy, queue_init, queue_insert): (queue_pop, write_unique, mergelines_node, check_insert): (update_parent): No longer inline; these uses of "inline" seemed unlikely to help performance much. --- src/sort.c | 18 +++++++++--------- 1 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/sort.c b/src/sort.c index 1fd4ce7..2ee5a1d 100644 --- a/src/sort.c +++ b/src/sort.c @@ -3007,7 +3007,7 @@ mergefiles (struct sortfile *files, size_t ntemps, size_t nfiles, T and LO point just past their respective arrays, and the arrays are in reverse order. NLINES must be at least 2. */ -static inline void +static void mergelines (struct line *restrict t, size_t nlines, struct line const *restrict lo) { @@ -3138,7 +3138,7 @@ unlock_node (struct merge_node *node) /* Destroy merge QUEUE. */ -static inline void +static void queue_destroy (struct merge_node_queue *queue) { heap_free (queue->priority_queue); @@ -3151,7 +3151,7 @@ queue_destroy (struct merge_node_queue *queue) RESERVE should accommodate all of them. Counting a NULL dummy head for the heap, RESERVE should be 2 * NTHREADS. */ -static inline void +static void queue_init (struct merge_node_queue *queue, size_t reserve) { queue->priority_queue = heap_alloc (compare_nodes, reserve); @@ -3162,7 +3162,7 @@ queue_init (struct merge_node_queue *queue, size_t reserve) /* Insert NODE into priority QUEUE. Assume caller either holds lock on NODE or does not need to lock NODE. */ -static inline void +static void queue_insert (struct merge_node_queue *queue, struct merge_node *node) { pthread_mutex_lock (&queue->mutex); @@ -3174,7 +3174,7 @@ queue_insert (struct merge_node_queue *queue, struct merge_node *node) /* Pop NODE off priority QUEUE. Guarantee a non-null, spinlocked NODE. */ -static inline struct merge_node * +static struct merge_node * queue_pop (struct merge_node_queue *queue) { struct merge_node *node; @@ -3192,7 +3192,7 @@ queue_pop (struct merge_node_queue *queue) this function does not actually save the line, nor any key information, thus is only appropriate for internal sort. */ -static inline void +static void write_unique (struct line const *line, FILE *tfp, char const *temp_output) { static struct line const *saved = NULL; @@ -3209,7 +3209,7 @@ write_unique (struct line const *line, FILE *tfp, char const *temp_output) /* Merge the lines currently available to a NODE in the binary merge tree, up to a maximum specified by MAX_MERGE. */ -static inline size_t +static size_t mergelines_node (struct merge_node *restrict node, size_t total_lines, FILE *tfp, char const *temp_output) { @@ -3276,7 +3276,7 @@ mergelines_node (struct merge_node *restrict node, size_t total_lines, /* Insert NODE into QUEUE if it passes insertion checks. */ -static inline void +static void check_insert (struct merge_node *node, struct merge_node_queue *queue) { size_t lo_avail = node->lo - node->end_lo; @@ -3296,7 +3296,7 @@ check_insert (struct merge_node *node, struct merge_node_queue *queue) /* Update parent merge tree NODE. */ -static inline void +static void update_parent (struct merge_node *node, size_t merged, struct merge_node_queue *queue) { -- 1.7.2 From unknown Sun Jun 22 07:51:58 2025 X-Loop: help-debbugs@gnu.org Subject: bug#6734: "inline" overused in .c files? Resent-From: Chen Guo Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-coreutils@gnu.org Resent-Date: Tue, 27 Jul 2010 04:30:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 6734 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: Paul Eggert Cc: Bug-gnulib , Bug-coreutils Received: via spool by submit@debbugs.gnu.org id=B.12802049774693 (code B ref -1); Tue, 27 Jul 2010 04:30:03 +0000 Received: (at submit) by debbugs.gnu.org; 27 Jul 2010 04:29:37 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OdbnN-0001De-2Y for submit@debbugs.gnu.org; Tue, 27 Jul 2010 00:29:37 -0400 Received: from mx10.gnu.org ([199.232.76.166]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OdbnL-0001DZ-5B for submit@debbugs.gnu.org; Tue, 27 Jul 2010 00:29:35 -0400 Received: from lists.gnu.org ([199.232.76.165]:33172) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1OdbnR-0003XL-Vu for submit@debbugs.gnu.org; Tue, 27 Jul 2010 00:29:42 -0400 Received: from [140.186.70.92] (port=40629 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OdbnQ-0002lJ-HZ for bug-coreutils@gnu.org; Tue, 27 Jul 2010 00:29:41 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, T_DKIM_INVALID autolearn=no version=3.3.1 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OdbnO-0005iP-Qd for bug-coreutils@gnu.org; Tue, 27 Jul 2010 00:29:40 -0400 Received: from mail-pz0-f41.google.com ([209.85.210.41]:33145) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OdbnM-0005hr-38; Tue, 27 Jul 2010 00:29:36 -0400 Received: by pzk33 with SMTP id 33so3063705pzk.0 for ; Mon, 26 Jul 2010 21:29:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=FZICdN0as4qZxtYF547O9zTAHASvhDc6e2p7/6MgBLE=; b=STuMhTgt0eWn8l/dh2EYFzTiryoVV79yG05sn6UKdGvvZAj0kiw5M2hATH6sWT/zDT 2beDMKIxxsAbtbl7PFtb812SNHUtETxvB4FtvAoMaNUywi0o7caEzC6c8C/8Bi7eVULH WW5oxikibTYnxzrhrnIKDiuiwKmMNvdbo6GZU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=k9zmTTkf7cXyVBcoXyfAYEl48W7wAXhWGxry8Fl0E0vAMGBSb6uu0Oye8iw3ySYEld I+id2hkauZngxOZ1NMTTBXddEfezIjObwHfkAA77se3T2ec8Z9d2jYE1iDYkmvBMVTWw /1NDu5ujyAKdSZH7NbaJyc6qlkqRVCD9vMQhA= MIME-Version: 1.0 Received: by 10.142.48.18 with SMTP id v18mr4822691wfv.102.1280204973849; Mon, 26 Jul 2010 21:29:33 -0700 (PDT) Received: by 10.142.216.2 with HTTP; Mon, 26 Jul 2010 21:29:33 -0700 (PDT) In-Reply-To: <4C4DD9B0.4040905@cs.ucla.edu> References: <4C4DD9B0.4040905@cs.ucla.edu> Date: Mon, 26 Jul 2010 21:29:33 -0700 Message-ID: From: Chen Guo Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Spam-Score: -4.3 (----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -4.5 (----) On Mon, Jul 26, 2010 at 11:53 AM, Paul Eggert wrote: > I noticed thirteen "inline"s in coreutils/src/sort.c. =A0Just for fun, I > removed them all. =A0In ten cases, removing "inline" made no difference t= o > the generated machine code on my platform (RHEL 5, x86-64, GCC 4.1.2, > compiled with the typical gcc -O2). =A0In the three sort.c functions > that were exceptions (queue_insert, write_unique, check_insert), > removing "inline" made the overall code a tad shorter with no > measurable change to CPU performance. > > Is there a reason those "inline"s are in there? =A0If not, I'm inclined > to remove them. =A0I can see a use for "static inline" in .h files, as > this asks the compiler not to warn about unused functions, but as far > as I know, it's typically not necessary to use "inline" in .c files > these days, as the compiler is typically smart enough. > > I've checked this only for coreutils/src/sort.c but perhaps the same > argument applies to other source files in coreutils or other GNU apps, so > I'll CC: this to bug-gnulib for more-general comment. > It's interesting that the three that are different are all from the new pat= ch... I can't think of a reason off the top of my head why we chose to inline the= m; they are all short functions that are called _very_ often in our algorithm,= and that's the most likely reason why we inlined them. I also recall a small bump in performance with at least write_unique, but t= hat could have just been a blip from testing on a shared machine. From debbugs-submit-bounces@debbugs.gnu.org Tue Sep 13 08:52:32 2011 Received: (at control) by debbugs.gnu.org; 13 Sep 2011 12:52:32 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1R3STX-0003lM-HJ for submit@debbugs.gnu.org; Tue, 13 Sep 2011 08:52:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1R3STV-0003lF-H2 for control@debbugs.gnu.org; Tue, 13 Sep 2011 08:52:30 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p8DCm2ah019410 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 13 Sep 2011 08:48:02 -0400 Received: from mx.meyering.net (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p8DCm1t5002881 for ; Tue, 13 Sep 2011 08:48:01 -0400 Received: from rho.meyering.net (localhost.localdomain [127.0.0.1]) by rho.meyering.net (Acme Bit-Twister) with ESMTP id ADD1C6011F for ; Tue, 13 Sep 2011 14:48:00 +0200 (CEST) From: Jim Meyering To: control@debbugs.gnu.org Subject: mark as done [Re: "inline" overused in .c files? Date: Tue, 13 Sep 2011 14:48:00 +0200 Message-ID: <87obyo38xr.fsf@rho.meyering.net> Lines: 2 MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-Spam-Score: -10.5 (----------) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -10.5 (----------) close 6734 thanks