Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp495312pxb; Sat, 20 Feb 2021 10:32:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJxaHzF8Iao+yaROoIUxw7k0teL7ZWQrp6gRUe8cQbmjjl46uXwyT2EO0ouYEXeK8fLe7v32 X-Received: by 2002:a05:6402:558:: with SMTP id i24mr15280805edx.190.1613845946086; Sat, 20 Feb 2021 10:32:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613845946; cv=none; d=google.com; s=arc-20160816; b=VnFknvs5f+NQKTt6synYX2cMfsiLyXj5KgvBtr9rh7cGGg6UNmLqLROQcW3Ld4QiWb ab1U3OXvlNttN4g3tEmq01AReVeaIXFV5k/CKILHf3Y0d7H28nigSnP16rExfGCdsUG2 BkR0aFRzB93Khx2fQGBxx7KwAsbeFrTm5+UtRE1DbOJxtzLSFjnyqg8p7b3KkodNQMcx Y8XzHro0RiZOOfKo0v48n4zl91feXnqQVuSrCyNLn5Sv16hPONc735aJko6+W6r0hezZ zK+lhMPuHE6p+KvPHzZFiZEdCtUPOoby6vtQxV+HKwJexgFNgNVPxIQKMFrPwii2JeDM SlhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=lD1HcC1ElSe3/B3EukUgF8uLAM755FrCoJcF7E1w+VI=; b=H7PK/LM9aY7SveLmjU8z+CFbE9nhRDtFNXsShSr7T8DuUKEO5n3qIR0Jg/LvssUFYt uFmwfGxRuIFb7bFVX0rqKFFuM/3cGVebsaBYs0GShUmizNPgW5oVxCKmjtD9ZA1qkb18 zSY/3cKUF2oesuI3XF3XWnBqfjjdi69kjaHJ+jv1vb5vv1XgrfNCDJ1PAzN102LL30cP l//EWCumFtcerm6dq5U908KOj0SxM78/CqLGEy5vaHQJWZK65y5KKocCcs5rCLnsCKm/ yW0dpjmv6NEYA6GFjpK7bTCWxNrMV2oINWx8VRC1EZsYqg+bSj/d54jWSt2w9WF1eNKR upyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b=OerchFwb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c15si8549414ede.341.2021.02.20.10.32.02; Sat, 20 Feb 2021 10:32:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b=OerchFwb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229891AbhBTSaJ (ORCPT + 99 others); Sat, 20 Feb 2021 13:30:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229784AbhBTSaF (ORCPT ); Sat, 20 Feb 2021 13:30:05 -0500 Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4AB57C061574 for ; Sat, 20 Feb 2021 10:29:25 -0800 (PST) Received: by mail-pl1-x635.google.com with SMTP id f8so5203217plg.5 for ; Sat, 20 Feb 2021 10:29:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=lD1HcC1ElSe3/B3EukUgF8uLAM755FrCoJcF7E1w+VI=; b=OerchFwb+SiCsbkWSYvotE2x7oT7AA/otmhLaADzu8OSe8CjWrpFJGFHSC1ibVH543 uzLtl1jvaoGW7UNZyHgVtpCS56yHv2wG9i9egultmIEIemmRxJcZhuFiennkEDUGL4gH HK0ScbpeX6AUM1hFtHEHFWc4CfI+ueLDiJGF+lNNwtii8xzqj7L9zqc0PSxSqY4ZuC6N uVBjG2VPfFGEo8Qo7R23saPe1d6V1ZN6ItUbpq9ntQRvglTpVN2S1CjOP4kx9Le5meN6 cqpRBTLAENvOvggfgQBAH4Ui5IBzOwIFJtHQ0I2EolBXa68HTOz5HLK8Jm68b1VkplkS Sn0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=lD1HcC1ElSe3/B3EukUgF8uLAM755FrCoJcF7E1w+VI=; b=BAc175SU9TrV6VsSEMY8ZbTFxBdS+qJ95SL4i+P2OpK7Xqa8uOFtAh0xSwjZzdBSxD D+OxWWqtcKAouOA4iO+7AsEqcLsyzmTMCoePfOH1s8MmEDOso4LD9t+4qdCo9ZUoVUWo 8BYsAkVHg0Upe+vmR+ffEtI/L/kyhSpQK0LNRetD54J7YCXbqBaO30BYd/lJBcSWXu3M GSYMsfmRCRDiGMvpLeTMCPpm1fLyGfdu1R09ApTQGpZ+UMKXxjq1uVJ3NHVXkcLjSGoM 0T4px3y63XFdsT7OhCHwLywUa1TAg2eoX6Y8LoBGHqrGdcYO5Pg70VpTiZgmYN3WiSSm V48Q== X-Gm-Message-State: AOAM531hWW60wL945AhheJpLxNx/w0Np8G96lpI0NPuzmcZ2+2EaGpdT vL3NlEEb3n56bwGhg1HwXlNc3CIVocpS1w== X-Received: by 2002:a17:90b:4d06:: with SMTP id mw6mr14537620pjb.24.1613845764688; Sat, 20 Feb 2021 10:29:24 -0800 (PST) Received: from [192.168.1.134] ([66.219.217.173]) by smtp.gmail.com with ESMTPSA id gk17sm12425342pjb.4.2021.02.20.10.29.23 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 20 Feb 2021 10:29:24 -0800 (PST) Subject: Re: [PATCH v3 0/2] io_uring: add support for IORING_OP_GETDENTS To: David Laight , 'Lennert Buytenhek' , Al Viro , "linux-kernel@vger.kernel.org" , "linux-fsdevel@vger.kernel.org" , "io-uring@vger.kernel.org" Cc: Matthew Wilcox References: <20210218122640.GA334506@wantstofly.org> <247d154f2ba549b88a77daf29ec1791f@AcuMS.aculab.com> From: Jens Axboe Message-ID: <28a71bb1-0aac-c166-ade7-93665811d441@kernel.dk> Date: Sat, 20 Feb 2021 11:29:22 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <247d154f2ba549b88a77daf29ec1791f@AcuMS.aculab.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2/20/21 10:44 AM, David Laight wrote: > From: Lennert Buytenhek >> Sent: 18 February 2021 12:27 >> >> These patches add support for IORING_OP_GETDENTS, which is a new io_uring >> opcode that more or less does an lseek(sqe->fd, sqe->off, SEEK_SET) >> followed by a getdents64(sqe->fd, (void *)sqe->addr, sqe->len). >> >> A dumb test program for IORING_OP_GETDENTS is available here: >> >> https://krautbox.wantstofly.org/~buytenh/uringfind-v2.c >> >> This test program does something along the lines of what find(1) does: >> it scans recursively through a directory tree and prints the names of >> all directories and files it encounters along the way -- but then using >> io_uring. (The io_uring version prints the names of encountered files and >> directories in an order that's determined by SQE completion order, which >> is somewhat nondeterministic and likely to differ between runs.) >> >> On a directory tree with 14-odd million files in it that's on a >> six-drive (spinning disk) btrfs raid, find(1) takes: >> >> # echo 3 > /proc/sys/vm/drop_caches >> # time find /mnt/repo > /dev/null >> >> real 24m7.815s >> user 0m15.015s >> sys 0m48.340s >> # >> >> And the io_uring version takes: >> >> # echo 3 > /proc/sys/vm/drop_caches >> # time ./uringfind /mnt/repo > /dev/null >> >> real 10m29.064s >> user 0m4.347s >> sys 0m1.677s >> # > > While there may be uses for IORING_OP_GETDENTS are you sure your > test is comparing like with like? > The underlying work has to be done in either case, so you are > swapping system calls for code complexity. What complexity? > I suspect that find is actually doing a stat() call on every > directory entry and that your io_uring example is just believing > the 'directory' flag returned in the directory entry for most > modern filesystems. While that may be true (find doing stat as well), the runtime is clearly dominated by IO. Adding a stat on top would be an extra copy, but no extra IO. > If you write a program that does openat(), readdir(), close() > for each directory and with a long enough buffer (mostly) do > one readdir() per directory you'll get a much better comparison. > > You could even write a program with 2 threads, one does all the > open/readdir/close system calls and the other does the printing > and generating the list of directories to process. > That should get the equivalent overlapping that io_uring gives > without much of the complexity. But this is what take the most offense to - it's _trivial_ to write that program with io_uring, especially compared to managing threads. Threads are certainly a more known paradigm at this point, but an io_uring submit + reap loop is definitely not "much of the complexity". If you're referring to the kernel change itself, that's trivial, as the diffstat shows. -- Jens Axboe