From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: master afc0bfd380: Speed up loaddefs-generate on slow disks Date: Fri, 03 Jun 2022 08:52:27 +0300 Message-ID: <838rqee1k4.fsf@gnu.org> References: <165416120601.23485.9799765950267646757@vcs2.savannah.gnu.org> <20220602091326.514E9C009A8@vcs2.savannah.gnu.org> <87a6avccs4.fsf@gnus.org> <83r147dosf.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="38818"; mail-complaints-to="usenet@ciao.gmane.io" Cc: larsi@gnus.org, emacs-devel@gnu.org, eggert@cs.ucla.edu To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Jun 03 07:53:29 2022 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nx0FU-0009tF-MW for ged-emacs-devel@m.gmane-mx.org; Fri, 03 Jun 2022 07:53:28 +0200 Original-Received: from localhost ([::1]:59264 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nx0FT-0007J3-6u for ged-emacs-devel@m.gmane-mx.org; Fri, 03 Jun 2022 01:53:27 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:48752) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nx0EL-0006cW-Az for emacs-devel@gnu.org; Fri, 03 Jun 2022 01:52:17 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:47940) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nx0EJ-0003RB-Vp; Fri, 03 Jun 2022 01:52:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=z8pegeimeU5K9M7SR9Y057jfZ1vlc0aU6NXNU80bhs8=; b=JTRsj1SnKiAH I5r2Sp0gKgFg9pCBbUHHSOgRAw9AMLLPvaQcNY1QfFrogUWPgWvL4/+3Zw5w5ReNgL3KJ1mHoWSnu RfvwVRUYux0jjGkCCMOzE99C68+u3LY1zPO6gcqrk7G6dVrm8S6WAzsQyv5Nl0fhoyXaXYat8U+m1 xvf+k0pEHeIZQNXxuqg+/EZ5RVgrO5B6l5QFyL/Q+exj3vJBc/LRCcBL4oiobyVdIFBAFllFKB1q+ 9SwfAMJXlESkPFpxBn3XKU4XB+xIYruokIu7PapsmfS3PgFa1J0DT6qAF6j61kg0sQjQ2tSgNdcvH 0C0rtaMsBBmn3gLxwuSX9w==; Original-Received: from [87.69.77.57] (port=1856 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nx0EJ-0006D6-EV; Fri, 03 Jun 2022 01:52:15 -0400 In-Reply-To: (message from Stefan Monnier on Thu, 02 Jun 2022 21:18:57 -0400) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:290595 Archived-At: > From: Stefan Monnier > Cc: Lars Ingebrigtsen , emacs-devel@gnu.org, > eggert@cs.ucla.edu > Date: Thu, 02 Jun 2022 21:18:57 -0400 > > Eli Zaretskii [2022-06-02 19:16:00] wrote: > >> > I'm really surprised this is faster, even on slow disks. > >> > Does anyone have a idea of why that is? > > Isn't that clear? file-newer-than-file-p calls 'stat' for both files, > > and one of them is a loop invariant AFAIU. Taking its time outside > > the loop speeds up things (but perhaps not on GNU/Linux). > > Under GNU/Linux, I'd expect `stat` to be significantly faster than > `file-attributes` (and the extra `stat` on the loop-invariant file > should be especially fast since it should be as close as it gets w.r.t > the caches (both OS-level and CPU-level)). Yes, when 'stat' is a syscall. On Windows, we issue at least 6 syscalls, more so if the file is on a networked volume. > >> I didn't actually benchmark it -- either way is fast on my laptop. But > >> the old autoloads code did it with time-less-p, and Eli said that it was > >> faster, so... Perhaps Eli can report back whether it made a difference > >> or not. > > It did -- for the better. Thanks. > > This suggests that the kind of change I suggested would make it even > a bit faster, tho it should reduce the run time by less than 50% > under Windows (because the time to do the `stat`s is apparently already > >50% of the total). I don't know how you deduce the 50% figure. Look at w32.c:stat_worker to see what we do on Windows to faithfully emulate 'stat' -- I have no idea how this compares with the time required to cons a Lisp data structure from the data, but it can well be that consing is much faster. The only sure way is to benchmark both alternatives.