Re: [racket-users] Profiling places

2018-03-28 Thread 'Paulo Matos' via Racket Users


On 28/03/18 10:23, 'Paulo Matos' via Racket Users wrote:
> True, I can confirm that. I will open an issue on this. 

Done #2019.
https://github.com/racket/racket/issues/2019

-- 
Paulo Matos

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Profiling places

2018-03-28 Thread 'Paulo Matos' via Racket Users


On 27/03/18 17:18, Vincent St-Amour wrote:
> On Tue, 27 Mar 2018 07:55:08 -0500,
> 'Paulo Matos' via Racket Users wrote:
>>
>> I was trying to confirm my suspicion that profile needs to be manually
>> setup in each place for profiling.
> 
> Right. Each place has its own separate runtime, and the profile only
> spans a single runtime.
> 
>> Is this a possibility or is there something out there to make this
>> easier? Also, profile-thunk says that:
>> "To track all threads, specify a non-#f value for the threads?
>> argument―this will execute the computation in a fresh custodian, and
>> keep track of all threads under this custodian."
>>
>> But what happens if the place itself creates its own custodian to launch
>> threads?
> 
> In this case, thread refers to Racket's concurrency mechanism; this is
> unrelated to places.
> 

I understand that, what I meant was that I was wondering what would
happen (haven't tried it yet) if the place spawned by `dynamic-place`
creates a new custodian and uses that to create new threads. Would
profiling through the place, with #:threads #t, still profile the
threads? -- maybe I need to create an example.

> On Tue, 27 Mar 2018 08:15:19 -0500,
> 'Paulo Matos' via Racket Users wrote:
>>
>>
>>
>> On 27/03/18 14:55, 'Paulo Matos' via Racket Users wrote:
>>>
>>> 1. setup a profile command line argument that's passed to places-profile.rkt
>>> 2. send a flag indicating if we need profiling in any-double?
>>> 3. then use profile-thunk on the function if profiling is required, or
>>> nothing if profiling is not required.
>>>
>>
>> I have attempted this:
>> [...]
> 
> I get profiling information (including periodic reports) when I disable
> errortrace mode in `profile-thunk`.
> 
> The errortrace mode requires the use of the errortrace compile-handler,
> without which there's nothing for the profiler to observe.
> 
> `raco profile --use-errortrace` sets it, as does `racket -l errortrace
> -t places-profile.rkt`. However, neither of those work on your example.
> 
> Could places be interfering with the compile-handler?
> 

True, I can confirm that. I will open an issue on this. I have no idea
how the internals of these things work so not sure what could be
happening here. Maybe Matthew knows?

-- 
Paulo Matos

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Profiling places

2018-03-27 Thread 'Paulo Matos' via Racket Users


On 27/03/18 14:55, 'Paulo Matos' via Racket Users wrote:
> 
> 1. setup a profile command line argument that's passed to places-profile.rkt
> 2. send a flag indicating if we need profiling in any-double?
> 3. then use profile-thunk on the function if profiling is required, or
> nothing if profiling is not required.
> 

I have attempted this:
;; places-profile.rkt

#lang racket

(define (main)
  (define p
(dynamic-place "any-double.rkt" 'place-entry))

  ;; enable profiling
  (place-channel-put p #t)

  (for ([i (in-range 1000)])
(define l (build-list (random 1) (lambda (_) (random 100
(place-channel-put p l)
(place-channel-get p))

  (place-kill p))

(main)

;; any-double.rkt

#lang racket

(require profile)
(require profile/render-text)

(provide place-entry)

(define (any-double? l)
  (for/or ([i (in-list l)])
(for/or ([i2 (in-list l)])
  (= i2 (* 2 i)

(define (place-entry ch)
  (define profile? (place-channel-get ch))

  (profile-thunk
   (thunk
(let loop ()
  (define l (place-channel-get ch))
  (define l-double? (any-double? l))
  (place-channel-put ch l-double?)
  (loop)))
   #:periodic-renderer (list 4 render)
   #:use-errortrace? #t
   #:threads #t))



Unfortunately, every 4 secs I see:
Profiling results
-
  Total cpu time observed: 185393ms (out of 188238ms)
  Number of samples taken: 3727 (once every 50ms)


Caller
Idx  TotalSelfName+srcLocal%
 ms(pct)  ms(pct)   Callee



Absolutely no results. Why?

Also, if I reduce the number of iterations in places-profile.rkt to
1000, and remove the periodic-render, there's absolutely no output from
the profiler. Is this related with the killing of the place via
place-kill? Is there a nice way to kill a place and still preserve
profiling information?

-- 
Paulo Matos

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Profiling places

2018-03-27 Thread 'Paulo Matos' via Racket Users
Hello,

I was trying to confirm my suspicion that profile needs to be manually
setup in each place for profiling.

So I created (based on the example in the manual)

;; places-profile.rkt
#lang racket

(define (main)
  (define p
(dynamic-place "any-double.rkt" 'place-entry))

  (for ([i (in-range 1000)])
(define l (build-list (random 100) (lambda (_) (random 100
(place-channel-put p l)
(printf "~a: ~a: ~a~n" i l (place-channel-get p

(main)

;; any-double.rkt
#lang racket

(provide place-entry)

(define (any-double? l)
  (for/or ([i (in-list l)])
(for/or ([i2 (in-list l)])
  (= i2 (* 2 i)

(define (place-entry ch)
  (let loop ()
(define l (place-channel-get ch))
(define l-double? (any-double? l))
(place-channel-put ch l-double?)
(loop)))


Then in the command line:
$ raco profile --all-threads --use-errortrace --total places-profile.rkt
...
Profiling results
-
  Total cpu time observed: 142ms (out of 432ms)
  Number of samples taken: 7 (once every 20ms)


   Caller
Idx  Total Self  Name+src Local%
 ms(pct)   ms(pct) Callee

[1]  39(27.4%)  0(0.0%)  (main ...) ...e/pmatos/tmp/places-profile.rkt:12:0
   (for ...) [2]  100.0%

   (main ...) [1] 100.0%
[2]  39(27.4%)  0(0.0%)  (for ...) /home/pmatos/tmp/places-profile.rkt:7:2
   (printf ...) [3]   100.0%

   (for ...) [2]  100.0%
[3]  39(27.4%)  0(0.0%)  (printf ...) ...pmatos/tmp/places-profile.rkt:10:4
   (place-channel-get ...) [4]100.0%

   (printf ...) [3]   100.0%
[4]  39(27.4%) 39(27.4%) (place-channel-get ...) ...laces-profile.rkt:10:29



I didn't expect this to work, i.e. to get profiling information for
any-double? procedure. I am now wondering if there's any example out
there on how to actually perform the profiling. From the docs, I can
imagine how I could setup something like this:

1. setup a profile command line argument that's passed to places-profile.rkt
2. send a flag indicating if we need profiling in any-double?
3. then use profile-thunk on the function if profiling is required, or
nothing if profiling is not required.

Is this a possibility or is there something out there to make this
easier? Also, profile-thunk says that:
"To track all threads, specify a non-#f value for the threads?
argument—this will execute the computation in a fresh custodian, and
keep track of all threads under this custodian."

But what happens if the place itself creates its own custodian to launch
threads?

Kind regards,

-- 
Paulo Matos

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.