Re: bug#27476: guix pull fails on powerful server

2019-01-29 Thread Ricardo Wurmus


Ludovic Courtès  writes:

> l...@gnu.org (Ludovic Courtès) skribis:
>
>> I can’t reproduce this with current Guile ‘stable-2.2’, following Andy’s
>> weak-table rewrite¹, so this might have been a weak-table bug showing up
>> under memory pressure.
>
> With Guile 2.2.3 a similar program triggers a crash very quickly:
>
> --8<---cut here---start->8---
> $ cat ../guile-debugging/syntax-parms.scm
> (use-modules (ice-9 threads)
>  (srfi srfi-1)
>  (guix monads)
>  (guix store)
>  (system base compile))
>
> (compile #f)  ;load modules
>
> (define threads
>   (unfold (lambda (x) (> x 100))
>   (lambda (x)
> (call-with-new-thread
>  (lambda ()
>(while #t
>  (compile
>   '(mlet %store-monad ((x y))
>  (mbegin %store-monad
>(return x)
>(return y)))
>   #:env (current-module)
>   #:from 'scheme
>   #:to 'tree-il)
>   1+
>   0))
>
> (for-each join-thread threads)
[…]
> --8<---cut here---end--->8---

I tried this with guile 2.2.4 on my laptop with 4 CPUs (according to
lscpu) and I did not get a crash even after waiting for several minutes.

--
Ricardo




Re: bug#27476: guix pull fails on powerful server

2018-04-30 Thread Ludovic Courtès
l...@gnu.org (Ludovic Courtès) skribis:

> I can’t reproduce this with current Guile ‘stable-2.2’, following Andy’s
> weak-table rewrite¹, so this might have been a weak-table bug showing up
> under memory pressure.

With Guile 2.2.3 a similar program triggers a crash very quickly:

--8<---cut here---start->8---
$ cat ../guile-debugging/syntax-parms.scm 
(use-modules (ice-9 threads)
 (srfi srfi-1)
 (guix monads)
 (guix store)
 (system base compile))

(compile #f)  ;load modules

(define threads
  (unfold (lambda (x) (> x 100))
  (lambda (x)
(call-with-new-thread
 (lambda ()
   (while #t
 (compile
  '(mlet %store-monad ((x y))
 (mbegin %store-monad
   (return x)
   (return y)))
  #:env (current-module)
  #:from 'scheme
  #:to 'tree-il)
  1+
  0))

(for-each join-thread threads)
$ guile --version
guile (GNU Guile) 2.2.3
Copyright (C) 2017 Free Software Foundation, Inc.

License LGPLv3+: GNU LGPL 3 or later .
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
$ guile ../guile-debugging/syntax-parms.scm 
In ice-9/psyntax.scm:
  2338:44 19 (expand-let _ _ _ #f _ # _ _ _)
  1679:45 18 (parse _ _ _ _ _ _ _)
In ice-9/boot-9.scm:
   222:17 17 (map1 ("-" "1dff1b83541ce327" "-" "2ad70"))
In ice-9/psyntax.scm:
  1679:45 16 (parse _ _ _ _ _ _ _)
In ice-9/boot-9.scm:
   222:17 15 (map1 ((#(ribcage () () ()) #(ribcage () () ()) #(ribcage 
#(unused-value) #((m-1dff1b83541ce327-29a7a top)) 
#("l-1dff1b83541ce327-2bce9")) #(ribcage () () ()) # …)))
In ice-9/psyntax.scm:
  1484:23 14 (_ _ _)
In ice-9/boot-9.scm:
   222:29 13 (map1 _)
   222:17 12 (map1 ("-" "2bd28"))
In ice-9/psyntax.scm:
  1789:11 11 (lp _ ())
  1679:45 10 (parse _ _ _ _ _ _ _)
In ice-9/boot-9.scm:
   222:17  9 (map1 ((expand-1dff1b83541ce327-2bd31) (#) …))
In ice-9/psyntax.scm:
  1679:45  8 (parse _ _ _ _ _ _ _)
In ice-9/boot-9.scm:
   222:17  7 (map1 ((m-1dff1b83541ce327-2bcf4 top)))
In ice-9/psyntax.scm:
  1484:23  6 (_ _ _)
In ice-9/boot-9.scm:
   222:17  5 (map1 (#))
In ice-9/psyntax.scm:
  1407:23  4 (_ _)
  1317:39  3 (syntax-type y (shift #(ribcage #(e) #((top)) 
#("l-680b775fb37a463-1343")) #(ribcage () () ()) #(ribcage #(xx) #((top)) 
#("l-680b775fb37a463-1340")) #(ribcage …)) # …)
   916:15  2 (resolve-identifier y (#>=> # 
#)>) (shift #(ribcage #(e) #((top)) #("l-680b775fb37a463-1343")) 
#(ribcage () () #) …) …)
   833:21  1 (id-var-name y _ _)
669:4  0 (search y (() #(ribcage () () ()) #(ribcage () () ()) #(ribcage () 
() ()) #(ribcage () () ())) (top) (hygiene guile-user))
ice-9/psyntax.scm:669:4: In procedure search:
In procedure vector-ref: Wrong type argument in position 1 (expecting vector): 
()
In ice-9/boot-9.scm:
   222:29 19 (map1 _)
   222:17 18 (map1 (#f))
In ice-9/psyntax.scm:
  1789:11 17 (lp _ ())
  1679:45 16 (parse _ _ _ _ _ _ _)
In ice-9/boot-9.scm:
   222:17 15 (map1 (() (m-1dff1b83541ce327-8f24e top)))
In ice-9/psyntax.scm:
  1679:45 14 (parse _ _ _ _ _ _ _)
In ice-9/boot-9.scm:
   222:17 13 (map1 ((m-1dff1b83541ce327-8fe71 top) shift #(ribcage #(e) 
#((top)) #("l-680b775fb37a463-1343")) #(ribcage () () ()) #(ribcage #(xx) 
#((top)) #("l-680b775fb3…")) #))
In ice-9/psyntax.scm:
  1409:12 12 (expand-expr _ _ _ (shift #(ribcage #(e) #((top)) 
#("l-680b775fb37a463-1343")) #(ribcage () () ()) #(ribcage #(xx) #((top)) 
#("l-680b775fb37a463-1340")) #(# # …)) # …)
  2054:19 11 (_ _ _ (m-1dff1b83541ce327-8fe71 top) ())
In ice-9/boot-9.scm:
   222:17 10 (map1 (# (# #)))
In ice-9/psyntax.scm:
  1409:12  9 (_ _)
  1789:11  8 (lp _ (#(ribcage () () ()) #(ribcage #(x) 
#((m-1dff1b83541ce327-8f383 top)) #("l-1dff1b83541ce327-8f40b")) #(ribcage () 
() ()) #(ribcage () () ()) #(ribcage # …) …))
  1679:45  7 (parse _ _ _ _ _ _ _)
In ice-9/boot-9.scm:
   222:17  6 (map1 (#(ribcage #(x) #((m-1dff1b83541ce327-8f383 top)) 
#("l-1dff1b83541ce327-8f40b")) #(ribcage () () ()) shift #(ribcage #(monad 
body) #((top) (top)) #("…" …)) …))
In ice-9/psyntax.scm:
  2702:67  5 (_ tmp-1dff1b83541ce327-8fa7a _ _)
 2646:111  4 (gen-clause # () 
(#(ribcage () () ()) #(ribcage #(x) #((m-1dff1b83541ce327-8f383 top)) 
#("l-1dff1b83541ce3…")) …) …)
  2607:69  3 (build-dispatch-call (("8fa7c" . 0)) "1dff1b83541ce327" # #((m-1dff1b83541ce327-8f383 top)) (#f 
#f () (#) # …))
In ice-9/boot-9.scm:
   222:17  2 (map1 ("8fa7c"))
In ice-9/psyntax.scm:
  2004:10  1 (gen-var _)
In unknown file:
   0 (symbol->string "8fa7c")
ERROR: In procedure symbol->string:
In procedure symbol->string: Wrong type argument in position 1 (expecting 
symbol): "8fa7c"
--8<---cut here---end--->8---

Ludo’.



Re: bug#27476: guix pull fails on powerful server

2017-11-07 Thread Ludovic Courtès
Hi,

Ricardo Wurmus  skribis:

> After limiting memory with “ulimit -Sv 500”:
>
> ice-9/threads.scm:289:22: In procedure loop:
> ice-9/threads.scm:289:22: Syntax error:
> guix/scripts/pull.scm:192:8: >>=: >>= (bind) used outside of 'with-monad' in 
> form (>>= (indirect-root-added latest) (lambda (done) (mlet* %store-monad () 
> (if (and (file-exists? latest) (string=? (readlink latest) source-dir)) 
> (begin (display (G_ "Guix already up to date\n")) (return #t)) (begin 
> (switch-symlinks latest source-dir) (format #t (G_ "updated ~a successfully 
> deployed under `~a'~%") %guix-package-name latest) (return #t))
>
> Some deprecated features have been used.  Set the environment
> variable GUILE_WARN_DEPRECATED to "detailed" and rerun the
> program to get more information.  Set it to "no" to suppress
> this message.
> builder for `/gnu/store/afji58647yzz7cr9dvlj87sd3ad36lbk-guix-latest.drv' 
> failed with exit code 1
> guix pull: error: build failed: build of 
> `/gnu/store/afji58647yzz7cr9dvlj87sd3ad36lbk-guix-latest.drv' failed
>
> It always crashes at around 69%.

This gave me an idea.  With this program:

--8<---cut here---start->8---
(use-modules (ice-9 threads)
 (srfi srfi-1)
 (guix monads)
 (guix store)
 (system base compile))

(compile #f)  ;load modules

(define threads
  (unfold (lambda (x) (> x 100))
  (lambda (x)
(call-with-new-thread
 (lambda ()
   (while #t
 (compile
  '(begin
 (with-monad %store-monad
   (>>= foo bar
(return 3)))
 (mlet %store-monad ((x y))
   (mbegin %store-monad
 (return x)
 (return y
  #:env (current-module)
  #:from 'scheme
  #:to 'tree-il)
  1+
  0))

(for-each join-thread threads)
--8<---cut here---end--->8---

I can reproduce the error:

--8<---cut here---start->8---
$ ulimit -Sv 200
$ guile syntax-parms.scm
In ice-9/psyntax.scm:
  1678:45 19 (parse _ _ _ _ _ _ _)
In ice-9/boot-9.scm:
   230:17 18 (map1 "placeholder" placeholder) ((#) . #) …) …)))
In ice-9/psyntax.scm:
  1483:23 17 (_ _ _)
In ice-9/boot-9.scm:
   230:29 16 (map1 (# # (#) (#))
   230:17 15 (map1 (# (#) (# #))
In ice-9/psyntax.scm:
  1788:11 14 (lp ((# # () # ((# #)) #)
  1678:45 13 (parse _ _ _ _ _ _ _)
In ice-9/boot-9.scm:
   230:17 12 (map1 "placeholder" placeholder) ("l-1dff1b83541ce327-67a3671" 
lexical . #) ("placeho…" …) …) …)))
In ice-9/psyntax.scm:
  1678:45 11 (parse _ _ _ _ _ _ _)
In ice-9/boot-9.scm:
   230:17 10 (map1 "placeholder" placeholder) ((#) . #) …) . #)))
In ice-9/psyntax.scm:
  2337:44  9 (expand-let _ _ _ #f (hygiene guile-user) # _ …)
  1678:45  8 (parse _ _ _ _ _ _ _)
In ice-9/boot-9.scm:
   230:17  7 (map1 "placeholder" placeholder) ("l-1dff1b83541ce327-67a37b2" 
lexical . #) ("placeho…" …) …) …)))
In ice-9/psyntax.scm:
  1678:45  6 (parse _ _ _ _ _ _ _)
In ice-9/boot-9.scm:
   230:17  5 (map1 "placeholder" placeholder) ((#) . #) …) …)))
In ice-9/psyntax.scm:
  1483:23  4 (_ _ _)
In ice-9/boot-9.scm:
   230:17  3 (map1 (# # (#) (#…>))
In ice-9/psyntax.scm:
  1406:23  2 (_ _)
  1347:32  1 (syntax-type ((# #)) 
(("placeholder" placeholder) ((#) . #) …) …)
  1558:32  0 (expand-macro # _ _ _ _ _ _)
ice-9/psyntax.scm:1558:32: In procedure expand-macro:
ice-9/psyntax.scm:1558:32: Syntax error:
unknown location: state-return: Wrong number of arguments in form 
((%store-monad %return))
In syntax-parms.scm:
15:17  9 (_)
In system/base/compile.scm:
255:6  8 (compile _ #:from _ #:to _ #:env _ #:opts _)
   183:32  7 (compile-fold (#) (begin 
(with-monad %store-monad (>>= …)) #) …)
In ice-9/boot-9.scm:
   2316:4  6 (save-module-excursion #)
In language/scheme/compile-tree-il.scm:
31:15  5 (_)
In ice-9/psyntax.scm:
  1233:22  4 (expand-top-sequence ((begin (with-monad %store-monad (>>= foo bar 
(return 3))) (mlet # ((…)) #))) _ …)
In ice-9/boot-9.scm:
   230:17  3 (map1 (# 
#))
In ice-9/psyntax.scm:
  1611:33  2 (parse "placeholder" placeholder) ((#) . #) …) . #)) …)
  1347:32  1 (syntax-type (>>= foo bar (return 3)) (("placeholder" placeholder) 
((#) . #) …) …)
  1558:32  0 (expand-macro # _ 
_ _ _ _ _)
ice-9/psyntax.scm:1558:32: In procedure expand-macro:
ice-9/psyntax.scm:1558:32: Syntax error:
unknown location: source expression failed to match any pattern
GC Warning: Failed to expand heap by 28770304 bytes
GC Warning: Failed to expand heap by 28770304 bytes
GC Warning: Failed to expand heap by 14385152 bytes
GC Warning: Out of Memory! Heap size: 919 MiB. Returning NULL!
Warning: Unwind-only `out-of-memory' exception; 

Re: bug#27476: guix pull fails on powerful server

2017-10-13 Thread Ricardo Wurmus

I tried it again after unsetting GUIX_PACKAGE_PATH, but the results are
just as bad:

--8<---cut here---start->8---
[rwurmus@murphy:~/guix] (338) $ unset GUIX_PACKAGE_PATH
[rwurmus@murphy:~/guix] (339) $ time ./pre-inst-env guix pull --url=$PWD
guile: warning: failed to install locale
warning: failed to install locale: Invalid argument
Updating from Git repository at '/home/rwurmus/guix'...
Building from Git commit d24c69d86670bfad0c6bb147162c918e9fcdccc2...
substitute: guile: warning: failed to install locale
substitute: warning: failed to install locale: Invalid argument
substitute: updating list of substitutes from 'https://mirror.hydra.gnu.org'... 
100.0%
The following derivation will be built:
   /gnu/store/q5sh4c1mfk396kixqdq8j0wdfwin4dsx-guix-latest.drv
copying and compiling to 
'/gnu/store/jzq053lg77shnysmhj4i2f2bngz2rr5b-guix-latest' with Guile 2.2.2...
loading...   25.8% of 640 filesrandom seed for tests: 1507928738
loading...   99.8% of 640 files
compiling... 14.4% of 640 filesIn thread:
ERROR: In procedure >>=: >>= (bind) used outside of 'with-monad'Error while 
printing exception.
compiling... 14.5% of 640 filesIn thread:
ERROR: In procedure return: return used outside of 'with-monad'Error while 
printing exception.
compiling... 17.3% of 640 filesIn thread:
ERROR: In procedure return: return used outside of 'with-monad'Error while 
printing exception.
compiling... 70.0% of 640 filesGC Warning: Repeated allocation of very 
large block (appr. size 28766208):
May lead to memory leak and poor performance
--8<---cut here---end--->8---

-- 
Ricardo

GPG: BCA6 89B6 3655 3801 C3C6  2150 197A 5888 235F ACAC
https://elephly.net




Re: bug#27476: guix pull fails on powerful server

2017-10-13 Thread Ricardo Wurmus

Hi Ludo,

> The patch below seems to fix the problem: (guix monads) has shared state
> (hash tables) used both at expansion-time and run-time, and it wasn’t
> protected.
>
> My hypothesis is that this was causing random memory corruption.  The
> weird thing, though, is that the errors we were getting were not so
> random.  Also, the load phase of ‘guix pull’ is sequential.
>
> Could you test it and report back?

This doesn’t seem to be enough to fix the problem.  I patched ~/guix and
ran “guix pull --url=$PWD” from ~/guix:

--8<---cut here---start->8---
[rwurmus@murphy:~/guix] (335) $ time ./pre-inst-env guix pull --url=$PWD
guile: warning: failed to install locale
warning: failed to install locale: Invalid argument
Updating from Git repository at '/home/rwurmus/guix'...
Building from Git commit d24c69d86670bfad0c6bb147162c918e9fcdccc2...
substitute: guile: warning: failed to install locale
substitute: warning: failed to install locale: Invalid argument
guix pull: warning: failed to load '(bimsb packages bioinformatics-nonfree)':
ERROR: no code for module (gnu packages zip)
guix pull: warning: failed to load '(bimsb packages staging)':
ERROR: no code for module (gnu packages zip)
substitute: updating list of substitutes from 'https://mirror.hydra.gnu.org'... 
100.0%
The following derivation will be built:
   /gnu/store/y54b92jj44li36743fgxzy0iagi6gb9n-guix-latest.drv
copying and compiling to 
'/gnu/store/p5zlw7fas26bickkqz4d68g8bxnjr14z-guix-latest' with Guile 2.2.2...
loading...   25.8% of 640 filesrandom seed for tests: 1507927861
loading...   99.8% of 640 files
compiling... 18.6% of 640 filesIn thread:
ERROR: In procedure return: return used outside of 'with-monad'Error while 
printing exception.
compiling... 70.0% of 640 files
--8<---cut here---end--->8---

The higher the percentage of completion, the slower this all gets.  It
hasn’t actually finished yet, even though it has been running for over
13 minutes.

--
Ricardo

GPG: BCA6 89B6 3655 3801 C3C6  2150 197A 5888 235F ACAC
https://elephly.net




Re: bug#27476: guix pull fails on powerful server

2017-10-13 Thread Ricardo Wurmus

Hi Ludo,

> Ricardo Wurmus  skribis:
>
>> The following derivation will be built:
>>/gnu/store/z5bhk17nxmdhvj0g4cy038p25mzh1gys-guix-latest.drv
>> copying and compiling to 
>> '/gnu/store/s3s7xlqa10mvf8v0ypxz8gzw3lcf1x5z-guix-latest' with Guile 2.2.2...
>> loading...   25.7% of 635 filesrandom seed for tests: 1506720257
>> loading...   99.8% of 635 files
>> compiling... 69.1% of 635 filesice-9/threads.scm:289:22: In procedure 
>> loop:
>> ice-9/threads.scm:289:22: Syntax error:
>> guix/scripts/graph.scm:103:10: return: return used outside of 'with-monad' 
>> in form (return (package-node-edges a))
>
> The program below crashes with completely surreal backtraces in less
> than a minute on my 4-thread laptop:
>
> --8<---cut here---start->8---
> (use-modules (ice-9 threads)
>  (srfi srfi-1)
>  (guix monads)
>  (guix store))
>
> (define threads
>   (unfold (lambda (x) (> x 100))
>   (lambda (x)
> (call-with-new-thread
>  (lambda ()
>(define monad
>  (symbol-append 'foo-monad
> (string->symbol (number->string x
>
>(while #t
>  (macroexpand
>   `(begin
>  (define-monad ,monad
>(bind +)
>(return -))
>  (with-monad ,monad
>(return 3))
>  (mapm ,monad + '(1 2 3
>   1+
>   0))
>
> (for-each join-thread threads)
> --8<---cut here---end--->8---
>
> Can you check if that also happens on your many-core machine?

It does not crash.  I left it running for more than an hour (without
compiling) and it printed things like this:

--8<---cut here---start->8---
…
GC Warning: Repeated allocation of very large block (appr. size 57528320):
May lead to memory leak and poor performance
GC Warning: Repeated allocation of very large block (appr. size 57528320):
May lead to memory leak and poor performance
GC Warning: Repeated allocation of very large block (appr. size 57528320):
May lead to memory leak and poor performance
GC Warning: Repeated allocation of very large block (appr. size 57528320):
May lead to memory leak and poor performance
GC Warning: Repeated allocation of very large block (appr. size 14385152):
May lead to memory leak and poor performance
GC Warning: Repeated allocation of very large block (appr. size 14385152):
May lead to memory leak and poor performance
GC Warning: Repeated allocation of very large block (appr. size 57528320):
May lead to memory leak and poor performance
GC Warning: Repeated allocation of very large block (appr. size 28766208):
May lead to memory leak and poor performance
…
--8<---cut here---end--->8---

That’s on the machine with 1.5T RAM and 192 cores.  Then I ran it again
for 10 minutes after compiling it.  It did not crash.

> The patch below seems to fix the problem: (guix monads) has shared state
> (hash tables) used both at expansion-time and run-time, and it wasn’t
> protected.
>
> My hypothesis is that this was causing random memory corruption.  The
> weird thing, though, is that the errors we were getting were not so
> random.  Also, the load phase of ‘guix pull’ is sequential.
>
> Could you test it and report back?

I’m trying the patch right now with “guix pull”.

--
Ricardo

GPG: BCA6 89B6 3655 3801 C3C6  2150 197A 5888 235F ACAC
https://elephly.net




Re: bug#27476: guix pull fails on powerful server

2017-10-12 Thread Ludovic Courtès
Hi!

Ricardo Wurmus  skribis:

> The following derivation will be built:
>/gnu/store/z5bhk17nxmdhvj0g4cy038p25mzh1gys-guix-latest.drv
> copying and compiling to 
> '/gnu/store/s3s7xlqa10mvf8v0ypxz8gzw3lcf1x5z-guix-latest' with Guile 2.2.2...
> loading...   25.7% of 635 filesrandom seed for tests: 1506720257
> loading...   99.8% of 635 files
> compiling... 69.1% of 635 filesice-9/threads.scm:289:22: In procedure 
> loop:
> ice-9/threads.scm:289:22: Syntax error:
> guix/scripts/graph.scm:103:10: return: return used outside of 'with-monad' in 
> form (return (package-node-edges a))

The program below crashes with completely surreal backtraces in less
than a minute on my 4-thread laptop:

--8<---cut here---start->8---
(use-modules (ice-9 threads)
 (srfi srfi-1)
 (guix monads)
 (guix store))

(define threads
  (unfold (lambda (x) (> x 100))
  (lambda (x)
(call-with-new-thread
 (lambda ()
   (define monad
 (symbol-append 'foo-monad
(string->symbol (number->string x

   (while #t
 (macroexpand
  `(begin
 (define-monad ,monad
   (bind +)
   (return -))
 (with-monad ,monad
   (return 3))
 (mapm ,monad + '(1 2 3
  1+
  0))

(for-each join-thread threads)
--8<---cut here---end--->8---

Can you check if that also happens on your many-core machine?

The patch below seems to fix the problem: (guix monads) has shared state
(hash tables) used both at expansion-time and run-time, and it wasn’t
protected.

My hypothesis is that this was causing random memory corruption.  The
weird thing, though, is that the errors we were getting were not so
random.  Also, the load phase of ‘guix pull’ is sequential.

Could you test it and report back?

Thanks,
Ludo’.

diff --git a/guix/monads.scm b/guix/monads.scm
index 6ae616aca..c9c5da3bb 100644
--- a/guix/monads.scm
+++ b/guix/monads.scm
@@ -20,6 +20,7 @@
   #:use-module ((system syntax)
 #:select (syntax-local-binding))
   #:use-module (ice-9 match)
+  #:use-module (ice-9 threads)
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-9)
   #:use-module (srfi srfi-26)
@@ -117,6 +118,7 @@
   ;; the syntax object of the parameter over which it is templated, and (2)
   ;; the syntax of its body.
   (define-once %templates (make-hash-table))
+  (define-once %template-lock (make-mutex))
 
   (define (register-template! name param body)
 (hash-set! %templates name (cons param body)))
@@ -139,8 +141,9 @@ template instances."
   (syntax-source s))
 
 (define current-info-port
-  ;; Port for debugging info.
-  (const (%make-void-port "w")))
+  ;; Port for debugging info.  Return a fresh port at each call to make
+  ;; sure we're thread-safe.
+  (lambda () (%make-void-port "w")))
 
 (define location-string
   (format #f "~a:~a:~a"
@@ -204,12 +207,14 @@ template instances."
;; Search for an instance of template NAME for this ACTUAL parameter.
;; On success, expand to the identifier of the instance; otherwise
;; expand to #f.
-   (any (matching-instance? #'name #'actual) %template-instances))
+   (with-mutex %template-lock
+ (any (matching-instance? #'name #'actual) %template-instances)))
   ((_ exists? name actual)
;; Likewise, but return a Boolean.
(let ((result (->bool
-  (any (matching-instance? #'name #'actual)
-   %template-instances
+  (with-mutex %template-lock
+(any (matching-instance? #'name #'actual)
+ %template-instances)
  (unless result
(format (current-warning-port)
"~a: warning: no specialization of template '~a' for '~a'~%"
@@ -220,8 +225,9 @@ template instances."
;; Expand to the definitions of all the existing templates
;; specialized for ACTUAL.
#`(begin
-   #,@(hash-map->list (cut instance-definition <> <> #'actual)
-  %templates))
+   #,@(with-mutex %template-lock
+(hash-map->list (cut instance-definition <> <> #'actual)
+%templates)))
 
 (define-syntax define-template
   (lambda (s)


Re: guix pull fails on powerful server

2017-10-10 Thread Ludovic Courtès
Ricardo Wurmus  skribis:

> Ludovic Courtès  writes:
>
>> Ricardo Wurmus  skribis:
>>
>>> I’ve tried “guix pull” on the same server again, this time limiting CPUs
>>> with “taskset -c 0 guix pull”:
>>
>> As a stopgap, commit aba219af0fed6a349af930f19c913fb87e6a69dd ensures
>> that ‘--cores’ is honored.  So if you run “guix pull --cores=1”, it will
>> build things sequentially.
>>
>> Now, to take advantage of that, you first need to update to the current
>> Guix…
>
> Thank you, this worked!
>
> On that server I built Guix from source and then let the users pull with
> “--cores=1” to update their own Guix.

You could also run guix-daemon with --cores=4 or similar, so that it
uses 4 cores by default (few package builds scale beyond that anyway),
and then maybe --max-jobs=4 so you don’t waste the other cores.  ;-)

Ludo’.



Re: guix pull fails on powerful server

2017-10-10 Thread Ricardo Wurmus

Ludovic Courtès  writes:

> Ricardo Wurmus  skribis:
>
>> I’ve tried “guix pull” on the same server again, this time limiting CPUs
>> with “taskset -c 0 guix pull”:
>
> As a stopgap, commit aba219af0fed6a349af930f19c913fb87e6a69dd ensures
> that ‘--cores’ is honored.  So if you run “guix pull --cores=1”, it will
> build things sequentially.
>
> Now, to take advantage of that, you first need to update to the current
> Guix…

Thank you, this worked!

On that server I built Guix from source and then let the users pull with
“--cores=1” to update their own Guix.

-- 
Ricardo

GPG: BCA6 89B6 3655 3801 C3C6  2150 197A 5888 235F ACAC
https://elephly.net




Re: guix pull fails on powerful server

2017-10-07 Thread Ludovic Courtès
Ricardo Wurmus  skribis:

> I’ve tried “guix pull” on the same server again, this time limiting CPUs
> with “taskset -c 0 guix pull”:

As a stopgap, commit aba219af0fed6a349af930f19c913fb87e6a69dd ensures
that ‘--cores’ is honored.  So if you run “guix pull --cores=1”, it will
build things sequentially.

Now, to take advantage of that, you first need to update to the current
Guix…

Ludo’.



Re: guix pull fails on powerful server

2017-10-04 Thread Ricardo Wurmus

Clément Lassieur  writes:

> Ricardo Wurmus  writes:
>
>> Is there another work-around I could try on this machine?
>
> My workaround was to build Guix from sources.  But I'm sure you thought
> about it.

Yes, that works, but I was looking for something that a user can do who
wouldn’t like to fiddle with git.

-- 
Ricardo

GPG: BCA6 89B6 3655 3801 C3C6  2150 197A 5888 235F ACAC
https://elephly.net




Re: guix pull fails on powerful server

2017-10-04 Thread Clément Lassieur
Ricardo Wurmus  writes:

> Is there another work-around I could try on this machine?

My workaround was to build Guix from sources.  But I'm sure you thought
about it.



Re: guix pull fails on powerful server

2017-10-04 Thread Ricardo Wurmus

Marius Bakke  writes:

> Ricardo Wurmus  writes:
>
>> Is there another work-around I could try on this machine?
>
> Using Guile 2.0 worked for me:
>
> guix package -r guix guile-git -i guile2.0-guix guile2.0-git

Unfortunately, this didn’t work for me.  I tried this:

   guix package -i guile2.0-guix --with-source=/path/to/guix/checkout

This printed a lot of repetitions of “warning: unknown warning type
`macro-use-before-definition'” and eventually failed with this
backtrace:

--8<---cut here---start->8---
Backtrace:
In ice-9/boot-9.scm:
 160: 9 [catch #t # ...]
In unknown file:
   ?: 8 [apply-smob/1 #]
In ice-9/boot-9.scm:
  66: 7 [call-with-prompt prompt0 ...]
In ice-9/eval.scm:
 432: 6 [eval # #]
In ice-9/boot-9.scm:
2412: 5 [save-module-excursion #]
4091: 4 [#]
1734: 3 [%start-stack load-stack #]
1739: 2 [#]
In unknown file:
   ?: 1 [primitive-load 
"/tmp/guix-build-guile2.0-guix-0.13.0-4.f1ddfe4.drv-0/source/./build-aux/compile-all.scm"]
In ice-9/threads.scm:
  99: 0 [loop (("guix/base16.scm" "guix/base32.scm" "guix/base64.scm" ...))]

ice-9/threads.scm:99:22: In procedure loop:
ice-9/threads.scm:99:22: In procedure fport_write: Bad address
make[2]: *** [Makefile:5252: make-go] Error 1
make[2]: Leaving directory 
'/tmp/guix-build-guile2.0-guix-0.13.0-4.f1ddfe4.drv-0/source'
make[1]: *** [Makefile:4383: all-recursive] Error 1
make[1]: Leaving directory 
'/tmp/guix-build-guile2.0-guix-0.13.0-4.f1ddfe4.drv-0/source'
make: *** [Makefile:2973: all] Error 2
phase `build' failed after 149.5 seconds
builder for 
`/gnu/store/aqz4d2bbihvdmxqb6rlb71c853jb4dp3-guile2.0-guix-0.13.0-4.f1ddfe4.drv'
 failed with exit code 1
guix package: error: build failed: build of 
`/gnu/store/aqz4d2bbihvdmxqb6rlb71c853jb4dp3-guile2.0-guix-0.13.0-4.f1ddfe4.drv
--8<---cut here---end--->8---

--
Ricardo

GPG: BCA6 89B6 3655 3801 C3C6  2150 197A 5888 235F ACAC
https://elephly.net




Re: guix pull fails on powerful server

2017-09-25 Thread Andy Wingo
On Fri 22 Sep 2017 16:10, l...@gnu.org (Ludovic Courtès) writes:

> Hi Ricardo,
>
> Ricardo Wurmus  skribis:
>
>> The following derivation will be built:
>>/gnu/store/yvyfkns3w3vm7ynwbr7mvxcmin4gd2a0-guix-latest.drv
>> copying and compiling to 
>> '/gnu/store/7m52dkr98nhwgpsx20mmpwyw2yzj58d3-guix-latest' with Guile 2.2.2...
>> loading...   25.4% of 629 filesrandom seed for tests: 1506066913
>> loading...   99.8% of 629 files
>> compiling... 69.2% of 629 filesice-9/threads.scm:289:22: In procedure 
>> loop:
>> ice-9/threads.scm:289:22: Syntax error:
>> guix/scripts.scm:130:2: >>=: >>= (bind) used outside of 'with-monad' in form 
>> (>>= (apply set-build-options* #:use-substitutes
>> ptions)) (lambda (unused-value) (mbegin %store-monad (mlet %store-monad 
>> ((derivation (origin->derivation (package-source pack
>> tutes? use-substitutes? #:dry-run? dry-run?) (return 
>> (show-derivation-outputs derivation)))
>
> This was reported at , and I suspect a
> thread-safety issue.  However, syntax parameters are purely functional
> AFAICS, so I fail to see why multithreading could be a problem.
>
> Andy, any idea what could be causing this?

I have heard of but not seen a number of similar bugs: errors that
"can't happen" but which appear under multiple threads.  I don't know
what underlying pattern is.  Has anyone found a test case that reliably
reproduces?

Andy



Re: guix pull fails on powerful server

2017-09-25 Thread Ricardo Wurmus

Ludovic Courtès  writes:

> With this program:
>
> --8<---cut here---start->8---
> (use-modules (ice-9 threads)
>  (srfi srfi-1))
>
> (define-syntax-parameter foo
>   (identifier-syntax +))
>
> (define threads
>   (unfold (lambda (x) (> x 100))
>   (lambda (x)
> (call-with-new-thread
>  (lambda ()
>(while #t
>  (macroexpand
>   '(syntax-parameterize ((foo (identifier-syntax -)))
>  (foo y z)))
>   1+
>   0))
>
> (for-each join-thread threads)
> --8<---cut here---end--->8---

I have tried this programme on my 16 core 32G workstation, and on the
192 core 1.5T server, but could not get it to segfault.

-- 
Ricardo

GPG: BCA6 89B6 3655 3801 C3C6  2150 197A 5888 235F ACAC
https://elephly.net




Re: guix pull fails on powerful server

2017-09-25 Thread Ludovic Courtès
Hi,

Andy Wingo  skribis:

> On Fri 22 Sep 2017 16:10, l...@gnu.org (Ludovic Courtès) writes:
>
>> Hi Ricardo,
>>
>> Ricardo Wurmus  skribis:
>>
>>> The following derivation will be built:
>>>/gnu/store/yvyfkns3w3vm7ynwbr7mvxcmin4gd2a0-guix-latest.drv
>>> copying and compiling to 
>>> '/gnu/store/7m52dkr98nhwgpsx20mmpwyw2yzj58d3-guix-latest' with Guile 
>>> 2.2.2...
>>> loading...   25.4% of 629 filesrandom seed for tests: 1506066913
>>> loading...   99.8% of 629 files
>>> compiling... 69.2% of 629 filesice-9/threads.scm:289:22: In procedure 
>>> loop:
>>> ice-9/threads.scm:289:22: Syntax error:
>>> guix/scripts.scm:130:2: >>=: >>= (bind) used outside of 'with-monad' in 
>>> form (>>= (apply set-build-options* #:use-substitutes
>>> ptions)) (lambda (unused-value) (mbegin %store-monad (mlet %store-monad 
>>> ((derivation (origin->derivation (package-source pack
>>> tutes? use-substitutes? #:dry-run? dry-run?) (return 
>>> (show-derivation-outputs derivation)))
>>
>> This was reported at , and I suspect a
>> thread-safety issue.  However, syntax parameters are purely functional
>> AFAICS, so I fail to see why multithreading could be a problem.
>>
>> Andy, any idea what could be causing this?
>
> I have heard of but not seen a number of similar bugs: errors that
> "can't happen" but which appear under multiple threads.  I don't know
> what underlying pattern is.  Has anyone found a test case that reliably
> reproduces?

With this program:

--8<---cut here---start->8---
(use-modules (ice-9 threads)
 (srfi srfi-1))

(define-syntax-parameter foo
  (identifier-syntax +))

(define threads
  (unfold (lambda (x) (> x 100))
  (lambda (x)
(call-with-new-thread
 (lambda ()
   (while #t
 (macroexpand
  '(syntax-parameterize ((foo (identifier-syntax -)))
 (foo y z)))
  1+
  0))

(for-each join-thread threads)
--8<---cut here---end--->8---

I managed to get a segfault:

--8<---cut here---start->8---
$ guile syntax-parms.scm
;;; note: source file /home/ludo/src/guix/syntax-parms.scm
;;;   newer than compiled 
/home/ludo/.cache/guile/ccache/2.2-LE-8-3.A/home/ludo/src/guix/syntax-parms.scm.go
;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
;;;   or pass the --no-auto-compile argument to disable.
;;; compiling /home/ludo/src/guix/syntax-parms.scm
;;; compiled 
/home/ludo/.cache/guile/ccache/2.2-LE-8-3.A/home/ludo/src/guix/syntax-parms.scm.go
In /home/ludo/src/guix/syntax-parms.scm:
13:17 13 (_)
In ice-9/psyntax.scm:
  1233:22 12 (expand-top-sequence (#(ribcage #(x) #((m-1dff1b83541ce327-7f97c 
#)) #) # …) …)
In ice-9/boot-9.scm:
   230:17 11 (map1 (#))
In ice-9/psyntax.scm:
  2053:19 10 (_ _ #() (foo y z) ())
In ice-9/boot-9.scm:
   230:17  9 (map1 #())
In ice-9/psyntax.scm:
  1408:12  8 (_ _)
  1788:11  7 (lp (1) (11 0 . 0))
  1678:45  6 (parse _ _ _ _ _ _ _)
In ice-9/boot-9.scm:
   230:17  5 (map1 ((tmp-1dff1b83541ce327-7f98b 0 . 0)))
In ice-9/psyntax.scm:
  2701:67  4 Adres-eraro
--8<---cut here---end--->8---

… but then I failed to reproduce it again (that was on my 4-thread
laptop).

Ludo’.



Re: guix pull fails on powerful server

2017-09-25 Thread Clément Lassieur
I got it too for the first time yesterday on my 128G RAM and 32 CPU
cores server:

--8<---cut here---start->8---
substitute: updating list of substitutes from [...]
Updating from Git repository at 'https://git.savannah.gnu.org/git/guix.git'...
Building from Git commit 3140844e33254316348135b03762eaeb04764544...
substitute: updating list of substitutes from [...]
The following derivation will be built:
   /gnu/store/7143x1dd2r5kch8dldyylz1ljhp3nird-guix-latest.drv
copying and compiling to 
'/gnu/store/8a42yc4yxslrr1hf7wk5x5mddbs76yqm-guix-latest' with Guile 2.2.2...
loading...   25.3% of 632 filesrandom seed for tests: 1506279202
loading...   99.8% of 632 files
compiling... 94.8% of 632 filesice-9/threads.scm:289:22: In procedure loop:
ice-9/threads.scm:289:22: Syntax error:
guix/gexp.scm:530:8: return: return used outside of 'with-monad' in form 
(return output)

Some deprecated features have been used.  Set the environment
variable GUILE_WARN_DEPRECATED to "detailed" and rerun the
program to get more information.  Set it to "no" to suppress
this message.
builder for `/gnu/store/7143x1dd2r5kch8dldyylz1ljhp3nird-guix-latest.drv' 
failed with exit code 1
guix pull: error: build failed: build of 
`/gnu/store/7143x1dd2r5kch8dldyylz1ljhp3nird-guix-latest.drv' failed
--8<---cut here---end--->8---

And then, today, again:

--8<---cut here---start->8---
substitute: updating list of substitutes from [...]
Updating from Git repository at 'https://git.savannah.gnu.org/git/guix.git'...
Building from Git commit 0960ba75233ae5b6c539f43d97d06d64e9ad...
substitute: updating list of substitutes from [...]
The following derivation will be built:
   /gnu/store/dmv64icdan1fqrl00czgwx1an923fzda-guix-latest.drv
copying and compiling to 
'/gnu/store/slqcrr5gwhi1zqv21wjp0l973zs3dywc-guix-latest' with Guile 2.2.2...
loading...   25.3% of 632 filesrandom seed for tests: 1506327995
loading...   99.8% of 632 files
compiling... 94.8% of 632 filesice-9/threads.scm:289:22: In procedure loop:
ice-9/threads.scm:289:22: Syntax error:
guix/gexp.scm:539:10: return: return used outside of 'with-monad' in form 
(return (derivation->output-path drv))

Some deprecated features have been used.  Set the environment
variable GUILE_WARN_DEPRECATED to "detailed" and rerun the
program to get more information.  Set it to "no" to suppress
this message.
builder for `/gnu/store/dmv64icdan1fqrl00czgwx1an923fzda-guix-latest.drv' 
failed with exit code 1
guix pull: error: build failed: build of 
`/gnu/store/dmv64icdan1fqrl00czgwx1an923fzda-guix-latest.drv' failed
--8<---cut here---end--->8---



Re: guix pull fails on powerful server

2017-09-22 Thread Ludovic Courtès
Hi Ricardo,

Ricardo Wurmus  skribis:

> The following derivation will be built:
>/gnu/store/yvyfkns3w3vm7ynwbr7mvxcmin4gd2a0-guix-latest.drv
> copying and compiling to 
> '/gnu/store/7m52dkr98nhwgpsx20mmpwyw2yzj58d3-guix-latest' with Guile 2.2.2...
> loading...   25.4% of 629 filesrandom seed for tests: 1506066913
> loading...   99.8% of 629 files
> compiling... 69.2% of 629 filesice-9/threads.scm:289:22: In procedure 
> loop:
> ice-9/threads.scm:289:22: Syntax error:
> guix/scripts.scm:130:2: >>=: >>= (bind) used outside of 'with-monad' in form 
> (>>= (apply set-build-options* #:use-substitutes
> ptions)) (lambda (unused-value) (mbegin %store-monad (mlet %store-monad 
> ((derivation (origin->derivation (package-source pack
> tutes? use-substitutes? #:dry-run? dry-run?) (return (show-derivation-outputs 
> derivation)))

This was reported at , and I suspect a
thread-safety issue.  However, syntax parameters are purely functional
AFAICS, so I fail to see why multithreading could be a problem.

Andy, any idea what could be causing this?

Thanks,
Ludo’.



guix pull fails on powerful server

2017-09-22 Thread Ricardo Wurmus
Hi there,

I have a big server with 1.5T RAM and 192 CPU cores.  “guix pull”
is very slow and crashes with the error below:

--8<---cut here---start->8---
[root@murphy:~] (1001) $ guix pull
guile: warning: failed to install locale
warning: failed to install locale: Invalid argument
substitute: guile: warning: failed to install locale
substitute: warning: failed to install locale: Invalid argument

Starting download of /tmp/guix-file.Px0iiK
>From https://git.savannah.gnu.org/cgit/guix.git/snapshot/master.tar.gz...
 tar.gz 3.9MiB/s 00:03 | 13.6MiB transferred
unpacking '/gnu/store/vl04ygdiyqwbs1ms1rrx495g2yn44ipc-guix-latest.tar.gz'...
substitute: updating list of substitutes from 'https://mirror.hydra.gnu.org'... 
100.0%
The following derivation will be built:
   /gnu/store/yvyfkns3w3vm7ynwbr7mvxcmin4gd2a0-guix-latest.drv
copying and compiling to 
'/gnu/store/7m52dkr98nhwgpsx20mmpwyw2yzj58d3-guix-latest' with Guile 2.2.2...
loading...   25.4% of 629 filesrandom seed for tests: 1506066913
loading...   99.8% of 629 files
compiling... 69.2% of 629 filesice-9/threads.scm:289:22: In procedure loop:
ice-9/threads.scm:289:22: Syntax error:
guix/scripts.scm:130:2: >>=: >>= (bind) used outside of 'with-monad' in form 
(>>= (apply set-build-options* #:use-substitutes
ptions)) (lambda (unused-value) (mbegin %store-monad (mlet %store-monad 
((derivation (origin->derivation (package-source pack
tutes? use-substitutes? #:dry-run? dry-run?) (return (show-derivation-outputs 
derivation)))

Some deprecated features have been used.  Set the environment
variable GUILE_WARN_DEPRECATED to "detailed" and rerun the
program to get more information.  Set it to "no" to suppress
this message.
builder for `/gnu/store/yvyfkns3w3vm7ynwbr7mvxcmin4gd2a0-guix-latest.drv' 
failed with exit code 1
guix pull: error: build failed: build of 
`/gnu/store/yvyfkns3w3vm7ynwbr7mvxcmin4gd2a0-guix-latest.drv' failed
--8<---cut here---end--->8---

Here’s the version of Guix:

--8<---cut here---start->8---
[root@murphy:~] (1003) $ guix --version
guile: warning: failed to install locale
warning: failed to install locale: Invalid argument
guix (GNU Guix) 
Copyright (C) 2017 the Guix authors
License GPLv3+: GNU GPL version 3 or later 
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
[root@murphy:~] (1004) $ which guix
/root/.guix-profile/bin/guix
[root@murphy:~] (1005) $ readlink -f /root/.guix-profile/bin/guix
/gnu/store/m6nlmnlyr5d8d97k8lgp6ig2r2nxgf3r-guix-0.13.0-5.228a398/bin/guix
--8<---cut here---end--->8---

Is this related to Guile’s memory problems?

-- 
Ricardo

GPG: BCA6 89B6 3655 3801 C3C6  2150 197A 5888 235F ACAC
https://elephly.net