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
Start of new types on the client #4254
Conversation
The integration tests are failing because some packages have uint64 tlids. In dev, the one package created has a 64bit tlid. In production, about half the packages have 64bit tlids. It seems also that 1000 production toplevels have tlids above 2147483647 (all for some reason being a number like 1587041099384 but 156, 157, or 158. Also, int_of_string is crashing so we shouldn't use it anyway. But it looks like it will make sense to switch to 64 bit ints here if possible anyway :( |
Wait, if we json parse 64-bit ints, what makes it to rescript? 64bit ints or strings, or floats with missing precision? Does it matter whether they're a field in an array (as in the json representation of variants) or as ids in a dictionary). |
Parsing 64 bit ints gets us floats with a loss of precision. I wonder if we're safe to just convert the tlids in the DB to a lower precision (except for users editing). I don't think tlids are used except to tell the apiserver what db/handler is being deleted. |
They are binary serialized into ops. Ugh. |
Related: the expression OCamlTypes has a string in EInteger and FPInteger, which is why programs stay valid using OCamlTypes (when sent back and forth from the apiserver). But dvals don't! Either when sent from a trace, or when sent back from Wasm. But, I think if we encoded tlid and int64 as strings when they're too big, we could handle this ok. |
971e1ac
to
bb21b0e
Compare
OK, the plan here is to serialize |
bb21b0e
to
795dcc6
Compare
This addresses all the issues by creating a UInt64 type (backed by a combination of BigInt for printing/serialization as strings, and Int64 for use in-memory), and then using UInt64 for the TLID/ID types. Numbers over 2^53 are serialized as strings because JSON has a 53bit limit for integers being represented accurately as themselves. |
72f4b2c
to
09a04b5
Compare
Corrects some other types on the way
Test suite slowed down 3x just from using a U.UInt64.t from bs-zarith. However, it still makes sense to use the string functions from U.UInt64.
Also improve comments and remove dead code
09a04b5
to
ca198a4
Compare
Summary and descriptionThis has gone on a while, so I'm going to restate it all. Originally, this started as an attempt to replace client types with the types used by the server. And indeed, this adds those types. However, after I made a few subsequent changes, it got big enough that now it's time to stop and get this merged. The major change was changing the type of TLIDs (and IDs). The backend used uint64s, and the client used strings. Using strings led to some pretty bad situations: the backend used uint64s and so while it was mostly fine to use uint64-encoded-as-strings, in practice we snuck in lots of things that weren't uint64s. In some cases, those were test items like The attempt to switch to a real As a result, it made more sense to come back to using Both uint64 and int64 use 64 bits. There wasn't tooling to just cast them between each other, so I explicitly made the translation (using the negative int64 range to hold the values above the positive int64 range). The complexity here was converting negative int64s to positive uint64s, especially during stringification (needed for encoders and decoders). For that, I used JS BigInts - this allowed me more range, and also to use their Along the way I tried a bunch of other things, but they all came out more complex in one way: encoding it as a tuple of 2 int32, manually scaling int64s, my own version of This PR also:
|
| Rail | ||
| NoRail | ||
|
||
and expr = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this file include some Tuple types? it doesn't right now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it should. Wrote this before they merged, nice catch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it feels a bit offputting to use negative values to represent those out of bounds, but I can't think of anything better. Looks good!
Yeah. The other option is to keep the type opaque and use strings. Any preferences? |
Not really, they're both kinda bad :) So might as well go with the thing we've already coded. |
10035f5
to
4e80ac3
Compare
This started as an attempt to move all the client types to match the backend ProgramTypes and RuntimeTypes, but it got to be a lot so I stopped early. So far, just all this really does is updates ID/TLIDs to use int32s, and fixes the fallout (and adds a few types that aren't used yet).