Is it possible to increase the sbcl dynamic-space-size beyond the default of 1024 on Windows 10 in version SBCL 2.0.0?
For example, loading from the command prompt with sbcl --dynamic-space-size 2048 seems to be ignored since (/ (- sb-vm:dynamic-space-end sb-vm:dynamic-space-start) (expt 1024 2)) still returns 1024, not 2048. Thanks.
Related
Here is my MIT Scheme code:
(display (name->package '(user)))
(newline)
(->environment (name->package '(user)))
(%exit)
This runs fine on MIT/GNU Scheme Release 9.1.1. Here is the output:
$ scheme --quiet --load foo.scm
#[package 13 (user)]
But when I run this with MIT/GNU Scheme Release 10.1.5, I get this error:
$ mit-scheme --quiet --load foo.scm
#[package 12 (user)]
;The object #[package 12 (user)], passed as an argument to ->environment, is not an environment.
;To continue, call RESTART with an option number:
; (RESTART 1) => Return to read-eval-print level 1.
2 error>
On debugging I get this,
2 error> (debug)
There are 7 subproblems on the stack.
Subproblem level: 0 (this is the lowest subproblem level)
Compiled code expression unknown
#[compiled-return-address 13 ("rep" #x2f) #xd8 #x95ed10]
There is no current environment.
There is no execution history for this subproblem.
You are now in the debugger. Type q to quit, ? for commands.
3 debug>
Why does this error occur in 10.1.5 but not in 9.1.1?
I recently decided to start playing with MIT Scheme by following along with the examples in SICP. I installed scheme from the Ubuntu repository.
sudo apt-get install mit-scheme
Given an input file that looks like this:
486
(+ 137 349)
(- 1000 334)
(* 5 99)
(/ 10 5)
(* 25 4 12)
I run scheme as follows.
scheme < Numbers.scm
It produces the following output.
MIT/GNU Scheme running under GNU/Linux
Type `^C' (control-C) followed by `H' to obtain information about interrupts.
Copyright (C) 2011 Massachusetts Institute of Technology
This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Image saved on Sunday February 7, 2016 at 10:35:34 AM
Release 9.1.1 || Microcode 15.3 || Runtime 15.7 || SF 4.41 || LIAR/x86-64 4.118 || Edwin 3.116
1 ]=> 486
;Value: 486
1 ]=> (+ 137 349)
;Value: 486
1 ]=> (- 1000 334)
;Value: 666
1 ]=> (* 5 99)
;Value: 495
1 ]=> (/ 10 5)
;Value: 2
1 ]=> (* 25 4 12)
;Value: 1200
1 ]=>
End of input stream reached.
Moriturus te saluto.
This output feels excessive, so I'm currently paring it down like so.
scheme < Numbers.scm | awk '/Value/ {print $2}
486
486
666
495
2
1200
Is there a native way to reduce the verbosity of scheme, so I can get something resembling the above output without resorting to an external process?
I have examined the output of scheme --help but did not find any obvious options.
Note that passing the filename as an argument does not appear to work in MIT-Scheme.
scheme Numbers.scm
MIT/GNU Scheme running under GNU/Linux
Type `^C' (control-C) followed by `H' to obtain information about interrupts.
Copyright (C) 2011 Massachusetts Institute of Technology
This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Image saved on Sunday February 7, 2016 at 10:35:34 AM
Release 9.1.1 || Microcode 15.3 || Runtime 15.7 || SF 4.41 || LIAR/x86-64 4.118 || Edwin 3.116
;Warning: Invalid keyword: "Numbers.scm"
;Warning: Unhandled command line options: ("Numbers.scm")
1 ]=>
Here you go:
scheme --quiet < Numbers.scm
Now this will suppress the REPL entirely except when errors occur so that what is not explicitly displayed will not be displayed. eg. evaluatiing (+ 2 3) returns 5, but does not print since you have not told it to print. You need to use procedures like display to get the information printed or go back to using a REPL which sole purpose is to display your results.
I was originally hoping you could do:
scheme --quiet --load Numbers.scm
But it does not exit after the file and adding --eval (exit) has the REPL ask if you want to quit.
EDIT
(define (displayln v)
(display v)
(newline)
v)
(displayln (+ 4 5))
; ==> 9, in addition you get the side effect that "9\n" is written to current output port
You could also perhaps make a macro to do this:
(define-syntax begin-display
(syntax-rules ()
((_ form ...) (begin (displayln form) ...))))
(begin-display
486
(+ 137 349)
(- 1000 334)
(* 5 99)
(/ 10 5)
(* 25 4 12))
; ==> 1200. In addition you get the side effect that "486\n486\n666\n49\n2\n1200\n" is written to current output port
As a workaround,
scheme < Numbers.scm | gawk '/^;Value: / { sub(/^;Value: /, ""); print }'
But maybe you'd run it as a script file rather than an stdin stream? Not sure about MIT Scheme invocation, something like
scheme Numbers.scm
Though this way you'll have to print out the results explicitly, with (display) or something, otherwise they'll go unnoticed.
I want to programing a function about open the file directly. Like python code:
os.system("ls")
For example, when I use this function (fun_open "/path/to/file"), the system will open the file use the default app. If file is a .txt, open it with textedit.
How to make it?
----UPDATE 9/24/2015-----
My code is:
(defun open_by_system (dir)
(sb-ext:run-program "/usr/bin/open" (list "-a" "Preview" dir)))
and I use it:
CL-USER> (open_by_system "~/Desktop/ML.pdf")
#<SB-IMPL::PROCESS :EXITED 1>
Nothing else happen
I'd recommend using UIOP, which provides portable interface to the OS and is universally available as a part of ASDF3:
(uiop:run-program "ls")
See the docstrings in run-program.lisp for details.
If you need more convenience functions, you could take a look at inferior-shell.
I recommend you to take a look at the available libraries on quickdocs:
link
I recommend you to use inferior-shell available on quicklisp
link
loading:
CL-USER> (ql:quickload 'inferior-shell)
To load "inferior-shell":
Load 5 ASDF systems:
alexandria asdf closer-mop named-readtables optima
Install 4 Quicklisp releases:
fare-mop fare-quasiquote fare-utils inferior-shell
; Fetching #<URL "http://beta.quicklisp.org/archive/fare-quasiquote/2015-06-08/fare-quasiquote-20150608-git.tgz">
; 15.08KB
==================================================
15,437 bytes in 0.10 seconds (157.03KB/sec)
; Fetching #<URL "http://beta.quicklisp.org/archive/fare-utils/2015-06-08/fare-utils-20150608-git.tgz">
; 31.51KB
==================================================
32,264 bytes in 0.14 seconds (218.80KB/sec)
; Fetching #<URL "http://beta.quicklisp.org/archive/fare-mop/2015-06-08/fare-mop-20150608-git.tgz">
; 2.67KB
==================================================
2,738 bytes in 0.00 seconds (0.00KB/sec)
; Fetching #<URL "http://beta.quicklisp.org/archive/inferior-shell/2015-06-08/inferior-shell-20150608-git.tgz">
; 12.87KB
==================================================
13,182 bytes in 0.00 seconds (12873.05KB/sec)
; Loading "inferior-shell"
[package fare-utils]..............................
[package fare-stateful]...........................
[package fare-quasiquote].........................
[package fare-mop].............
(INFERIOR-SHELL)
a simple sample:
CL-USER> (inferior-shell:run/ss '(echo (1) "2" (+ 3)))
"1 2 3"
NIL
0
a sample with pipes:
CL-USER> (inferior-shell:run/ss `(inferior-shell:pipe (echo (+ hel "lo,") world) (tr "hw" "HW") (sed -e "s/$/!/")))
"Hello, World!"
NIL
0
Mac OS X and SBCL:
Open a text file in the default text editor application TextEdit:
Lisp Machine:~ lispm$ touch /tmp/test.text
Lisp Machine:~ lispm$ sbcl
This is SBCL 1.2.14, an implementation of ANSI Common Lisp.
More information about SBCL is available at <http://www.sbcl.org/>.
SBCL is free software, provided as is, with absolutely no warranty.
It is mostly in the public domain; some portions are provided under
BSD-style licenses. See the CREDITS and COPYING files in the
distribution for more information.
* (sb-ext:run-program "/usr/bin/open" '("/tmp/test.text"))
#<SB-IMPL::PROCESS :EXITED 0>
Open the file with LispWorks as the text editor:
* (sb-ext:run-program
"/usr/bin/open"
'("-a"
"/Applications/LispWorks 7.0 (64-bit)/LispWorks (64-bit).app"
"/tmp/test.text"))
You might want to consult the SBCL manual for such questions. For example the chapter on Running External Programs.
Nginx occupies all the available disk space. How to set limit for log files on Mac OS?
Rotate the log files. On OS X, newsyslog is the preferred utility to do that. Set up a file like this in /etc/newsyslog.d/nginx.conf:
# logfilename [owner:group] mode count size when flags [/pid_file] [sig_num]
/var/log/nginx.log deceze:wheel 644 2 1024 * J
Read https://www.newsyslog.org/manual.html for more information.
Building on #deceze's answer, here's an adapted version of Apple's Apache configuration for a Homebrew-installed nginx:
#logfilename [owner:group] mode count size when [flags] [/pid_file] [sig_num]
/opt/homebrew/var/log/nginx/access.log _nginx:_nginx 644 10 20480 * Z /opt/homebrew/var/run/nginx.pid 30
This is assuming you're running as user:group _nginx:_nginx. It sends the correct SIGUSR1 signal (30 on macOS) to nginx. Also changed to using gzip instead of bzip2.
Being a Linux administrator, I used to write my scripts in Bash, TCL and, less often, in Perl. Just out of curiosity, I tried to write something in mzscheme, but what I found out was that the performance was so much worse. I cut the script to simply reading a 500MB log file:
#lang scheme
(require rnrs/programs-6)
(call-with-input-file (vector-ref (current-command-line-arguments) 0)
(lambda (in)
(let loop ((line (read-line in)))
(unless (eof-object? line)
(loop (read-line in))))))
This simple process takes about 40 seconds. The same script, adapted for Guile, executes in 10 seconds. TCL version runs for 5 seconds. Chicken Scheme takes only 3.8 seconds, ten time less than MZScheme:
#!/usr/bin/csi -script
(call-with-input-file (list-ref (command-line-arguments) 0)
(lambda (in)
(let loop ((line (read-line in)))
(if (not (eof-object? line))
(loop (read-line in))))))
What am I doing wrong? Are there any recommendations on writing faster MZScheme programs?
Some more tests:
minaev#minaev:~/1$ time ./t.tcl blog.log
real 0m8.907s
user 0m8.417s
sys 0m0.468s
Mon Oct 31 13:15:19 MSK 2011
minaev#minaev:~/1$ time ./t.scm blog.log # Chicken 4.2.0
real 0m7.678s
user 0m6.896s
sys 0m0.580s
Mon Oct 31 13:15:29 MSK 2011
minaev#minaev:~/1$ time /usr/bin/mzscheme t.ss blog.log # mzscheme 4.2.1
real 0m44.047s
user 0m41.803s
sys 0m0.948s
Mon Oct 31 13:17:03 MSK 2011
minaev#minaev:~/1$ time racket t.ss blog.log # racket 5.1.3
real 0m25.287s
user 0m23.189s
sys 0m0.828s
Mon Oct 31 13:17:39 MSK 2011
minaev#minaev:~/1$ raco make t.ss
Mon Oct 31 13:17:47 MSK 2011
minaev#minaev:~/1$ time racket t.ss blog.log # racket 5.1.3 byte-compiled
real 0m23.237s
user 0m22.469s
sys 0m0.688s
This has now been substantially improved in the development version of Racket. See the commit here and the message from Racket maintainer Matthew Flatt here. It should now be only about 50% slower than Chicken. The remaining slowdown is primarily due to the additional features Racket provides, such as events, line-counting, unicode encoding, and others.
I tried repeating your results, and I got about 3.4s for Chicken 4.5.0 and about 10s for various versions of mzscheme/racket. (I tried mzscheme from PLT Scheme 4.2 and racket from both Racket 5.1.1 and the development tree, all compiled in 64-bit mode.)
What version of mzscheme are you using? What platform?
Are your timings repeatable? (I wonder about block cache effects.)