Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756818AbdHYTbZ (ORCPT ); Fri, 25 Aug 2017 15:31:25 -0400 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:35061 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1756704AbdHYTbX (ORCPT ); Fri, 25 Aug 2017 15:31:23 -0400 From: Nick Terrell To: Minchan Kim CC: Joonsoo Kim , "sergey.senozhatsky.work@gmail.com" , "linux-kernel@vger.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//+XcYCAALPlgIAAeKYA Date: Fri, 25 Aug 2017 19:31:14 +0000 Message-ID: <315465C2-671F-4165-970E-B74ACFB9398D@fb.com> References: <20170824014936.4738-1-sergey.senozhatsky@gmail.com> <20170825004947.GE29701@js1304-P5Q-DELUXE> <27EDD68A-61DC-42F1-8422-16B9AB9F0EB3@fb.com> <20170825051925.GB26819@blaptop> In-Reply-To: <20170825051925.GB26819@blaptop> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [2620:10d:c090:200::7:7b0a] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR15MB1114;20:gxIGqf0juBdHwlcpbRk6FLTIU71Miwun2Y006eEYnQ9hy8qDfY4HW2P3DcMHaorJ4Wxr8G5AFzGBc1cROnLnd7WdasKp3HMa6BH4qg8Ol1wredZ6LAkyH4Nnj+lAMUQgBAaO3JpdW5lH+HPRZh7PCHVKUkLdO8IzSOLRH66wJNA= x-ms-exchange-antispam-srfa-diagnostics: SSOS;SSOR; x-forefront-antispam-report: SFV:SKI;SCL:-1;SFV:NSPM;SFS:(10019020)(6009001)(51914003)(199003)(24454002)(189002)(52314003)(377454003)(8936002)(39060400002)(53936002)(83716003)(50986999)(6436002)(5660300001)(6506006)(105586002)(4326008)(6306002)(36756003)(6246003)(6512007)(54906002)(54356999)(2900100001)(76176999)(189998001)(2950100002)(110136004)(99286003)(6916009)(229853002)(6486002)(6116002)(77096006)(68736007)(14454004)(82746002)(305945005)(3280700002)(478600001)(33656002)(81166006)(102836003)(106356001)(8676002)(7736002)(86362001)(93886005)(53546010)(81156014)(25786009)(966005)(101416001)(97736004)(2906002)(3660700001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR15MB1114;H:DM5PR15MB1753.namprd15.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; x-ms-office365-filtering-correlation-id: eb6de5fb-d006-4edf-ccfa-08d4ebefd9f0 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(300000503095)(300135400095)(2017052603199)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:DM5PR15MB1114; x-ms-traffictypediagnostic: DM5PR15MB1114: x-exchange-antispam-report-test: UriScan:(58145275503218); 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)(93006095)(93001095)(10201501046)(6041248)(20161123564025)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123560025)(20161123555025)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:DM5PR15MB1114;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:DM5PR15MB1114; 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 19:31:15.0511 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 8ae927fe-1255-47a7-a2af-5f3a069daaa2 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR15MB1114 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_05:,, 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 v7PJVUUC018443 Content-Length: 2866 Lines: 64 On 8/24/17, 10:19 PM, "Minchan Kim" wrote: > On Fri, Aug 25, 2017 at 01:35:35AM +0000, Nick Terrell wrote: [..] > > I think using dictionaries in zram could be very interesting. We could for > > example, take a random sample of the RAM and use that as the dictionary > > for compression. E.g. take 32 512B samples from RAM and build a 16 KB > > dictionary (sizes may vary). > > For static option, could we create the dictionary with data in zram > and dump the dictionary into file. And then, rebuiling zram or kernel > includes the dictionary into images. > > For it, we would need some knob like > > cat /sys/block/zram/zstd_dict > dict.data > > CONFIG_ZSTD_DICT_DIR= > CONFIG_ZSTD_DICT_FILE= My guess is that a static dictionary won't cut it, since different workloads will have drastically different RAM contents, so we won't be able to construct a single dictionary that works for them all. I'd love to be proven wrong though. > For dynamic option, could we make the dictionary with data > in zram dynamically? So, upcoming pages will use the newly > created dictionary but old compressed pages will use own dictionary. Yeah thats totally possible on the compression side, we would just need to save which pages were compressed with which dictionary somewhere. > I'm not sure it's possible, anyway, if predefined dict can help > comp ratio a lot in 4K data, I really love the feature and will support > to have it. ;) > > > > > I'm not sure how you would pass a dictionary into the crypto compression > > API, but I'm sure we can make something work if dictionary compression > > proves to be beneficial enough. > > Yes, it would be better to integrate the feature crypto but Please, don't tie to > crypto API. If it's hard to support with current cypto API in short time, > I really want to support it with zcomp_zstd.c. > > Please look at old zcomp model. > http://elixir.free-electrons.com/linux/v4.7/source/drivers/block/zram/zcomp_lz4.c Thanks for the link, we could definitely make zcomp work with dictionaries. > > What data have you, or anyone, used for benchmarking compression ratio and > > speed for RAM? Since it is such a specialized application, the standard > > compression benchmarks aren't very applicable. > > I have used my image dumped from desktop swap device. > Of course, it doesn't cover all of cases in the world but it would be better > to use IO benchmark buffer, IMHO. :) Since adding dictionary support won't be quite as easy as adding zstd support, I think the first step is building a set of benchmarks that represent some common real world scenarios. We can easily test different dictionary construction algorithms in userspace, and determine if the work will pay off for some workloads. I'll collect some RAM samples from my device and run some preliminary tests.