The status of statprof

2013-09-17 Thread Panicz Maciej Godek
Hi,
I've been trying to run the statprof that's
shipped with guile-2.0 with the following
code, but it reports "no samples taken".

The issue started with another project that
I wanted to profile, and there it worked, but
didn't count the calls (reported 0 to all of them).
So I decided to see that for the simplest case,
but apparently the simplest case doesn't work
(perhaps due to some optimizations). So my
question is: what is the status of the statprof
Is it maintained, or has it been abandoned,
or are there any additional tricks to get it
right? Here's the code:

(use-modules (statprof))

(define (increase x)
  (sleep 1)
  (1+ x))

(begin
  (statprof-reset 0 500 #t)
  (statprof-start)
  (let loop ((i 0))
(if (< i 10)
(loop (increase i))
i))
(statprof-stop)
(statprof-display))


;; Best regards,
;; M.


Re: pretty-print for 1+

2013-09-17 Thread Ludovic Courtès
Brian Killian  skribis:

> On Thu, Sep 12, 2013 at 6:04 PM, Ludovic Courtès  wrote:
>
>> Brian Killian  skribis:
>>
>> > Using guile 2.0.9 and the ice-9 pretty-print module, when I apply:
>> >
>> > (pretty-print '(1+ 1))
>> >
>> > I get:
>> >
>> > (#{1+}# 1)
>> >
>> > I was expecting:
>> >
>> > (1+ 1)
>> >
>> > Is this an issue with pretty-print or should I adjust my expectation?
>>
>> I think it’s an issue with ‘write’.  Specifically,
>> ‘INITIAL_IDENTIFIER_MASK’ in print.c doesn’t quite match the syntax
>> recognized by ‘read’.
>>
>> Ludo’.
>>
>>
>>
> Thank you for the information. I'm using (+ arg 1) instead of (1+ arg) as a
> workaround.

Well note that (#{1+}# 1) is valid and equivalent to (1+ 1).

> I'm using pretty-print to format code snippets as I work through SICP,
> which is becoming tedious. Do you know of a script or tool that formats
> Scheme files using the pretty-print rules? I've switched from gedit to
> Emacs as an editor, but Emacs only seems to indent things properly, rather
> than stripping extraneous newlines and trying to fit expressions on one
> line if possible like pretty-print does.

Good question, I don’t know of any such tool.

Ludo’.




Interpreting statprof

2013-09-17 Thread Dmitry Bogatov

Hello!

Today I tried to statprof my toy application, that uses htmlprag
since it is too slow (4 sec on one page) vs 0.5 with Python.
Statprof says, that most of time takes `eval` function, but I checked
htmlprag source --- it does not use eval. So question is where is it
called and what can I do to speedup my application?

PS. Should I attach source file and html file to parse?

% cumulative   self
time   seconds seconds  name
 56.48  4.22  2.38  eval
 11.82  0.50  0.50  memoized-expression-data
  9.22  0.39  0.39  list-ref
  8.36  0.35  0.35  memoized-expression-typecode
  4.03  0.17  0.17  write-char
  2.31  0.10  0.10  get-output-string
  1.44  0.06  0.06  list-set!
  1.15  0.05  0.05  variable?
  1.15  0.05  0.05  open-output-string
  0.86  0.04  0.04  read-char
  0.86  0.04  0.04  #
  0.58  0.02  0.02  eqv?
  0.29  0.01  0.01  equal?
  0.29  0.01  0.01  memv
  0.29  0.01  0.01  map
  0.29  0.01  0.01  string->symbol
  0.29  0.01  0.01  eof-object?
  0.29  0.01  0.01  #
  0.00  4.22  0.00  statprof
  0.00  4.22  0.00  save-module-excursion
  0.00  4.22  0.00  #
  0.00  4.22  0.00  #
  0.00  4.22  0.00  load-compiled/vm
  0.00  4.22  0.00  apply-smob/1
  0.00  4.22  0.00  call-with-prompt
  0.00  4.22  0.00  catch
  0.00  4.22  0.00  perform-action
---
Sample count: 347
Total time: 4.218837499 seconds (0.176613742 seconds in GC)

--
Best regards, Dmitry Bogatov ,
Free Software supporter and netiquette guardian.
git clone git://kaction.name/rc-files.git --depth 1
GPG: 54B7F00D
Html mail and proprietary format attachments are forwarded to /dev/null.


pgpaPi5xDBoSw.pgp
Description: PGP signature


Re: The status of statprof

2013-09-17 Thread Ludovic Courtès
Panicz Maciej Godek  skribis:

> I've been trying to run the statprof that's
> shipped with guile-2.0 with the following
> code, but it reports "no samples taken".

That probably means that the code being profiled runs too fast compared
to the sample rate.

The ‘with-statprof’ macro allows you to specify a sample rate, and
whether/how many times you want to run its body in a loop (info "(guile)
Statprof").

HTH,
Ludo’.




Re: Interpreting statprof

2013-09-17 Thread Andy Wingo
On Tue 17 Sep 2013 18:14, Dmitry Bogatov  writes:

> Hello!
>
> Today I tried to statprof my toy application, that uses htmlprag
> since it is too slow (4 sec on one page) vs 0.5 with Python.
> Statprof says, that most of time takes `eval` function, but I checked
> htmlprag source --- it does not use eval. So question is where is it
> called and what can I do to speedup my application?
>
> PS. Should I attach source file and html file to parse?
>
> % cumulative   self
> time   seconds seconds  name
>  56.48  4.22  2.38  eval
>  11.82  0.50  0.50  memoized-expression-data
>   9.22  0.39  0.39  list-ref
>   8.36  0.35  0.35  memoized-expression-typecode

Probably this means that your program is being interpreted, rather than
compiled.  Or something is being interpreted, anyway.  Check that you
have auto-compilation on.

Cheers,

Andy
-- 
http://wingolog.org/



Re: guile-figl - Any plans for an initial release?

2013-09-17 Thread Andy Wingo
Hi!

On Sat 14 Sep 2013 16:43, David Thompson  writes:

> I'm hoping to make a 0.1 release guile-2d soon (maybe by the GNU 30th
> anniversary?), but I would like to wait until guile-figl has made a
> release so that I can point users to a release tarball rather than
> asking them to compile from git master.
>
> So, any plans for a release? It's certainly usable enough for my needs,
> though I'm not sure if the project has some explicit goals that need to
> be met before it's deemed worthy of a release.

I've kinda forgotten about this stuff, sorry.  Daniel what's the status
of our GNU project?  IIRC all things were go at one point.  Do we change
the project name to guile-opengl or something, now that we have
permission?  Sorry for dropping the ball here :)

Andy
-- 
http://wingolog.org/



Re: The status of statprof

2013-09-17 Thread Andy Wingo
On Tue 17 Sep 2013 14:37, Panicz Maciej Godek  writes:

> So my question is: what is the status of the statprof?

It's fine :)

> (define (increase x)
> (sleep 1)
> (1+ x))
>
> (begin
> (statprof-reset 0 500 #t)
> (statprof-start)
> (let loop ((i 0))
> (if (< i 10)
> (loop (increase i))
> i))
> (statprof-stop)
> (statprof-display))

Statprof runs on SIGPROF ticks, driven by setitimer.  These ticks run
after a constant amount of CPU time spent.  Your test doesn't consume
any CPU time because it's sleeping, so no ticks get recorded.

Also note that using the "statprof" function is much easier.

Cheers,

Andy
-- 
http://wingolog.org/



Re: Doctest for guile

2013-09-17 Thread Andy Wingo
On Wed 11 Sep 2013 17:03, Dmitry Bogatov  writes:

> $ guile doctest.scm '(foo)'

Neat!

> + Your ideas?
>
> I it will be found useful enough, I will gladly work on patch to integrate
> doctest in Guile guild script.

I was going to write exactly this!  "guild doctest '(foo)'" sounds
sensible to me.

Note also that the compiler will residualize other properties in
addition to docstrings.  They are taken from pairs in a static vector in
head position.  Hacky, right?

scheme@(guile-user)> (define (foo) #((foo . bar) (baz . qux)) 1)
scheme@(guile-user)> (procedure-properties foo)
$3 = ((arity 0 0 #f) (name . foo) (foo . bar) (baz . qux))

They don't propagate to the interpreter but that can be fixed.  Anyway
it's possible to associate some kind of test property with test.  If
that's useful to you, anyway.

Cheers,

Andy
-- 
http://wingolog.org/



Re: Interpreting statprof

2013-09-17 Thread Andy Wingo
On Tue 17 Sep 2013 18:14, Dmitry Bogatov  writes:

> Hello!
>
> Today I tried to statprof my toy application, that uses htmlprag
> since it is too slow (4 sec on one page) vs 0.5 with Python.
> Statprof says, that most of time takes `eval` function, but I checked
> htmlprag source --- it does not use eval. So question is where is it
> called and what can I do to speedup my application?
>
> PS. Should I attach source file and html file to parse?
>
> % cumulative   self
> time   seconds seconds  name
>  56.48  4.22  2.38  eval
>  11.82  0.50  0.50  memoized-expression-data
>   9.22  0.39  0.39  list-ref
>   8.36  0.35  0.35  memoized-expression-typecode

Probably this means that your program is being interpreted, rather than
compiled.  Or something is being interpreted, anyway.  Check that you
have auto-compilation on.

Cheers,

Andy
>   4.03  0.17  0.17  write-char
>   2.31  0.10  0.10  get-output-string
>   1.44  0.06  0.06  list-set!
>   1.15  0.05  0.05  variable?
>   1.15  0.05  0.05  open-output-string
>   0.86  0.04  0.04  read-char
>   0.86  0.04  0.04  #
>   0.58  0.02  0.02  eqv?
>   0.29  0.01  0.01  equal?
>   0.29  0.01  0.01  memv
>   0.29  0.01  0.01  map
>   0.29  0.01  0.01  string->symbol
>   0.29  0.01  0.01  eof-object?
>   0.29  0.01  0.01  #
>   0.00  4.22  0.00  statprof
>   0.00  4.22  0.00  save-module-excursion
>   0.00  4.22  0.00  #
>   0.00  4.22  0.00  #
>   0.00  4.22  0.00  load-compiled/vm
>   0.00  4.22  0.00  apply-smob/1
>   0.00  4.22  0.00  call-with-prompt
>   0.00  4.22  0.00  catch
>   0.00  4.22  0.00  perform-action
> ---
> Sample count: 347
> Total time: 4.218837499 seconds (0.176613742 seconds in GC)
>
> --
> Best regards, Dmitry Bogatov ,
> Free Software supporter and netiquette guardian.
>   git clone git://kaction.name/rc-files.git --depth 1
>   GPG: 54B7F00D
> Html mail and proprietary format attachments are forwarded to /dev/null.

-- 
http://wingolog.org/



Re: is (web client) ready for use even for the simplest task?

2013-09-17 Thread Andy Wingo
On Tue 10 Sep 2013 11:19, Mark H Weaver  writes:

> Darren Hoo  writes:
>
>> OK, let's add something to the body
>>
>> (http-post "http://www.google.com/"; #:body "")
>>
>> Howcome the request now becomes an http GET request:
>>
>> GET / HTTP/1.1
>> Content-Type: text/plain;charset=utf-8
>> Host: www.google.com
>> Connection: close

That was totally my fault, FWIW.  Sorry about that!

>> This is really ridiculous.
>
> You found a bug.  It happens.  There's no need to be obnoxious about it.

Agreed.  But now that that's settled, have fun with Guile :)

Andy
-- 
http://wingolog.org/



Re: Interpreting statprof

2013-09-17 Thread Dmitry Bogatov

Andy Wingo  writes:
>> Today I tried to statprof my toy application, that uses htmlprag
>> since it is too slow (4 sec on one page) vs 0.5 with Python.
>> Statprof says, that most of time takes `eval` function, but I checked
>> htmlprag source --- it does not use eval. So question is where is it
>> called and what can I do to speedup my application?
>> time   seconds seconds  name
>>  56.48  4.22  2.38  eval
>>  11.82  0.50  0.50  memoized-expression-data
> Probably this means that your program is being interpreted, rather than
> compiled.  Or something is being interpreted, anyway.  Check that you
> have auto-compilation on.
Thanks! It reduced time from 4 sec to 0.4.

--
Best regards, Dmitry Bogatov ,
Free Software supporter and netiquette guardian.
git clone git://kaction.name/rc-files.git --depth 1
GPG: 54B7F00D
Html mail and proprietary format attachments are forwarded to /dev/null.


pgpY8PkD0QG3z.pgp
Description: PGP signature


Re: Doctest for guile

2013-09-17 Thread Ian Price
Dmitry Bogatov  writes:

> Hello!
> I am glad to offer implementation of doctest in Guile --- way to declare
> and check tests in function docstring. In most simple way, if in
> docstring you write following:
>
> +++ (foo 1 2 3)
> --- 6

I have to admit, I really don't like these sorts of modules. Automatic
checking of an example in a docstring is fine, but putting all the tests
in a docstring makes the docstring too big to be useful, and you lose
any compile warning time warnings guile can give you on the code.

Just my 2¢, but glad it works for you.

-- 
Ian Price -- shift-reset.com

"Programming is like pinball. The reward for doing it well is
the opportunity to do it again" - from "The Wizardy Compiled"



Re: Doctest for guile

2013-09-17 Thread Dmitry Bogatov

Andy Wingo  writes:

>> I it will be found useful enough, I will gladly work on patch to integrate
>> doctest in Guile guild script.
>
> I was going to write exactly this!  "guild doctest '(foo)'" sounds
> sensible to me.
>
> Note also that the compiler will residualize other properties in
> addition to docstrings.  They are taken from pairs in a static vector in
> head position.  Hacky, right?
>
> scheme@(guile-user)> (define (foo) #((foo . bar) (baz . qux)) 1)
> scheme@(guile-user)> (procedure-properties foo)
> $3 = ((arity 0 0 #f) (name . foo) (foo . bar) (baz . qux))
It is intresting, but just now I see no use for it. In face, it seems my
Guile saves less information about function, that your:
$2 = ((name . foo) (foo . bar) (baz . qux))
As you can see, I am missing arity. Is it git patch?

--
Best regards, Dmitry Bogatov ,
Free Software supporter and netiquette guardian.
git clone git://kaction.name/rc-files.git --depth 1
GPG: 54B7F00D
Html mail and proprietary format attachments are forwarded to /dev/null.


pgprcU6NXb2hc.pgp
Description: PGP signature


Re: Doctest for guile

2013-09-17 Thread Andy Wingo
On Tue 17 Sep 2013 20:45, Dmitry Bogatov  writes:

>   $2 = ((name . foo) (foo . bar) (baz . qux))
> As you can see, I am missing arity. Is it git patch?

Probably you're using master.  I think arity is not a property there,
but instead accessed using other accessors.

Regards,

Andy
-- 
http://wingolog.org/



Re: pretty-print for 1+

2013-09-17 Thread Chaos Eternal
yet there is another interesting thing:

(symbol? 'a) => #t
(symbol? '+a) => #t
(symbol? '-a) => #t

(symbol? 'b) => #t
(symbol? '+b) => #t
(symbol? '-b) => #t

BUT:
(symbol? 'i) => #t
(symbol? '+i) => #f
(symbol? '-i) => #f

In guile-scsh, user would like the guile recognize -i as symbols
rather than complex numbers, is there any way?

On Tue, Sep 17, 2013 at 6:02 PM, Ludovic Courtès  wrote:
> Brian Killian  skribis:
>
>> On Thu, Sep 12, 2013 at 6:04 PM, Ludovic Courtès  wrote:
>>
>>> Brian Killian  skribis:
>>>
>>> > Using guile 2.0.9 and the ice-9 pretty-print module, when I apply:
>>> >
>>> > (pretty-print '(1+ 1))
>>> >
>>> > I get:
>>> >
>>> > (#{1+}# 1)
>>> >
>>> > I was expecting:
>>> >
>>> > (1+ 1)
>>> >
>>> > Is this an issue with pretty-print or should I adjust my expectation?
>>>
>>> I think it’s an issue with ‘write’.  Specifically,
>>> ‘INITIAL_IDENTIFIER_MASK’ in print.c doesn’t quite match the syntax
>>> recognized by ‘read’.
>>>
>>> Ludo’.
>>>
>>>
>>>
>> Thank you for the information. I'm using (+ arg 1) instead of (1+ arg) as a
>> workaround.
>
> Well note that (#{1+}# 1) is valid and equivalent to (1+ 1).
>
>> I'm using pretty-print to format code snippets as I work through SICP,
>> which is becoming tedious. Do you know of a script or tool that formats
>> Scheme files using the pretty-print rules? I've switched from gedit to
>> Emacs as an editor, but Emacs only seems to indent things properly, rather
>> than stripping extraneous newlines and trying to fit expressions on one
>> line if possible like pretty-print does.
>
> Good question, I don’t know of any such tool.
>
> Ludo’.
>
>