From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25515 invoked by alias); 18 Apr 2012 04:58:09 -0000 Received: (qmail 25501 invoked by uid 22791); 18 Apr 2012 04:58:06 -0000 X-SWARE-Spam-Status: No, hits=-4.3 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,KHOP_THREADED X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 18 Apr 2012 04:57:19 +0000 From: "tglek at mozilla dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug other/46770] Replace .ctors/.dtors with .init_array/.fini_array on targets supporting them Date: Wed, 18 Apr 2012 04:58:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: other X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: tglek at mozilla dot com X-Bugzilla-Status: RESOLVED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: hjl.tools at gmail dot com X-Bugzilla-Target-Milestone: 4.7.0 X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2012-04/txt/msg01462.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46770 --- Comment #93 from Taras Glek 2012-04-18 04:48:18 UTC --- (In reply to comment #92) > As I said in comment #47 and elsewhere, you should not confuse the order in > which entries appear in .ctors or .init_array sections with the order in which > they appear in the binary. If you want better layout in the binary, then tell > the linker to change the layout in the binary. The order in the .ctors or > .init_array sections is irrelevant. The fact that reversing the order of > constructors happens to give you faster startup for firefox is just a > coincidence. Don't let that coincidence drive you toward choices that make no > sense. I am not confusing the order in which entries appear. My concerns is the order in which code gets paged in from disk. Right now that's driven entirely by translation unit "concatenation" and how that relates to the order of ctor invocation. Currently the right thing(tm) happens, achieving the same by other means is considerably more complicated. There are 2 problems with using section ordering to solve this a) there is no way to do this kind of section ordering transparently(especially not by default) with current infrastructure. b) it doesn't work without lto because initializers pull in other code... I'll expand on b: We(C++ code like Firefox/Chrome/etc) have one initializer per TU. The initializer is often not self-contained and calls other code within the unit(and rarely in other units...this you can't solve without LTO) So if you pass a list of init sections to the linker...that list needs to be transitive and include all of the sections called from inits in order to achieve a useful level of locality post-reorder. Or you can keep TUs without any reordering, have decent locality(because related init code is generally nearby) and a sane page-in pattern if the order of init executions matches TU layout.