Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754383AbdHYCqN (ORCPT ); Thu, 24 Aug 2017 22:46:13 -0400 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:57310 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754191AbdHYCqL (ORCPT ); Thu, 24 Aug 2017 22:46:11 -0400 From: Nick Terrell To: Sergey Senozhatsky CC: Joonsoo Kim , "linux-kernel@vger.kernel.org" , "minchan@kernel.org" , Yann Collet Subject: Re: [PATCH] zram: add zstd to the supported algorithms list Thread-Topic: [PATCH] zram: add zstd to the supported algorithms list Thread-Index: AQHTHSCvXWqWlMVfbUKYI//VGek9A6KUPdeA//+XcYCAAHo6gP//jzWAgAB4pAD//5GggA== Date: Fri, 25 Aug 2017 02:46:04 +0000 Message-ID: <69F9B64F-B138-4D8B-9167-9B91855CFFA9@fb.com> References: <20170824014936.4738-1-sergey.senozhatsky@gmail.com> <20170825004947.GE29701@js1304-P5Q-DELUXE> <27EDD68A-61DC-42F1-8422-16B9AB9F0EB3@fb.com> <20170825015301.GB743@jagdpanzerIV.localdomain> <08620C31-AD6A-4DDB-ACA6-22243920AE1E@fb.com> <20170825022106.GC743@jagdpanzerIV.localdomain> In-Reply-To: <20170825022106.GC743@jagdpanzerIV.localdomain> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [2620:10d:c090:200::7:5460] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR15MB1420;20:jGFgDgdnyV0W9G//mZ76AgF+yBmAdpRpZd4jA1Tx2E4b9F9XESlujD/8whYo1XlqrX744UPjgy3eFLgoamuU7z5g29N34t5M1gC3gJfoEWvwnSpObPvvP8RXY7IPiyCR79OT6fO/+HmHUGUz8lYIXS7cE7DFKb3nfAqSn/C1HVc= x-ms-exchange-antispam-srfa-diagnostics: SSOS;SSOR; x-forefront-antispam-report: SFV:SKI;SCL:-1;SFV:NSPM;SFS:(10019020)(6009001)(189002)(377454003)(24454002)(199003)(68736007)(110136004)(2950100002)(6246003)(53936002)(6436002)(8936002)(4326008)(229853002)(6506006)(6486002)(77096006)(25786009)(36756003)(39060400002)(6512007)(99286003)(33656002)(76176999)(50986999)(54906002)(54356999)(101416001)(8676002)(3660700001)(189998001)(81166006)(5660300001)(81156014)(7736002)(14454004)(6916009)(305945005)(2900100001)(53546010)(83716003)(478600001)(3280700002)(93886005)(2906002)(97736004)(86362001)(82746002)(102836003)(6116002)(105586002)(106356001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR15MB1420;H:DM5PR15MB1753.namprd15.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; x-ms-office365-filtering-correlation-id: 63011484-cede-4289-ffc5-08d4eb636e37 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:DM5PR15MB1420; x-ms-traffictypediagnostic: DM5PR15MB1420: x-exchange-antispam-report-test: UriScan:; x-microsoft-antispam-prvs: x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(8121501046)(5005006)(3002001)(100000703101)(100105400095)(10201501046)(93006095)(93001095)(6041248)(20161123555025)(20161123562025)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123558100)(20161123560025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:DM5PR15MB1420;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:DM5PR15MB1420; x-forefront-prvs: 041032FF37 spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="utf-8" Content-ID: MIME-Version: 1.0 X-MS-Exchange-CrossTenant-originalarrivaltime: 25 Aug 2017 02:46:04.8598 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 8ae927fe-1255-47a7-a2af-5f3a069daaa2 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR15MB1420 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-08-25_01:,, 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 v7P2kIgu021093 Content-Length: 1737 Lines: 31 On 8/24/17, 7:21 PM, "Sergey Senozhatsky" wrote: > not really familiar either... I was thinking about having "zstd" and > "zstd_dict" crypto_alg structs - one would be !dict, the other one would > allocate dict and pass it to compress/decompress zstd callbacks. "zstd" > vecrsion would invoke zstd_params() passing zeros as compress and dict > sizes to ZSTD_getParams(), while "zstd_dict" would invoke, lets say, > zstd_params_dict() passing PAGE_SIZE-s. hm... (0, PAGE_SIZE)? to > ZSTD_getParams(). just a rough idea... The way zstd dictionaries work is the user provides some data which gets "prepended" to the data that is about to be compressed, without actually writing it to output. That way zstd can find matches in the dictionary and represent them for "free". That means the user has to pass the same data to both the compressor and decompressor. We could build a dictionary, say every 20 minutes, by sampling 512 B chunks of the RAM and constructing a 16 KB dictionary. Then recompress all the compressed RAM with the new dictionary. This is just a simple example of a dictionary construction algorithm. You could imagine grouping pages by application, and building a dictionary per application, since those pages would likely be more similar. Regarding the crypto API, I think it would be possible to experiment by creating functions like `zstd_comp_add_dictionary(void *ctx, void *data, size_t size)' and `zstd_decomp_add_dictionary(void *ctx, void *data, size_t size)' in the crypto zstd implementation and declare them in `zcomp.c'. If the experiments prove that using zstd dictionaries (or LZ4 dictionaries) is worthwhile, then we can figure out how we can make it work for real.