wanpeebaw
2020-4-21 09:51:55

I ran this on DrRacket and Racket REPL, the performance difference is huge. In DrRacket it’s about 16x slower than in Racket REPL. In DrRacket: > (time (for ([i (in-range 10000000)]) (void))) cpu time: 115 real time: 115 gc time: 0 In Racket REPL: > (time (for ([i (in-range 10000000)]) (void))) cpu time: 7 real time: 7 gc time: 0 Does anyone know how to make it run as fast as REPL in DrRacket?


spdegabrielle
2020-4-21 10:01:14

I don’t think you can make it run as fast, but you can speed it up by turning off debugging and profiling in the language details.


spdegabrielle
2020-4-21 10:04:08

you have to click details in the language menu



wanpeebaw
2020-4-21 13:56:53

@spdegabrielle Thanks, after turn off debugging and profiling, it becomes. cpu time: 20 real time: 20 gc time: 0


wanpeebaw
2020-4-21 13:58:18

If I disable Preserve stacktrace, I got. cpu time: 7 real time: 7 gc time: 0 Which is pretty good.


wanpeebaw
2020-4-21 14:06:44

However, conventional development environments usually separates debugging build/run from normal build/run. Don’t know if DrRacket can do the same?


spdegabrielle
2020-4-21 14:09:17

That’s a q for the developers I think - maybe ask in #general


samth
2020-4-21 14:27:00

@wanpeebaw Isn’t that what the button is doing?


soegaard2
2020-4-21 14:32:15

An easy to find drop-down to switch between w/wo debugging, w/wo profiling would be a good thing. New-comers are always suprised that DrRacket instruments the code before running it.


soegaard2
2020-4-21 14:32:31

Perhaps with a “triangle dropdown”.


soegaard2
2020-4-21 14:32:51

soegaard2
2020-4-21 14:33:05

(from Geogebra)


lexi.lambda
2020-4-21 14:34:11

I think you can think of a pict like it’s a sort of image format, though it’s closer to something like SVG or Postscript than a bitmap. But picts are also immutable, so you can’t draw “into” one. pict can’t implement dc<%> because dc<%> works by modifying the underlying canvas, which is incompatible with pict’s model.


lexi.lambda
2020-4-21 14:37:26

With pict you can do something like (hc-append p (scale p 2)) and it all works out nicely—you get two of the same pict side by side, one of them at twice the size. But if pict implemented dc<%>, drawing “into” it would affect both picts (and any other picts derived from those ones), which is undesirable.


wanpeebaw
2020-4-21 16:10:53

@soegaard2 This is how IntelliJ IDEA’s run/debug toolbar looks. And the hot-key are ^R for Run and ^D for Debug.


wanpeebaw
2020-4-21 16:11:09

wanpeebaw
2020-4-21 16:38:10

This is Xcode’s menu, which also separate Run from Test and Profile.


notjack
2020-4-21 17:09:03

@wanpeebaw the issue is that Racket without any debugging or profiling is much harder to debug than Java without any debugging or profiling. Java exceptions still get stack traces when running normally. Racket exceptions don’t, and the handling of tail calls means getting something approximately like a useful stack trace is not possible without instrumenting the code in the way DrRacket does. That’s why it’s on by default instead of off by default.


samth
2020-4-21 17:12:33

Racket exceptions get stack traces even without any of the instrumentation, although it’s not as good with errortrace and with inlining disabled.


notjack
2020-4-21 17:14:41

How not-as-good are they?


samth
2020-4-21 17:16:25

Without errortrace, you only get functions, not expressions (similar to what you’d see in Java). With inlining on, you can miss lots of frames that are relevant. Combined with tail calls, it can be a lot worse, but I basically never have them on unless I need specifically to help debugging something.


notjack
2020-4-21 17:18:26

What’s the default when running racket at the command line?


samth
2020-4-21 17:18:48

errortrace is not on, and inlining is enabled


notjack
2020-4-21 17:24:06

ah, is that what people using racket-mode also see?


samth
2020-4-21 17:24:24

I believe so, but @greg knows for sure


greg
2020-4-21 17:38:11

@greg has joined the channel



greg
2020-4-21 17:41:06

I usually default it to medium. If an error message isn’t specific enough, I re-run with the C-u prefix to get high temporarily.


greg
2020-4-21 17:41:35

high can be slow. So I like this combo of “medium by default, high if/as/when helpful”.


samth
2020-4-21 17:41:48

what is the default default?


greg
2020-4-21 17:41:49

@jack ^


greg
2020-4-21 17:42:13

Derp. @notjack ^


greg
2020-4-21 17:42:53

@samth The default default is medium.


greg
2020-4-21 17:43:17

So just compile-context-preservation-enabled #t.


greg
2020-4-21 17:48:41

btw if you do run with high, i.e. errortrace instrumentation, if you use a time expression the REPL prints a comment: ; Warning: time or time-apply used in errortrace annotated code. ; For meaningful timings, use command-line racket instead!


greg
2020-4-21 17:48:49

(in Racket Mode)


greg
2020-4-21 17:49:40

I added that mainly to help myself, after posting a couple performance “measurements” on Racket Users, then later feeling embarrassed. :smile:


greg
2020-4-21 17:50:27

