Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751969AbdIVTON (ORCPT ); Fri, 22 Sep 2017 15:14:13 -0400 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:51332 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751795AbdIVTOL (ORCPT ); Fri, 22 Sep 2017 15:14:11 -0400 From: Nick Terrell To: Colin King , Chris Mason CC: "kernel-janitors@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] lib: zstd: make const array rtbTable static, reduces object code size Thread-Topic: [PATCH] lib: zstd: make const array rtbTable static, reduces object code size Thread-Index: AQHTM7N9KhSfulA6+kKHmmoJXouq9aLA0SkA Date: Fri, 22 Sep 2017 19:14:05 +0000 Message-ID: <6C490CCD-32E1-4AC3-BCCF-5EB3A56EA887@fb.com> References: <20170922145946.14316-1-colin.king@canonical.com> In-Reply-To: <20170922145946.14316-1-colin.king@canonical.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [2620:10d:c090:200::6:f8f4] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;CY4PR15MB1655;20:CouAnEisyGhas4smbXl6ZP6ciWF+tLnPXxzifRZE058leJXJtZA9AGm1z8ws4sqM0aEKw+IWPZ9ODEHZpqHctDChQLSETH2FWd8rfpjdZEZNYOkfUNTkxwpHlsTr5KXyZvX8PsKCya+tcOVj1XYfuQJ7nY4OlhYp2yu7vJLFy5o= x-ms-exchange-antispam-srfa-diagnostics: SSOS;SSOR; x-forefront-antispam-report: SFV:SKI;SCL:-1;SFV:NSPM;SFS:(10019020)(6009001)(346002)(376002)(189002)(24454002)(377454003)(199003)(305945005)(7736002)(2950100002)(966005)(2906002)(99286003)(6512007)(25786009)(6116002)(5660300001)(102836003)(6306002)(8676002)(81166006)(68736007)(81156014)(86362001)(83716003)(8936002)(3660700001)(316002)(478600001)(3280700002)(110136005)(6246003)(54906003)(53936002)(97736004)(50986999)(33656002)(76176999)(54356999)(6506006)(36756003)(77096006)(82746002)(4326008)(6486002)(229853002)(6436002)(14454004)(2900100001)(53546010)(101416001)(189998001)(105586002)(106356001)(6636002);DIR:OUT;SFP:1102;SCL:1;SRVR:CY4PR15MB1655;H:CY4PR15MB1752.namprd15.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; x-ms-office365-filtering-correlation-id: 0f1f3df6-19b5-4961-310a-08d501ee180d x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(300000502095)(300135100095)(22001)(2017030254152)(300000503095)(300135400095)(2017052603199)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:CY4PR15MB1655; x-ms-traffictypediagnostic: CY4PR15MB1655: x-exchange-antispam-report-test: UriScan:(166708455590820)(9452136761055)(67672495146484)(81227570615382)(198206253151910); x-microsoft-antispam-prvs: x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(8121501046)(5005006)(100000703101)(100105400095)(10201501046)(93006095)(93001095)(3002001)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(20161123558100)(20161123562025)(20161123560025)(20161123555025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:CY4PR15MB1655;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:CY4PR15MB1655; x-forefront-prvs: 0438F90F17 spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="utf-8" Content-ID: MIME-Version: 1.0 X-MS-Exchange-CrossTenant-originalarrivaltime: 22 Sep 2017 19:14:05.8748 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 8ae927fe-1255-47a7-a2af-5f3a069daaa2 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR15MB1655 X-OriginatorOrg: fb.com X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-09-22_08:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by nfs id v8MJEJVD001596 Content-Length: 1437 Lines: 36 On 9/22/17, 8:00 AM, "linux-kernel-owner@vger.kernel.org on behalf of Colin King" wrote: > From: Colin Ian King > > Don't populate const array rtbTable on the stack, instead make it > static. Also split overly long line to clean a chechkpach warning. > Makes the object code smaller by nearly 500 bytes: > > Before: > text data bss dec hex filename > 13297 104 0 13401 3459 lib/zstd/fse_compress.o > > After: > text data bss dec hex filename > 12742 160 0 12902 3266 lib/zstd/fse_compress.o > > (gcc 6.3.0, x86-64) > > Signed-off-by: Colin Ian King I tested your patch with gcc-7.1 on x86, and benchmarked the speed on upstream zstd. There isn't a noticeable speed difference, since it isn't a particularly hot piece of code. Would you be able to submit the same patch upstream [1], or would you be okay with me porting it back upstream, so it doesn't get lost on an update? I didn't expect gcc to leave constant arrays on the stack, that seems silly. Clang makes it static, but gcc loads it onto the stack, and in 6.3+ it saves the data statically, and then uses vector instructions to load it onto the stack [2]. Tested-by: Nick Terrell [1] https://github.com/facebook/zstd [2] https://godbolt.org/g/fvTcED