pocmatos
2018-11-12 08:41:30

All, I am having a go at porting some of my code to Typed Racket to understand impact in performance. Interestingly, when I call place/context, the type checker tells me instead the problem is with place/proc: driver.rkt:135:4: Type Checker: missing type for identifier; consider using `require/typed' to import it identifier: place/proc from module: racket/place in: (for/list ((i (in-range cores))) (place/context ch (define s (solve/single authdata diff i)) (place-channel-put ch s)))


pocmatos
2018-11-12 08:42:16

So, now shall I require/typed place/context or place/proc?


pocmatos
2018-11-12 08:42:56

Also, strange that typed racket knows of type Place but not of place/context


pocmatos
2018-11-12 08:56:07

Interesting, actually place/proc is not provided so I can’t type it but I don’t think I can type place/context either since it’s a macro.


popa.bogdanp
2018-11-12 09:06:32

I’ve noticed the documentation about several concepts doesn’t go into details about how those concepts work/are implemented at lower levels. For places, I had to read place.c and mzrt.h to figure out that places use posix threads/win32 threads based on the operating system (my first guess would’ve been processes communicating via IPC). I was similarly confused about threads initially, wondering whether they were green threads or system threads with a GIL, though some part of the documentation did answer that question for me (I don’t think it was the threads reference, however).

Is this a conscious choice to hide those details from the reader/user so that the runtime is free to change them as it sees fit?


soegaard2
2018-11-12 09:13:52

This could give us a Racket prompt on ios: https://ish.app/


pocmatos
2018-11-12 09:14:35

@popa.bogdanp I don’t think it’s a problem to hide the implementation details. after all the user shouldn’t care about it and the documentation is clear that places use OS threads.


pocmatos
2018-11-12 09:15:04

My question was due to the fact that the typed racket error mentions a function that is not provided and the user should not need to care about.


pocmatos
2018-11-12 09:15:25

At the same time, it feels like it might be tricky to type this one. Surely @samth can enlighten us.


sorawee
2018-11-12 09:17:34

Is it a known issue that syntax/module-reader is brittle with respect to the directory that the file is in?

For example, let’s say we have:

;; /path/to/raquet.rkt
#lang s-exp syntax/module-reader
"raquet-mlang.rkt"

;; /path/to/raquet-mlang.rkt
#lang racket
(provide (except-out (all-from-out racket) lambda)
         (rename-out [lambda function]))

;; /path/to/a.rkt
#lang reader "raquet.rkt"
(define identity (function (x) x))
(print (identity 5))

This is an example from https://docs.racket-lang.org/guide/syntax_module-reader.html whick works without any problem.

Now, create a new file:

;; /path/to/test/b.rkt
#lang reader "../raquet.rkt"
(define identity (function (x) x))
(print (identity 5))

Running it, we get this error:

/path/to/test $ racket b.rkt
open-input-file: cannot open module file
  module path: /path/to/test/raquet-mlang.rkt
  path: /path/to/test/raquet-mlang.rkt
  system error: no such file or directory; rktio_err=3

popa.bogdanp
2018-11-12 09:18:37

I didn’t mean to imply that it was! But the documentation wasn’t clear to me that places use OS threads. :slightly_smiling_face:


popa.bogdanp
2018-11-12 09:19:36

All it really says is that places let you take advantage of multiple CPUs, cores or hw (hyper) threads.


popa.bogdanp
2018-11-12 09:20:44

And so when I read that I saw two options: either they were implemented using OS threads or using processes; but the docs didn’t tell me which and the performance characteristics for either are different.


samth
2018-11-12 14:04:43

@pocmatos indeed the user shouldn’t need to care about it, but this is a limitation of how TR works that you do, in fact, have to care about it


samth
2018-11-12 14:05:40

adding types to the place form will require somewhat more work than just using require/typed


pocmatos
2018-11-12 14:06:43

Well, you certainly need to care about if need to extend typed racket to support the place form.


pocmatos
2018-11-12 14:07:35

I am surprised, why support the Place but not the place form? Is it expected from users to move place calls to the untyped world?


samth
2018-11-12 14:09:14

note that dynamic-place works already


samth
2018-11-12 14:09:43

as you note, place is trickier


samth
2018-11-12 14:10:00

but we should try to support it


samth
2018-11-12 14:11:50

the place form expands to a submodule, which it’s not immediately obvious how to handle


pocmatos
2018-11-12 14:14:28

Ah, understood. I will switch this part to using dynamic place and see what happens.


pocmatos
2018-11-12 14:14:42

Right - makes sense. Dynamic place is a function, not syntax.


popa.bogdanp
2018-11-12 14:23:14

It’s been over 24h since I’ve published my first package (https://pkgd.racket-lang.org/pkgn/package/component-lib) and it still doesn’t have any builds. I’m wondering if I did something wrong or if I skipped some vital step. Reading the source of pkg-index it looks like packages with changes should be built every hour, but I can’t figure out why this one isn’t. Any ideas?


samth
2018-11-12 14:24:27

@popa.bogdanp every hour, the index of packages is updated (which indeed has happened for your package)


samth
2018-11-12 14:24:49

every 24 hours http://pkg-build.racket-lang.org\|pkg-build.racket-lang.org runs, but it might not be done with this morning’s run yet


popa.bogdanp
2018-11-12 14:25:40

Ahh, okay. Thank you for clarifying!