sorawee
2020-3-10 10:46:28

I have a random thought that I don’t know if it makes sense.

Should there be another construct that is just like case-lambda, but is informally required that the behavior of the fixed arity cases must match that of the variadic case? It looks like most usage of case-lambda has this described characteristics anyway. With this new construct, we can automatically verify the correctness of the “optimized” cases (assuming there’s a verifier) confidently.


tim986
2020-3-10 11:21:33

I’m having issues installing drracket with homebrew on Mac Catalina… I’ve brew install minimal-racket and gotten racket 7.5; but raco pkg install --auto drracket then tries to download and install and fail v. 6.10.1

Better yet, something seems to install 6.10.1 in my Cellar directory :cry: Can someone help please?


ryanc
2020-3-10 11:35:47

My opinion: This doesn’t sound like a good case for a new language construct, especially for a hypothetical verifier. If by “verify” you mean “test”, then I would treat this as a special case of the general testing pattern where you write two implementations (one naive and one “practical”) and test that they agree—except that in this case, the practical implementation falls back to the naive/general implementation for part of its domain. For other notions of verification, it’s still often (?) easier to deal with external proof/verification of equivalence/correspondence rather than dealing with one object that contains the two things and carries the verification with it.


ryanc
2020-3-10 11:50:28

Tangent: There are well-known tradeoffs between the traditional FP (datatypes and case analysis) and OO (interfaces and methods) approaches to representing information (cf initial vs final algebras). It seems to me that verification has the same spectrum: external theorems (easy to add new theorems/properties, hard to add new variants) vs proofs carried within values (easy to add new variants, hard to add new properties). It’s a bit more complicated, because you can mix an FP approach to computation and an OO approach to properties… I need to think about this more.


sorawee
2020-3-10 13:46:23

@mflatt: this program:

#lang racket sort list expands very weirdly.


sorawee
2020-3-10 13:46:42

sorawee
2020-3-10 13:47:58

Here’s a side-by-side of syntax object information of sort7.1 and list. Somehow source location of sort7.1 is missing.


sorawee
2020-3-10 13:48:20

The same problem happens in Rosette, which defines its own sort (but not in other languages like #lang lazy)


sorawee
2020-3-10 13:49:35

The problem that this “bug” causes for me in particular is that sort in the expanded code is not free-identifier=? with sort exported from Rosette.


sorawee
2020-3-10 13:52:45

As far as I know, sort seems to be the only identifier that has this issue in Rosette. Other identifiers exported similarly don’t have this problem.


mflatt
2020-3-10 14:05:53

The sort function is implemented with define and keyword arguments, which means that the provided identifier is a macro that can optimize the delivery of keyword arguments. So, sort expands to a different identifier defined in the exporting module.


mflatt
2020-3-10 14:07:25

The question of transferring source locations from one identifier to another in an expansion is tricky. Sometimes you want the source of the identifier in the macro, and sometimes you want the source of the macro use. But the latter is also available via the origin property.


mflatt
2020-3-10 14:08:44

In any case, the sort... identifier in the expansion really is a different identifier with a different binding, so that’s why it’s not free-identifier=? to the unexpanded sort identifier.


sorawee
2020-3-10 14:09:02

Ah, that makes sense.


sorawee
2020-3-10 14:09:16

Thanks!


capfredf
2020-3-10 14:15:14

can you post the error messages?


capfredf
2020-3-10 14:18:23

or you can try brew cask install racket


sorawee
2020-3-10 15:58:40

And just to be sure, I can use syntax-procedure-alias-property to get an identifier to free-identifier=?, correct? I’ve tried it with a bunch of examples so far and it seems to work well.



leif
2020-3-10 19:07:05

Does anyone know where the latest proposal for the (non s-exp) version of Racket 2 is?



ecb10
2020-3-10 19:38:39

I don’t know if this is of interest to anyone, but I now have an Idris 2 parser written in Idris 2, that compiles via Racket-on-Chez, or via Chez


ecb10
2020-3-10 19:38:52

the curious thing is that the racket-on-chez version takes about 3 times as long as the chez version…


ben
2020-3-10 19:44:35

@ryanc should (syntax? this-syntax) always be true in a syntax class pattern? Because its not true here: #lang racket/base (require syntax/parse) (define x '(A B C)) (define stx (datum->syntax #'here x)) (define-syntax-class any-syntax (pattern _ #:when (syntax? this-syntax))) (syntax-parse stx ((_ . :any-syntax) (void)))


leif
2020-3-10 19:53:49

That’s a-okay. Thank you. :slightly_smiling_face:


ben
2020-3-10 19:55:04

after talking to leif I’m thinking the answer is “no, because it can be a syntax pair” (in that case typed racket has the bug)


badkins
2020-3-10 19:58:14

That doesn’t sound good. Are you referring to the time to compile the parser, or the run time of the compiled parser? Also, can you post links to source to help someone look into this if there is interest?


ecb10
2020-3-10 20:02:56

I mean the run time. I can post the source somewhere, though it is horrific generated stuff…


ecb10
2020-3-10 20:03:15

I realise my use case is not normal :)