“I am here to inform you about an important micro-benchmark I have observed!” …. “Oh. Derp.”


wanpeebaw
2020-4-21 18:15:06

I have to say that the first impression of the performance greatly affect the adoption rate of the language. Especially when people in the industry try to evaluate whether to use this language in their products.


spdegabrielle
2020-4-21 18:50:30

I think it is a good point - DrRacket by default has debugging on even if you your press run. This is confusing for people coming from other IDE’s where you explicitly choose to debug.


diallo.ms
2020-4-21 19:37:50

Hello. It is possible to create a structure without field like: (define-struct none []) Are there examples that show the usefulness of such a structure ? Thank you !


soegaard2
2020-4-21 19:38:26

Yes. That’s possible.


soegaard2
2020-4-21 19:39:47

When you define a struct using struct you can give a struct a “super” struct. (struct name-of-a-struct name-of-super-struct (field …))


soegaard2
2020-4-21 19:40:16

The new struct name-of-a-struct now gets the same fields as name-of-super-struct did plus the new fields field …


soegaard2
2020-4-21 19:40:57

It make it easy to make a “hierarchy” of structs.


diallo.ms
2020-4-21 19:41:21

I understand. Thank you !


popa.bogdanp
2020-4-21 19:41:32

Another use case may be to create canary values.


soegaard2
2020-4-21 19:41:56

In metapict I have this example: ;;; Labels (struct label (string-or-pict pos plc) #:transparent) ;;; Label placements (struct placement ()) (struct lft placement()) ; left (struct rt placement()) ; right (struct top placement()) ; top (struct bot placement()) ; bottom


soegaard2
2020-4-21 19:42:44

Now placement? will work on lft, rt, etc structs.


diallo.ms
2020-4-21 19:43:23

Thank you !


greg
2020-4-21 19:44:45

@popa.bogdanp I have a guess, but not sure: What do you mean by “canary” values?


popa.bogdanp
2020-4-21 19:48:03

A singleton value that is easy to recognize, like:

(define-values (canary canary?) (let () (struct canary ()) (values (canary) canary?))) if my API exposes canary to a user, then it can easily recognize that specific value and the user can’t create any new ones like it.


popa.bogdanp
2020-4-21 19:48:29

I feel like I’ve used this in Racket libraries a few times, but I can’t think of any examples off the top of my head.


greg
2020-4-21 19:50:02

@wanpeebaw I agree that can be important (although there are many counter-examples). Just to be clear, I was talking about myself in the past being excited I’d discovered some performance issue with Racket… but I’d only discovered something about errrotrace annotated code. I was poking fun at myself.


popa.bogdanp
2020-4-21 19:50:54

There are other ways you could achieve the same sort of thing, but I like (ab)using structs for this because they also print nicely


greg
2020-4-21 19:50:56

Maybe eof and eof-object? ?


popa.bogdanp
2020-4-21 19:51:05

Ah, yep, perfect example


greg
2020-4-21 19:51:24

Got it. Thanks.


soegaard2
2020-4-21 19:51:49

I think I would call those values singletons or perhaps unique values.


popa.bogdanp
2020-4-21 19:52:15

Well, they are singletons, but the ability to recognize them is also important


popa.bogdanp
2020-4-21 19:52:27

Which isn’t necessarily required for a singleton


soegaard2
2020-4-21 19:52:36

True.


soegaard2
2020-4-21 19:53:50

In the good old days (in the r5rs-era) I used (list 'canary) to produce such values. These days I use structs too.


greg
2020-4-21 19:54:05

That reminds me of some history of “undefined” in Racket… but that history is maybe not #beginners material


soegaard2
2020-4-21 19:55:03

That’s a true canary!


arunsk.tec
2020-4-21 19:59:21

@arunsk.tec has joined the channel


samdphillips
2020-4-21 20:14:31

Rebellion has a singleton type that automates a bit of the creation of such a type: https://docs.racket-lang.org/rebellion/Singleton_Types.html


notjack
2020-4-21 20:15:09

It also has enum types for creating multiple singletons with a shared predicate https://docs.racket-lang.org/rebellion/Enum_Types.html


notjack
2020-4-21 20:16:25

singleton types: (define-singleton-type null) > null #<null> > (null? null) #t enum types: (define-enum-type direction (north south east west)) > north #<direction:north> > (direction? south) #t


notjack
2020-4-21 20:17:58

@wanpeebaw I agree, but also see Python


chas
2020-4-21 20:52:18

@chas has joined the channel


johnsmithaaa100
2020-4-21 22:27:42

@johnsmithaaa100 has joined the channel


wanpeebaw
2020-4-22 05:59:51

@notjack Well, better to have both, ease of use and yet very efficient.


wanpeebaw
2020-4-22 06:03:47

When I started to learn Racket, due to the slow startup time and huge memory consumption of DrRacket, the overall impression given to me was that it’s very inefficient.

After done some micro-benchmark, it did show that it did not perform well (Now I know it’s due to the debugging stuff), and It did make me hesitate. But I still want to try it, because I am very interested in its expressiveness. And I’m happy to find out it’s actually quite fast.

My point is, the impression of this language is not very efficient, which is bad, and will scare some people out. It would be better if not the case. :slightly_smiling_face: