From patchwork Fri Dec 11 01:34:09 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 555440 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 1CF7C1402D8 for ; Fri, 11 Dec 2015 12:34:25 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=rpKWWiAU; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=pNScp3nOaHlT4xfC1DdtA+uhz8vEmAyiZA8iqpAHgTDMsLI/7KFc4 h1nRr7RYsdDaIHXGWKIUfvWuhcxiOaH0aevuRtAoeHF9YOAZ3++9I+McyEa3uiGs 060rggYj9KFY13Pb/dKNmDVcwow0zj3VPoY2Ty9XYhCYrc1k7+M6V0= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=txtfjcqTXh9X+FlifWsZ5LA5PFo=; b=rpKWWiAU/hO7lRCz/bGm 1H8egl0AbKzIqVM4TugB9QoULKjTxeuhg1EZ2gaLmm5ERVY0pSRnxImNRKl2Bz/E 3rr5l+Z9HncOM38fgzKJqwJmLg5a+9aWR0LsMSQ5rWrZFBiH+zeS7nSwlZEdgP9T T3+NyN476psybfuUUSKTEL0= Received: (qmail 10987 invoked by alias); 11 Dec 2015 01:34:14 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 10963 invoked by uid 89); 11 Dec 2015 01:34:13 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.2 required=5.0 tests=AWL, BAYES_40, KAM_LAZY_DOMAIN_SECURITY, T_RP_MATCHES_RCVD autolearn=no version=3.3.2 X-HELO: nikam.ms.mff.cuni.cz Received: from nikam.ms.mff.cuni.cz (HELO nikam.ms.mff.cuni.cz) (195.113.20.16) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 11 Dec 2015 01:34:12 +0000 Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 4540F543F09; Fri, 11 Dec 2015 02:34:09 +0100 (CET) Date: Fri, 11 Dec 2015 02:34:09 +0100 From: Jan Hubicka To: gcc-patches@gcc.gnu.org, rguenther@suse.de Subject: Reduce global decl stream Message-ID: <20151211013409.GB5527@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Hi, this patch saves about 30% of global decl stream size in firefox. While implementing the lto sections for initializers I put very stupid heursitcs to get_symbol_initial_value deciding whether the initializer is better streamed inline or offline. This ignores strings and may get bit out of hand. With this patch and the compression, the largest ltrans unit is 118479156 bytes and 103584016 out of that is a global decl stream. Bootstrapped/regtested x86_64-linux OK? Honza * lto-streamer-out.c (subtract_estimated_size): New function (get_symbol_initial_value): Use it. Index: lto-streamer-out.c =================================================================== --- lto-streamer-out.c (revision 231546) +++ lto-streamer-out.c (working copy) @@ -309,6 +309,33 @@ lto_is_streamable (tree expr) || TREE_CODE_CLASS (code) != tcc_statement); } +/* Very rough estimate of streaming size of the initializer. If we ignored + presence of strings, we could simply just count number of non-indexable + tree nodes and number of references to indexable nodes. Strings however + may be very large and we do not want to dump them int othe global stream. + + Count the size of initializer until the size in DATA is positive. */ + +static tree +subtract_estimated_size (tree *tp, int *ws, void *data) +{ + long *sum = (long *)data; + if (tree_is_indexable (*tp)) + { + *sum -= 4; + *ws = 0; + } + if (TREE_CODE (*tp) == STRING_CST) + *sum -= TREE_STRING_LENGTH (*tp) + 8; + if (TREE_CODE (*tp) == IDENTIFIER_NODE) + *sum -= IDENTIFIER_LENGTH (*tp) + 8; + else + *sum -= 16; + if (*sum < 0) + return *tp; + return NULL_TREE; +} + /* For EXPR lookup and return what we want to stream to OB as DECL_INITIAL. */ @@ -329,10 +356,16 @@ get_symbol_initial_value (lto_symtab_enc varpool_node *vnode; /* Extra section needs about 30 bytes; do not produce it for simple scalar values. */ - if (TREE_CODE (DECL_INITIAL (expr)) == CONSTRUCTOR - || !(vnode = varpool_node::get (expr)) + if (!(vnode = varpool_node::get (expr)) || !lto_symtab_encoder_encode_initializer_p (encoder, vnode)) initial = error_mark_node; + if (initial != error_mark_node) + { + long max_size = 30; + if (walk_tree (&initial, subtract_estimated_size, (void *)&max_size, + NULL)) + initial = error_mark_node; + } } return initial;