ryanc
2020-3-10 20:18:49

Right, syntax pairs are the problem. I probably should have made this-syntax coerce to syntax, but that causes other complications; for example, the easiest “fix” would have the property that (eq? this-syntax this-syntax) might be false.


badkins
2020-3-10 20:20:00

Sure, but with a 3 to 1 run time differential, maybe it provides a good stress test of RacketCS for the core team to look at.


ryanc
2020-3-10 20:20:53

The second easiest fix potentially causes performance problems on long syntax lists.


samth
2020-3-10 20:45:10

Yes, a data point would be great


ecb10
2020-3-10 20:45:53

Where should I send my terrible code?


ecb10
2020-3-10 20:46:40

I wondered if there was some difference in some primitives. Other small examples I’ve tried have been fairly equal between the two.


samth
2020-3-10 20:47:09

I think a bug report on racket/racket or a mailing list pot would both be good


samth
2020-3-10 20:47:46

The major things that are a lot slower are unlikely to be your problem, like floating point intermediate values


ecb10
2020-3-10 20:48:11

Righto, I’ll do that when I’m back at a computer with a keyboard.


samth
2020-3-10 20:48:21

One possibility is that you’re using mutable pairs


samth
2020-3-10 20:48:28

Which are indeed slower


samth
2020-3-10 20:48:44

And which you probably don’t want anyway


ecb10
2020-3-10 20:48:51

I don’t deliberately use mutable anything, but I am a racket novice so I may be doing something daft


samth
2020-3-10 20:49:03

Are you using r6rs


ecb10
2020-3-10 20:49:11

Mostly it’s creating and reading vectors


ecb10
2020-3-10 20:49:16

I don’t think so…


samth
2020-3-10 20:49:38

Ok then that also seems unlikely


ecb10
2020-3-10 20:50:20

The chez parser is faster than the Idris 1 parser so I want this to work :)


samth
2020-3-10 20:53:10

The other other possibility is that you’re doing a lot of compiling that takes much longer in Racket


samth
2020-3-10 20:53:53

If you can target Racket CS then presumably you can also target old Racket, and a performance comparison there would be illuminating


ecb10
2020-3-10 20:53:56

What do you mean by compiling here? The compilation is slower, but I’m just talking about the executable time


samth
2020-3-10 20:54:21

Are you evaling any code at runtime?


ecb10
2020-3-10 20:54:44

No, nothing like that


ecb10
2020-3-10 20:55:16

I’m using it as a glorified lambda calculus


ecb10
2020-3-10 20:55:52

If I run the rkt file through racket does that give me old Racket?


samth
2020-3-10 20:55:59

Yes


ecb10
2020-3-10 20:56:11

That’s about 3–4 times slower again


samth
2020-3-10 20:56:30

Assuming that you were running it through racketcs to test Racket on Chez


samth
2020-3-10 20:56:47

Interesting


ecb10
2020-3-10 20:57:09

That was compiled to an executable


ecb10
2020-3-10 20:59:48

I don’t have racketcs apparently, but I believe I’m using racket on chez because I see: edwin@yaffle:~/Research/Idris2-SelfHost/src$ racket Welcome to Racket v7.4 [cs].


samth
2020-3-10 21:00:29

First I’d try 7.6


ecb10
2020-3-10 21:00:54

aha. I will do that (I have retrieved my computer with a keyboard :))


