all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [bug#67238] [PATCH] derivations: Avoid readlink syscalls in read-derivation-from-file.
@ 2023-11-17 11:35 Christopher Baines
  2023-11-24 11:28 ` Ludovic Courtès
  0 siblings, 1 reply; 3+ messages in thread
From: Christopher Baines @ 2023-11-17 11:35 UTC (permalink / raw)
  To: 67238
  Cc: Christopher Baines, Josselin Poiret, Ludovic Courtès,
	Mathieu Othacehe, Ricardo Wurmus, Simon Tournier,
	Tobias Geerinckx-Rice

strace -c reports over 10,000 readlink syscalls when reading the derivation
for the hello package. By just setting the %file-port-name-canonicalization
fluid, this drops to less than 10.

I'm not sure if this actually improves performance, but doing less is surely
better.

* guix/derivations.scm (read-derivation-from-file): Set
%file-port-name-canonicalization to 'none when calling call-with-input-file.

Change-Id: I1ff16a059160576a576f2e9ed881379596e66af3
---
 guix/derivations.scm | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/guix/derivations.scm b/guix/derivations.scm
index 9fec7f4f0b..e6ecb570c4 100644
--- a/guix/derivations.scm
+++ b/guix/derivations.scm
@@ -556,7 +556,12 @@ (define (read-derivation-from-file file)
   ;; and because the same argument is read more than 15 times on average
   ;; during something like (package-derivation s gdb).
   (or (and file (hash-ref %derivation-cache file))
-      (let ((drv (call-with-input-file file read-derivation)))
+      (let ((drv
+             ;; Avoid calling scm_i_relativize_path in
+             ;; fport_canonicalize_filename since this leads to lots of
+             ;; readlink calls
+             (with-fluids ((%file-port-name-canonicalization 'none))
+               (call-with-input-file file read-derivation))))
         (hash-set! %derivation-cache file drv)
         drv)))
 

base-commit: e35b7c5386c1bfacf47ed31bac9b503373dd26fc
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [bug#67238] [PATCH] derivations: Avoid readlink syscalls in read-derivation-from-file.
  2023-11-17 11:35 [bug#67238] [PATCH] derivations: Avoid readlink syscalls in read-derivation-from-file Christopher Baines
@ 2023-11-24 11:28 ` Ludovic Courtès
  2023-11-25 20:58   ` bug#67238: " Christopher Baines
  0 siblings, 1 reply; 3+ messages in thread
From: Ludovic Courtès @ 2023-11-24 11:28 UTC (permalink / raw)
  To: Christopher Baines
  Cc: Josselin Poiret, Tobias Geerinckx-Rice, Simon Tournier,
	Mathieu Othacehe, 67238, Ricardo Wurmus, Christopher Baines

Hi,

Christopher Baines <mail@cbaines.net> skribis:

> strace -c reports over 10,000 readlink syscalls when reading the derivation
> for the hello package. By just setting the %file-port-name-canonicalization
> fluid, this drops to less than 10.
>
> I'm not sure if this actually improves performance, but doing less is surely
> better.
>
> * guix/derivations.scm (read-derivation-from-file): Set
> %file-port-name-canonicalization to 'none when calling call-with-input-file.
>
> Change-Id: I1ff16a059160576a576f2e9ed881379596e66af3

[...]

> +      (let ((drv
> +             ;; Avoid calling scm_i_relativize_path in
> +             ;; fport_canonicalize_filename since this leads to lots of
> +             ;; readlink calls
> +             (with-fluids ((%file-port-name-canonicalization 'none))
> +               (call-with-input-file file read-derivation))))

This is already done in ‘run-guix’ in (guix ui), for all the ‘guix’
commands (so this patch would be a slight performance regression for
Guix itself).

I’d suggest setting this fluid globally in applications that use Guix
(the Build Coordinator, etc.), as is done in Guix itself.

WDYT?

Ludo’.




^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#67238: [PATCH] derivations: Avoid readlink syscalls in read-derivation-from-file.
  2023-11-24 11:28 ` Ludovic Courtès
@ 2023-11-25 20:58   ` Christopher Baines
  0 siblings, 0 replies; 3+ messages in thread
From: Christopher Baines @ 2023-11-25 20:58 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 67238-close

[-- Attachment #1: Type: text/plain, Size: 1417 bytes --]


Ludovic Courtès <ludo@gnu.org> writes:

> Hi,
>
> Christopher Baines <mail@cbaines.net> skribis:
>
>> strace -c reports over 10,000 readlink syscalls when reading the derivation
>> for the hello package. By just setting the %file-port-name-canonicalization
>> fluid, this drops to less than 10.
>>
>> I'm not sure if this actually improves performance, but doing less is surely
>> better.
>>
>> * guix/derivations.scm (read-derivation-from-file): Set
>> %file-port-name-canonicalization to 'none when calling call-with-input-file.
>>
>> Change-Id: I1ff16a059160576a576f2e9ed881379596e66af3
>
> [...]
>
>> +      (let ((drv
>> +             ;; Avoid calling scm_i_relativize_path in
>> +             ;; fport_canonicalize_filename since this leads to lots of
>> +             ;; readlink calls
>> +             (with-fluids ((%file-port-name-canonicalization 'none))
>> +               (call-with-input-file file read-derivation))))
>
> This is already done in ‘run-guix’ in (guix ui), for all the ‘guix’
> commands (so this patch would be a slight performance regression for
> Guix itself).
>
> I’d suggest setting this fluid globally in applications that use Guix
> (the Build Coordinator, etc.), as is done in Guix itself.
>
> WDYT?

Ah, I didn't realise it was already set for Guix scripts. But yeah,
setting it in other places that read derivations makes sense.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 987 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-11-25 21:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-17 11:35 [bug#67238] [PATCH] derivations: Avoid readlink syscalls in read-derivation-from-file Christopher Baines
2023-11-24 11:28 ` Ludovic Courtès
2023-11-25 20:58   ` bug#67238: " Christopher Baines

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.