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.