samth
2020-3-10 21:00:59

If that’s the case then running racket foo.rkt runs RacketCS as well


samth
2020-3-10 21:01:20

And so you could also try downloading traditional Racket


samth
2020-3-10 21:01:52

The performance difference you saw was almost certainly compile time


samth
2020-3-10 21:02:11

Run raco make foo.rkt to precompile


ecb10
2020-3-10 21:02:59

I build with raco exe - is that wrong?


samth
2020-3-10 21:03:07

No that’s fine


samth
2020-3-10 21:03:44

But raco make will compile the file and be used when running racket programs generally


samth
2020-3-10 21:04:10

Whereas raco exe creates a separate executable but doesn’t change the behavior of the existing program


ecb10
2020-3-10 21:04:53

I wouldn’t be surprised if running racket on the .rkt source had quite an overhead, so I’m hoping my 3x difference has nothing to do with that


ecb10
2020-3-10 21:05:02

anyway, 7.6 is downloading…


ecb10
2020-3-10 21:05:23

honestly I’m delighted that this works at all :slightly_smiling_face:


samth
2020-3-10 21:05:27

The raco exe time should not include compilation time


soegaard2
2020-3-10 21:05:35

@programminglinguist Try again with version 7.6. Maybe ask the mailing list if you encounter the same problem.


ecb10
2020-3-10 21:05:37

right, that’s what I expected


samth
2020-3-10 21:10:36

That’s what it’s for


ecb10
2020-3-10 21:10:43

Good news: 7.6 is quicker when running in the .rkt file directly


samth
2020-3-10 21:10:45

Typed Racket uses it similarly


ecb10
2020-3-10 21:10:57

Bad news: It’s pretty much the same when compiled to an executable


samth
2020-3-10 21:11:17

What about running it after raco make


ecb10
2020-3-10 21:12:38

I get an error…


ecb10
2020-3-10 21:13:37

ah, just a paths issue


ecb10
2020-3-10 21:13:49

but once that’s resolved, about the same again (1.4s)


ecb10
2020-3-10 21:14:46

I’ll post full details of what I’m up to somewhere tomorrow anyway, just in case it’s useful to anyone. It’d be interesting to know why the difference.


ecb10
2020-3-10 21:14:58

I’m guessing there’s some important detail I just don’t know yet.


samth
2020-3-10 21:15:09

That’s what I expected for raco exe vs racket


ecb10
2020-3-10 21:15:27

right, that makes sense


samth
2020-3-10 21:15:31

If you just can post the racket file somewhere I’ll look at it


ecb10
2020-3-10 21:16:12

(fwiw the sum of raco make and the executable is close to running racket directly…)


samth
2020-3-10 21:16:25

That is also to be expected



ecb10
2020-3-10 21:18:41

(Yes I am testing the parser on itself :))


ecb10
2020-3-10 21:19:43

please try not to be too horrified by the generated racket…


samth
2020-3-10 21:20:20

you definitely seem to be using r6rs


samth
2020-3-10 21:20:22

