Received: by 10.213.65.68 with SMTP id h4csp82481imn; Wed, 21 Mar 2018 12:58:14 -0700 (PDT) X-Google-Smtp-Source: AG47ELvPs7cnBZO3/3BM6l6JFD6KA6t4AUlC8nwUu2s3pJTMS2jwyqNWODCNVAA+ynyJ6/xLO++5 X-Received: by 2002:a17:902:6884:: with SMTP id i4-v6mr22531949plk.259.1521662294802; Wed, 21 Mar 2018 12:58:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521662294; cv=none; d=google.com; s=arc-20160816; b=B5VGl9oCERE+XKinc+rVzUpdyhY2/JcufagSzjRtVHa0gqbVbBeIBojiG5Jw1pleMN YEOph3IOExlAsns31OQFIj98WbVe1IkvgRe1MRChuqeFFZ9df/zCOwT6+nfjTGKbdV3G mGxD3FOFj6K9y6htpqMcg9nXXWtCfVM1y345RoiDQvKnKuuDvscLJNx2X2cD+VdtK4hx tJuJJtnfDE2MWAErYiRUkiWzz6kMl64ysGYq08ZpMjs4pUwS703AVCqad//RE/L0xPX1 /VDyeKzeX9G+urn1MXRbggyRDQG/0A/Be+xdtkJG3gXHrIhxeEAVRgYS72Pr5Md0RP/s 9eMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-id:spamdiagnosticmetadata:spamdiagnosticoutput :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from:dkim-signature :dkim-signature:arc-authentication-results; bh=1Y3W7CadJw+keZkGPqjAUMkynRALMU93nRkH2spJv14=; b=IbRLgzYwKjgylKdu07KzV6MABWMzmmOie71BRBDep765HNHJHNhv+pFjCtwJHAbCbP ZAHfqpo6FRsaZsw4fNDPGjbugfgYn8YbN3gZOIyPRP3GNmnKLm0k1+X1lmaQN4k/w7gL 1ItbxHxiN+DGuFSZNsHSee2gQZmRWXiSloO7fTmFtf/1jBv9fGG7xrFFUWABht17GFQk NV4TtY645Wzsfjaitgm6aSr/szpkGMNIYhfUVcf/m+fEFCbyJ5rmVstFGk07EC3gh9zQ G6wJVw5aHBbLBfveiWE46QA28r0s9ibW/baC+eeI7G1vbeNdkWCKyC2gt4v5zu/OsMk5 x5tw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=igzSahU9; dkim=pass header.i=@fb.onmicrosoft.com header.s=selector1-fb-com header.b=fmY3e55b; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fb.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e74si3576422pfd.97.2018.03.21.12.57.44; Wed, 21 Mar 2018 12:58:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=igzSahU9; dkim=pass header.i=@fb.onmicrosoft.com header.s=selector1-fb-com header.b=fmY3e55b; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fb.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753029AbeCUT4l (ORCPT + 99 others); Wed, 21 Mar 2018 15:56:41 -0400 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:33316 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752637AbeCUT4j (ORCPT ); Wed, 21 Mar 2018 15:56:39 -0400 Received: from pps.filterd (m0109334.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w2LJr1SG024419; Wed, 21 Mar 2018 12:56:16 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-id : content-transfer-encoding : mime-version; s=facebook; bh=1Y3W7CadJw+keZkGPqjAUMkynRALMU93nRkH2spJv14=; b=igzSahU9AM/b1o6ju93TjZQ1AqIPckgK7S9Hn4rr+5Te3U3FIh/YFP4UbUBehASxPgb9 WXGlQWNyFFmqP6ZpDpepOfq3iFlz0FUSRppcoNU1wtbk4VGzNdzspK9vqSkXfeggM9PE W18apbIUIPuOpXMxTdhhIT7G+jXdSjZDNwU= Received: from maileast.thefacebook.com ([199.201.65.23]) by mx0a-00082601.pphosted.com with ESMTP id 2gusfe16hw-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Wed, 21 Mar 2018 12:56:16 -0700 Received: from NAM01-SN1-obe.outbound.protection.outlook.com (192.168.183.28) by o365-in.thefacebook.com (192.168.177.33) with Microsoft SMTP Server (TLS) id 14.3.361.1; Wed, 21 Mar 2018 15:56:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.onmicrosoft.com; s=selector1-fb-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=1Y3W7CadJw+keZkGPqjAUMkynRALMU93nRkH2spJv14=; b=fmY3e55b3tDAneMNA/hDOuA/rjvze+IqnkSmIi4aLaxEC6ZuuV2UKMYSNaBVfZDfdoCoG+F06LAxfG5gC/Uhrxuro9LvAKuVxg9NqCfVUWzqxk6L2u2RaJRm24hR7bD9bXjpaLA2Fi4RavzyD+miwh54MAeTDihpP82Qh7o7ySE= Received: from CY4PR15MB1543.namprd15.prod.outlook.com (10.172.162.8) by CY4PR15MB1350.namprd15.prod.outlook.com (10.172.158.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.588.14; Wed, 21 Mar 2018 19:56:11 +0000 Received: from CY4PR15MB1543.namprd15.prod.outlook.com ([fe80::89c7:6362:1da2:996f]) by CY4PR15MB1543.namprd15.prod.outlook.com ([fe80::89c7:6362:1da2:996f%14]) with mapi id 15.20.0588.017; Wed, 21 Mar 2018 19:56:10 +0000 From: Nick Terrell To: Sergey Senozhatsky CC: Maninder Singh , "herbert@gondor.apana.org.au" , "davem@davemloft.net" , "minchan@kernel.org" , "ngupta@vflare.org" , Kees Cook , "anton@enomsg.org" , "ccross@android.com" , "tony.luck@intel.com" , "akpm@linux-foundation.org" , "colin.king@canonical.com" , "linux-crypto@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "pankaj.m@samsung.com" , "a.sahrawat@samsung.com" , "v.narang@samsung.com" , Yann Collet Subject: Re: [PATCH 0/1] cover-letter/lz4: Implement lz4 with dynamic offset length. Thread-Topic: [PATCH 0/1] cover-letter/lz4: Implement lz4 with dynamic offset length. Thread-Index: AQHTwO5jt8QdQWvsxEiscfHuXN/+16PbG3KA Date: Wed, 21 Mar 2018 19:56:10 +0000 Message-ID: <1663C9A3-7DAC-4A11-894C-C99E07BEDAD2@fb.com> References: <1521607242-3968-1-git-send-email-maninder1.s@samsung.com> <20180321082628.GB2746@jagdpanzerIV> In-Reply-To: <20180321082628.GB2746@jagdpanzerIV> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [2620:10d:c090:200::5:3299] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;CY4PR15MB1350;7:+TQyh9k8+h6rbcIkjdLlOogB8XOd88MuLcpJlMLcIA8pewy1A5n8NFePRNVTl/1Z3A/pfofKDWSPJuxYgWyqR09eIqR1bhxZkpj/rRlcumh6FyF9Inp1m/xJQ5HAzV+8SHiZEEI/RxaaczatAdKnZjiDj2Rg6kmcRbfSH3Z8Pkkrq2unEX1P2DdnUDKDFHcNPDLnmfbxlgtnlVreyvI31JdkhL3/DDb8wJy6+gwO6GtaRNASr1UlN9zE+xWXU2F1;20:NRvhTWxZ4j/u0MF7pMPQx3sVJq9qblhdJCyUt+41YFeypKarQD7cItnWQlnsmwulRJaV0ZRk78kCRPu45zKVC8Mk/U3s9Qq6e/n+YRjtdu1NsInUSUROTEbWNXmVjQ4ghhlJ/Jg6YSbRbdWMxV8taUKPfSB4C5nvSWJxHaYKWfU= x-ms-exchange-antispam-srfa-diagnostics: SOS;SOR; x-forefront-antispam-report: SFV:SKI;SCL:-1;SFV:NSPM;SFS:(10019020)(346002)(39860400002)(376002)(366004)(39380400002)(396003)(189003)(199004)(81166006)(83716003)(5660300001)(39060400002)(186003)(316002)(82746002)(14454004)(76176011)(5250100002)(6116002)(6486002)(36756003)(2900100001)(6512007)(6916009)(54906003)(3280700002)(106356001)(3660700001)(97736004)(7416002)(81156014)(86362001)(8676002)(2906002)(4326008)(8936002)(7736002)(33656002)(99286004)(478600001)(46003)(2950100002)(105586002)(53936002)(25786009)(305945005)(6246003)(229853002)(6506007)(6436002)(102836004)(68736007)(446003);DIR:OUT;SFP:1102;SCL:1;SRVR:CY4PR15MB1350;H:CY4PR15MB1543.namprd15.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; x-ms-office365-filtering-correlation-id: 851569e2-8750-4d20-c585-08d58f65cb1a x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020);SRVR:CY4PR15MB1350; x-ms-traffictypediagnostic: CY4PR15MB1350: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(93006095)(93001095)(3231221)(11241501184)(944501326)(52105095)(3002001)(10201501046)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123564045)(20161123558120)(20161123562045)(6072148)(201708071742011);SRVR:CY4PR15MB1350;BCL:0;PCL:0;RULEID:;SRVR:CY4PR15MB1350; x-forefront-prvs: 0618E4E7E1 received-spf: None (protection.outlook.com: fb.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: crRTWOjMblf2XR18o6+vCQhTvra/dTkiUNm7kjbDyVthQzlzP3nyR8N3RtZSpcxBXJvHEP7IyPc1bnaYxArc+1gcwFq6cObWyoLKeLvgedEZV8Vs3privaVmY12rVrv7JU8LDpzyO4VUQexXNdBzRfDNY64aQFMCthwkLwQcSv/j/zuEgy5cP7JZlXGUZtMrFf1VZtQUM8og1Wo0Cn5DB/Fim2KcX46VrPSjs02zkFxM/KPAuxwYLquCoPk1DPZ+qjT5uBRTpOZZwGM6/fM2XMk/tiNgvfjZ54t6X1S0E/JI8WXd6tsmRxGa8eddo7CXU22jCvxiqJdIAgi4Dv9BiQ== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-ID: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 851569e2-8750-4d20-c585-08d58f65cb1a X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Mar 2018 19:56:10.3228 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 8ae927fe-1255-47a7-a2af-5f3a069daaa2 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR15MB1350 X-OriginatorOrg: fb.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2018-03-21_09:,, signatures=0 X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On (03/21/18 10:10), Maninder Singh wrote: > LZ4 specification defines 2 byte offset length for 64 KB data. > But in case of ZRAM we compress data per page and in most of > architecture PAGE_SIZE is 4KB. So we can decide offset length based > on actual offset value. For this we can reserve 1 bit to decide offset > length (1 byte or 2 byte). 2 byte required only if ofsset is greater than= 127, > else 1 byte is enough. >=20 > With this new implementation new offset value can be at MAX 32 KB. >=20 > Thus we can save more memory for compressed data. >=20 > results checked with new implementation:- >=20 > comression size for same input source > (LZ4_DYN < LZO < LZ4) >=20 > LZO > =3D=3D=3D=3D=3D=3D=3D > orig_data_size: 78917632 > compr_data_size: 15894668 > mem_used_total: 17117184 >=20 > LZ4 > =3D=3D=3D=3D=3D=3D=3D=3D > orig_data_size: 78917632 > compr_data_size: 16310717 > mem_used_total: 17592320 >=20 > LZ4_DYN > =3D=3D=3D=3D=3D=3D=3D > orig_data_size: 78917632 > compr_data_size: 15520506 > mem_used_total: 16748544 This seems like a reasonable extension to the algorithm, and it looks like LZ4_DYN is about a 5% improvement to compression ratio on your benchmark. The biggest question I have is if it is worthwhile to maintain a separate incompatible variant of LZ4 in the kernel without any upstream for a 5% gain? If we do want to go forward with this, we should perform more benchmarks. I commented in the patch, but because the `dynOffset` variable isn't a compile time static in LZ4_decompress_generic(), I suspect that the patch causes a regression in decompression speed for both LZ4 and LZ4_DYN. You'll need to re-run the benchmarks to first show that LZ4 before the patch performs the same as LZ4 after the patch. Then re-run the LZ4 vs LZ4_DYN benchmarks. I would also like to see a benchmark in user-space (with the code), so we can see the performance of LZ4 before and after the patch, as well as LZ4 vs LZ4_DYN without anything else going on. I expect the extra branches in the decoding loop to have an impact on speed, and I would like to see how big the impact is without noise.=20 CC-ing Yann Collet, the author of LZ4