From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id B02F63857800 for ; Mon, 14 Sep 2020 08:48:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org B02F63857800 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-179-NNTcFqn5P3eDUPlFw60txw-1; Mon, 14 Sep 2020 04:48:21 -0400 X-MC-Unique: NNTcFqn5P3eDUPlFw60txw-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E7C9380EF9E; Mon, 14 Sep 2020 08:48:16 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-113-252.ams2.redhat.com [10.36.113.252]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3ACD56F563; Mon, 14 Sep 2020 08:48:16 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id 08E8mCMv029758; Mon, 14 Sep 2020 10:48:13 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id 08E8mA2J029757; Mon, 14 Sep 2020 10:48:10 +0200 Date: Mon, 14 Sep 2020 10:48:10 +0200 From: Jakub Jelinek To: Richard Biener Cc: Jan Hubicka , gcc-patches@gcc.gnu.org, "Joseph S. Myers" Subject: Re: [PATCH] options, lto: Optimize streaming of optimization nodes Message-ID: <20200914084810.GU21814@tucnak> Reply-To: Jakub Jelinek References: <20200913083327.GG21814@tucnak> <20200914070048.GT21814@tucnak> MIME-Version: 1.0 In-Reply-To: User-Agent: Mutt/1.11.3 (2019-02-01) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0.002 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Sep 2020 08:48:25 -0000 On Mon, Sep 14, 2020 at 09:31:52AM +0200, Richard Biener wrote: > But does it make any noticable difference in the end? Using Yes. > bp_pack_var_len_unsigned just causes us to [u]leb encode half-bytes > rather than full bytes. Using hardcoded 8/16/32/64 makes it still > dependent on what 'int' is at maximum on the host. > > That is, I'd indeed prefer bp_pack_var_len_unsigned over hard-coding > 8, 16, etc., but can you share a size comparison of the bitpack? > I guess with bp_pack_var_len_unsigned it might shrink in half > compared to the current code and streaming standard -O2? So, I've tried --- gcc/tree-streamer-out.c.jj 2020-07-28 15:39:10.079755251 +0200 +++ gcc/tree-streamer-out.c 2020-09-14 10:31:29.106957258 +0200 @@ -489,7 +489,11 @@ streamer_write_tree_bitfields (struct ou pack_ts_translation_unit_decl_value_fields (ob, &bp, expr); if (CODE_CONTAINS_STRUCT (code, TS_OPTIMIZATION)) +{ +long ts = ob->main_stream->total_size; cl_optimization_stream_out (ob, &bp, TREE_OPTIMIZATION (expr)); +fprintf (stderr, "total_size %ld\n", (long) (ob->main_stream->total_size - ts)); +} if (CODE_CONTAINS_STRUCT (code, TS_CONSTRUCTOR)) bp_pack_var_len_unsigned (&bp, CONSTRUCTOR_NELTS (expr)); hack without and with the following patch on a simple small testcase with -O2 -flto. Got 574 bytes without the opc-save-gen.awk change and 454 bytes with it, that is ~ 21% saving on the TREE_OPTIMIZATION streaming. 2020-09-14 Jakub Jelinek * optc-save-gen.awk: In cl_optimization_stream_out use bp_pack_var_len_{int,unsigned} instead of bp_pack_value. In cl_optimization_stream_in use bp_unpack_var_len_{int,unsigned} instead of bp_unpack_value. Formatting fix. --- gcc/optc-save-gen.awk.jj 2020-09-14 09:04:35.879854156 +0200 +++ gcc/optc-save-gen.awk 2020-09-14 10:38:47.722424942 +0200 @@ -1257,8 +1257,10 @@ for (i = 0; i < n_opt_val; i++) { otype = var_opt_val_type[i]; if (otype ~ "^const char \\**$") print " bp_pack_string (ob, bp, ptr->" name", true);"; + else if (otype ~ "^unsigned") + print " bp_pack_var_len_unsigned (bp, ptr->" name");"; else - print " bp_pack_value (bp, ptr->" name", 64);"; + print " bp_pack_var_len_int (bp, ptr->" name");"; } print " for (size_t i = 0; i < sizeof (ptr->explicit_mask) / sizeof (ptr->explicit_mask[0]); i++)"; print " bp_pack_value (bp, ptr->explicit_mask[i], 64);"; @@ -1274,14 +1276,15 @@ print "{"; for (i = 0; i < n_opt_val; i++) { name = var_opt_val[i] otype = var_opt_val_type[i]; - if (otype ~ "^const char \\**$") - { - print " ptr->" name" = bp_unpack_string (data_in, bp);"; - print " if (ptr->" name")"; - print " ptr->" name" = xstrdup (ptr->" name");"; + if (otype ~ "^const char \\**$") { + print " ptr->" name" = bp_unpack_string (data_in, bp);"; + print " if (ptr->" name")"; + print " ptr->" name" = xstrdup (ptr->" name");"; } + else if (otype ~ "^unsigned") + print " ptr->" name" = (" var_opt_val_type[i] ") bp_unpack_var_len_unsigned (bp);"; else - print " ptr->" name" = (" var_opt_val_type[i] ") bp_unpack_value (bp, 64);"; + print " ptr->" name" = (" var_opt_val_type[i] ") bp_unpack_var_len_int (bp);"; } print " for (size_t i = 0; i < sizeof (ptr->explicit_mask) / sizeof (ptr->explicit_mask[0]); i++)"; print " ptr->explicit_mask[i] = bp_unpack_value (bp, 64);"; Jakub