```


ecb10
2020-3-10 21:20:26

hmm


samth
2020-3-10 21:20:31

[samth@huor:/tmp/edwin plt] raco make -v testparse.rkt && time racket testparse.rkt Parser.idr "testparse.rkt": [already up-to-date at "compiled/testparse_rkt.zo"] Parsed okay real 0m1.418s user 0m1.348s sys 0m0.072s [samth@huor:/tmp/edwin plt] racocs make -v testparse.rkt && time racketcs testparse.rkt Parser.idr "testparse.rkt": making #<path:/tmp/edwin/testparse.rkt> [output to "compiled/ta6le/testparse_rkt.zo"] Parsed okay real 0m1.320s user 0m1.280s sys 0m0.040s


samth
2020-3-10 21:20:42

so a little bit faster with racketcs


ecb10
2020-3-10 21:20:53

ah, for ports and bytevectors


ecb10
2020-3-10 21:21:06

does this affect other stuff?


samth
2020-3-10 21:21:17

probably not


samth
2020-3-10 21:26:00

ok i ran a quick profile and my first hypothesis is that Racket’s promise implementation is much slower than Chez’s, I think because it’s thread-safe


ecb10
2020-3-10 21:26:26

Oh, there will be quite a bit of that going on here since it’s used for the totality of the parser


samth
2020-3-10 21:26:35

I would try implementing your own promises with lambda and set! and a delay macro, and see if that changes things


ecb10
2020-3-10 21:27:00

It is more or less trivial to do what I need with a lambda


ecb10
2020-3-10 21:27:09

I’ll try that now…


ecb10
2020-3-10 21:27:42

I don’t need to cache results in this case, at least


samth
2020-3-10 21:29:36

[samth@huor:/tmp/edwin plt] time racketcs testparse.rkt Parser.idr Parsed okay real 0m0.931s user 0m0.856s sys 0m0.076s [samth@huor:/tmp/edwin plt] time racket testparse.rkt Parser.idr Parsed okay real 0m0.890s user 0m0.819s sys 0m0.072s


ecb10
2020-3-10 21:29:38

What I really want to do is partially evaluate the parser with the grammar. But that would involve some actual research and probably lead to a publication. Obviously that’d be good, but more work than I want for this case!


samth
2020-3-10 21:30:15

that’s with this implementation:

(define-syntax-rule (delay e) (lambda () e)) (define-syntax-rule (force e) (e))


ecb10
2020-3-10 21:31:27

Wow. I get a huge win with a similar thing.


ecb10
2020-3-10 21:31:48

The bad news is that Chez is still 3 times faster!


ecb10
2020-3-10 21:32:06

Down to 0.3s


samth
2020-3-10 21:32:06

yes, but we’ve ruled out one thing


samth
2020-3-10 21:32:58

next I’d try switching byte vectors for the native racket data structure


ecb10
2020-3-10 21:33:04

(The Idris 1 generated parser takes 0.45s on this file, without the vm start up cost, so I already know I’m never going to try implementing a run time system again)


samth
2020-3-10 21:33:20

I think the r6rs ones are probably a wrapper


samth
2020-3-10 21:33:23

same with ports


ecb10
2020-3-10 21:33:53

Byte vectors are only used for saving out checked files so unlikely to be the cost here. Still worth changing later though if that’s a big difference.


samth
2020-3-10 21:34:02

(of course, the r6rs ones are the chez interface which the racket ones are implemented on top of)


samth
2020-3-10 21:34:47

(but the r6 on racket on chez versions have two levels of translation instead of 0)


ecb10
2020-3-10 21:36:25

The thing with promises is that Scheme works a lot harder to avoid recomputation than Idris 1 does. In Idris, it’s really just about delaying computation. It is equivalent to wrapping it in a lambda.


ecb10
2020-3-10 21:36:46

I’d never have noticed that. Thanks!


samth
2020-3-10 21:37:03

chez is of course also avoiding recomputation


samth
2020-3-10 21:37:13

so maybe actually doing that but in a cheap way is the right thing


ecb10
2020-3-10 21:37:53

there’s clearly something else still going on. But that’s already a huge win!


samth
2020-3-10 21:39:07

avoiding recomputation makes things a little slower in my tests


samth
2020-3-10 21:49:07

looks like string->bytes conversion shows up high on the profile


ecb10
2020-3-10 21:50:20

Hmm, that isn’t something I’d expect. The Idris code reads the file and turns it into a list of characters before tokenising


ecb10
2020-3-10 22:02:11

Incidentally I find racket does a much better job of profiling than chez


ecb10
2020-3-10 22:02:55

Chez only tells me what was called more, but racket tells me where time was spent


samth
2020-3-10 22:03:23

There are drawbacks, as well, since Racket is sampling


ecb10
2020-3-10 22:05:47

I’ve generally found that sampling is more helpful, but mileage may of course vary


feynman24
2020-3-10 23:09:49

@feynman24 has joined the channel


tgbugs
2020-3-11 00:11:43

Tangentially related to this thread. Is it possible to have both compiled BC and compiled CS at the same time for the same file? I seem to recall Matthew saying that this would not initally be possible, but I have been known to miss/insert those pesky nots before.


cangyufu
2020-3-11 00:22:21

@cangyufu has joined the channel


samth
2020-3-11 00:26:42

Yes, that’s certainly possible. For example, if you build from git, then you can have both racket and racketcs and compiling for one will not interfere with the other