From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id 6MqsBM1U5mCE7gAAgWs5BA (envelope-from ) for ; Thu, 08 Jul 2021 03:28:45 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id 2DdZAM1U5mBrNAAA1q6Kng (envelope-from ) for ; Thu, 08 Jul 2021 01:28:45 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id DBB572A716 for ; Thu, 8 Jul 2021 03:28:43 +0200 (CEST) Received: from localhost ([::1]:36786 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m1IqI-0001j2-KB for larch@yhetil.org; Wed, 07 Jul 2021 21:28:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41876) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1Ify-0001XS-QB for guix-patches@gnu.org; Wed, 07 Jul 2021 21:18:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:42292) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m1Ify-0001tS-IC for guix-patches@gnu.org; Wed, 07 Jul 2021 21:18:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1m1Ify-00073x-8v for guix-patches@gnu.org; Wed, 07 Jul 2021 21:18:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#49107] [PATCH core-updates] gnu: fontconfig: Use (locally) deterministic caching Resent-From: Sarah Morgensen Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 08 Jul 2021 01:18:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 49107 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 49107@debbugs.gnu.org Received: via spool by 49107-submit@debbugs.gnu.org id=B49107.162570705726546 (code B ref 49107); Thu, 08 Jul 2021 01:18:02 +0000 Received: (at 49107) by debbugs.gnu.org; 8 Jul 2021 01:17:37 +0000 Received: from localhost ([127.0.0.1]:53838 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m1IfZ-0006tg-6l for submit@debbugs.gnu.org; Wed, 07 Jul 2021 21:17:37 -0400 Received: from out2.migadu.com ([188.165.223.204]:60691) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m1IfW-0006r6-VD for 49107@debbugs.gnu.org; Wed, 07 Jul 2021 21:17:36 -0400 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mgsn.dev; s=key1; t=1625707053; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=snAVT6g0nZXuzgjQLbY+YAdlJFIUIVPiQoQGD04OPCs=; b=UvKx1s2UCOR50WPTb4O0YXz4v6gPnDfgptAB2VNkrILzB5p6jSUFNa5AW0ba1yElqatSYI iEXLeWxHVvh7l60a9JVpcMNB8ZZH9Oeh/U3yECVE2L/w428B1WuBJyWmomSeVBADFA+UfP hGpepdZfuIEJ2kFjmJpdKGcIHCYafOg= References: <87sg0pomee.fsf@gnu.org> Date: Wed, 07 Jul 2021 18:17:30 -0700 In-Reply-To: <87sg0pomee.fsf@gnu.org> ("Ludovic =?UTF-8?Q?Court=C3=A8s?="'s message of "Wed, 07 Jul 2021 23:16:09 +0200") Message-ID: <86eec9k3it.fsf_-_@mgsn.dev> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Migadu-Auth-User: iskarian@mgsn.dev X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" Reply-to: Sarah Morgensen X-ACL-Warn: , Sarah Morgensen via Guix-patches From: Sarah Morgensen via Guix-patches via X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1625707724; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=snAVT6g0nZXuzgjQLbY+YAdlJFIUIVPiQoQGD04OPCs=; b=oxGyQz53I5vXffK8qD1qTqUE7ueIFMT2Z/FxFKm/r2JTCP4ao32ppcUubvz7avgSwdYyZx hZYuMBWnnUZsEkf6LlZ/AiHk543hjxsbFMH6FwkSCol4E39FXjZbHk/kTlk/jNoFtHKhiD j7tsfOxo2OS5XhHxvbr4sQI2wag4UHPJkFqY1OMkrkRw/dQYS27NGghGzcLwzI+MUTIz02 JNqlRKFLPQuBAVOBxsepRi4tc2pVh1jCZsoG/5PiO7Fr92WZlS7eVnOQ+d9P3BkxWsK7dK XNH732goDoHdpdTiPmv30CO8dU9hiZzp83+hiMll3vwaIUzNnRVxTVwkwy1Wgg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1625707724; a=rsa-sha256; cv=none; b=LtaKcqnJNt0ChOnfw3qIvuEp1YdvdIJCQI9KV2SoKoJRXMuQkILyy8Or2qrosNK6nl0LfT hGlrR8s/rwPfawK11ZiUk3tf0IJsjFtQ0NYyx5ioY/PsyK2/SYiyx5gWMdyq0bpEBfygp0 dpjmdNTIk+4RRYQ1UoVAQncqja7e+LG3lePkiAmdCOJN44e/MEE4/kIc1TIrZG71bemeSv N7ohP0zGo4zu6i54NuibRO0yQA3R+DXPv7hYzPVtHRdJwd81H+P1pDaJor08b4p3TWzAml bhYS7mm5fl88KFifHnH2FYG8cWv/aMycwEmxOjYEL80l0iaQiC1ZqTO6j1t3uQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=mgsn.dev header.s=key1 header.b=UvKx1s2U; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Spam-Score: -2.91 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=mgsn.dev header.s=key1 header.b=UvKx1s2U; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Queue-Id: DBB572A716 X-Spam-Score: -2.91 X-Migadu-Scanner: scn1.migadu.com X-TUID: yoHDQ4kWK+T9 Hello, Thanks for taking a look at this. Ludovic Court=C3=A8s writes: >> Fontconfig usually uses a directory's mtime as its checksum. However, wh= en >> fontconfig detects a "broken mtime" filesystem, it will generate a direc= tory >> checksum from the directory listing contents. This is slightly slower, a= s it has >> to stat all the files in all font directories. Unconditionally enabling = this >> mode should get us more regular behavior. > > Nice, sounds like an improvement! > > Does Fontconfig stats all these files every time an application starts? > Did you compare =E2=80=98strace -c some app=E2=80=99 with and without thi= s change, to > get an idea of what it costs? I *believe* it does so whenever an application calls FcFontList or such, which is usually on startup. I haven't done tracing with an application that actually uses FcFontList, but I just now ran a naive test, along the lines of: $ fc-cache -rf $ strace -c fc-list The old fc-list: --8<---------------cut here---------------start------------->8--- % time seconds usecs/call calls errors syscall ------ ----------- ----------- --------- --------- ---------------- 28.50 0.000226 0 228 142 openat 22.19 0.000176 1 136 26 access 11.10 0.000088 0 133 70 stat 5.93 0.000047 0 86 close 5.55 0.000044 2 22 fstatfs 5.30 0.000042 0 54 37 readlink 4.54 0.000036 4 8 munmap 3.78 0.000030 0 70 mmap 2.65 0.000021 1 20 write 2.52 0.000020 0 104 read 2.52 0.000020 0 40 fstat 1.89 0.000015 1 8 fadvise64 1.77 0.000014 1 10 getpid 0.88 0.000007 0 10 brk 0.63 0.000005 0 35 getrandom 0.25 0.000002 2 1 1 ioctl 0.00 0.000000 0 15 mprotect 0.00 0.000000 0 2 rt_sigaction 0.00 0.000000 0 1 rt_sigprocmask 0.00 0.000000 0 1 execve 0.00 0.000000 0 1 arch_prctl 0.00 0.000000 0 1 futex 0.00 0.000000 0 4 getdents64 0.00 0.000000 0 1 set_tid_address 0.00 0.000000 0 1 set_robust_list 0.00 0.000000 0 1 prlimit64 ------ ----------- ----------- --------- --------- ---------------- 100.00 0.000793 0 993 276 total --8<---------------cut here---------------end--------------->8--- And the patched fc-list: --8<---------------cut here---------------start------------->8--- % time seconds usecs/call calls errors syscall ------ ----------- ----------- --------- --------- ---------------- 17.19 0.000125 0 126 11 access 14.44 0.000105 0 126 52 openat 12.24 0.000089 1 55 mmap 10.32 0.000075 0 99 read 8.67 0.000063 4 15 mprotect 8.25 0.000060 0 94 6 newfstatat 5.50 0.000040 0 74 close 5.23 0.000038 0 58 40 readlink 4.68 0.000034 34 1 set_tid_address 3.30 0.000024 0 38 getrandom 3.16 0.000023 1 13 pread64 1.65 0.000012 0 26 getdents64 1.51 0.000011 1 9 brk 1.10 0.000008 4 2 rt_sigaction 0.83 0.000006 0 9 munmap 0.55 0.000004 4 1 rt_sigprocmask 0.55 0.000004 4 1 prlimit64 0.41 0.000003 3 1 arch_prctl 0.41 0.000003 3 1 set_robust_list 0.00 0.000000 0 20 write 0.00 0.000000 0 1 1 ioctl 0.00 0.000000 0 1 execve 0.00 0.000000 0 1 sysinfo 0.00 0.000000 0 11 fstatfs 0.00 0.000000 0 8 fadvise64 ------ ----------- ----------- --------- --------- ---------------- 100.00 0.000727 0 791 110 total --8<---------------cut here---------------end--------------->8--- Now that is unexpected! There are actually less stats and opens. I'm stumped! My profile has about 20 font packages (about 450 actual files) installed. For reference, for both versions, `fc-cache -rf` yields about 3700 stats; and `fc-cache` yeilds about 300... I suppose I should be more careful about speaking from theory! > >> I am not confident this method is fully deterministic; particular filesy= stem >> capabilities may still be an implicit imput in the checksums. This shoul= d only >> matter when distributing pre-generated caches. >> >> Fontconfig does honor SOURCE_DATE_EPOCH, but without a reliable mtime, >> fontconfig has no way of knowing when to update such a cache. SOURCE_DAT= E_EPOCH >> is now disabled for the tests because they assume working cache invalida= tion. > > So tests fail is we leave SOURCE_DATE_EPOCH, right? Correct. > Thanks for addressing this longstanding issue! (And apologies for the > delay=E2=80=A6 Now=E2=80=99s a good time to get semi-high-level changes = like this one > in =E2=80=98core-updates=E2=80=99.) I still wish we could address it "properly" by generating a cache at profile generation time... but it looks like fontconfig embeds the full paths of fonts in the cache (including username, since fonts are under ~/.guix-profile), so I doubt such a cache would work. I plan to try it eventually anyway (or perhaps someone else will), but in the meantime, this looks like the 80% solution. -- Sarah