-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
playground examples don't work with --scheme-numbers enabled #327
Comments
That seems like an error from the jsnumbers library having to do with it's implementation of bigints. What playground example are you getting that error with? It looks like most of the examples break with |
I'm still investigating but the examples themselves actually seem ok (I ran the ones I could offline). So the error must happen while it's getting loaded |
The previous error I posted was a red herring i think. It looks like the actual problem is due to scheme numbers getting passed to js functions Here is a basic example that does not render properly in the playground #lang racketscript/base
(require racketscript/htdp/image)
(print-image (text "RacketScript" 48 'black)) What is happening is that the compilation of
I think this shows that |
Update: Still unconfirmed whether it worked, but we ran into a variation of the issue (sort of the dual to the above). Currently in this situation, they are treated as exact integers (the current design decision comes from the original https://github.com/dyoo/js-numbers library) (https://github.com/dyoo/js-numbers/blob/2cf776f6017858a30488a4ec768be3e67bb0a6c4/src/js-numbers.js#L29-L31):
But in racketscript, the unboxed number does not have to be an integer and currently this scenario is unhandled by the original library, which can cause problems To address this gap, here is our new proposed treatment of unboxed numbers that flow back into the numbers library:
@kclapper Please clarify if needed |
It occurred to me that using I'll take a look at how much slower it would be. The actual implementation of the functions can unbox them where appropriate so hopefully the slow down isn't terrible. |
Good point. Why dont we just do it the straightforward way first (use |
I think I'm not quite sure what you mean. Tower.js already turns I think the issue is that, if tower.js functions return a I did a few microbenchmarks to see if there's a significant slowdown if tower.js functions always return the boxed representation instead, it doesn't appear to have a significant impact (because the implementation unboxes it when possible before doing the computation anyway). So I'd suggest we revise our treatment of unboxed numbers to this: For input to a tower.js function:
For output from a tower.js function:
In the implementations of the tower.js functions, boxed numbers will be unboxed where possible so they execute on a fast path. |
I guess I was suggesting that |
Oh I see. This is feasible but we'd decided it was undesirable. The only way to distinguish between an exact and inexact I think my suggestion would actually work out fairly well. Since all Inexact numbers are being returned as boxed numbers right now, we may end up with fewer boxed values floating around anyway (for computations using a lot of inexact numbers). |
Ok sounds good. Let's try your proposal |
Edit: I was incorrect, these benchmarks are with With micro-benchmarks on the
To better rule out garbage collection time, I force Node to garbage collect before it runs trials on each case (js-numbers vs tower.js vs javascript). Right now, it's running 100 trials per case. If you force Node to garbage collect between each trial within a case instead, tower.js is faster every time. This likely means tower.js is allocating more objects than js-numbers. |
Here is the same benchmark but with the unboxed number representation I suggested. To recap: For input to a tower.js function:
For output from a tower.js function:
Benchmark summary:
Tower.js gives us better interop with plain JS at the cost of speed in the case of exact integers. It also gives us faster big number and inexact number computations. This is an isolated benchmark, so I'll need to see if these results hold in other cases as well.
|
Turns out this scheme is pretty slow for common fast functions like
No use of bigint's other than for representing big boxed numbers. |
Still investigating but I'm frequently getting this (codemirror?) error:
Uncaught TypeError: Cannot read properties of undefined (reading 'chunkSize')
The text was updated successfully, but these errors were encountered: