From owner-freebsd-fs@FreeBSD.ORG Wed Dec 12 14:20:01 2012 Return-Path: Delivered-To: freebsd-fs@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 60C6698C; Wed, 12 Dec 2012 14:20:01 +0000 (UTC) (envelope-from olavgg@gmail.com) Received: from mail-gh0-f182.google.com (mail-gh0-f182.google.com [209.85.160.182]) by mx1.freebsd.org (Postfix) with ESMTP id 086E08FC13; Wed, 12 Dec 2012 14:20:00 +0000 (UTC) Received: by mail-gh0-f182.google.com with SMTP id z15so143290ghb.13 for ; Wed, 12 Dec 2012 06:19:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=iGAH3i73fuGXzFMmSM0DKPxjb3dlDIrRXEtxTrx8NF0=; b=yTmRR6NUv8X5TIPMsL6KZrgbtMVyNKXr4fxsl7wUcnGNBYnuO+uWOX/shk2jpX8NwY 41pH/N9uu9QbaKrDcX2S+XlhXPIIpCcWTxGjzxODXQvTx6t9ASCXcvd4iMKsQP9p5i0I jxzFRg3rxLcFGDvr6dD4og+eYsDnFOs4TBDG517seaK9ct1h11BmMEfTdhoUdgSPgJ60 acbIxiWxe13ISyaXeQOB6ecvtB7H7QrKz19/jlZXsbpdWv7AY53WzpSYHoS++x6j7B04 tyk0+XxjyHEXowir/XzELY1Z6KOjqqgnIr4qVCq9aTLwLberNxiih6SfMvgCLL2dX7Ku qkyg== MIME-Version: 1.0 Received: by 10.58.48.231 with SMTP id p7mr603571ven.11.1355321998719; Wed, 12 Dec 2012 06:19:58 -0800 (PST) Received: by 10.58.254.195 with HTTP; Wed, 12 Dec 2012 06:19:58 -0800 (PST) Date: Wed, 12 Dec 2012 15:19:58 +0100 Message-ID: Subject: find vs ls performance for walking folders, are there any faster options? From: =?ISO-8859-1?Q?Olav_Gr=F8n=E5s_Gjerde?= To: freebsd-performance@freebsd.org, freebsd-fs@freebsd.org Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Dec 2012 14:20:01 -0000 I'm working on scanning filesystems to build a file search engine and came over something interesting. I can walk through 300 000 folders in ~19.5seconds with this command: ls -Ra | grep -e "./.*:" | sed "s/://" With find, it surprisingly takes ~50.5 seconds.: find . -type d My results are based on five runs of each command to warm up the disk cache. I've tried both this with both UFS and ZFS, and both filesystems shows the same speed difference. On a modern Linux distribution(Ubuntu 12.10 with EXT4), ls is just slight faster than find(about 15-20%). Are there a faster way to walk folders on FreeBSD? Are there some options(sysctl) I could tune to improve the performance?