> This has tanked my performance to the point where the tests for > non-scalar types (vectors and hashes) time out on the package > server, and thus fail. > https://gitlab.com/HiPhish/MsgPack.rkt/commit/0b6cdc7115389db97a8de2a5175c1feb4c939f8f
The performance is probably because HashTable and Vector values can be mutable, so Typed Racket needs to do extra work to protect them. To test this, I cloned msgpack, removed `Vector` from the `Packable` type, and changed `HashTable` to `Immutable-Hashtable`. Change here: https://gitlab.com/bennn1/MsgPack.rkt/commit/2a711200ad0efa1b974a3e5454f69d7004a74996 When I run the tests in test/pack/map.rkt, I see: - 40 seconds with the types on master - 13 seconds with immutable types - 9 seconds on commit ac2b005 (before changing the types?) I'm working on a pull request to add Immutable-Vector to Typed Racket. That should be ready for the 6.12 release, and then msgpack can make the `Packable` type immutable. https://github.com/racket/typed-racket/pull/575 If that PR doesn't solve the performance problem, then I'd be happy to keep looking for something that does. > Another thing I noticed is that the predicate > does not provide any proposition, if it succeeds the type checker is not > informed that the object is of type `Packable`. It *should* be possible to make the predicate a proposition by changing the type of `packable?` to `(-> Any Boolean : Packable)`. But I couldn't get this to type check. Here's a simpler case that did work: http://pasterack.org/pastes/92542 But it's probably easier to just use `(define-predicate packable? Packable)` > Another is that Typed Racket > seems unable to narrow down the type of the result. Take a look at this > example: > > > (require msgpack) > > (define bs (call-with-output-bytes (λ (out) (pack 3 out)))) > > bs > - : Bytes > #"\3" > > (define v (call-with-input-bytes bs (λ (in) (unpack in)))) > > v > - : Packable > 3 > > (+ v 3) > ; readline-input:8:3: Type Checker: type mismatch > ; expected: Number > ; given: Packable > ; in: v > ; [,bt for context] > > (exact-integer? v) > - : Boolean > #t > > So the type checker can figure out that v is an integer, but it cannot treat > it as one for addition. The type checker doesn't know that `v` is an integer. It just knows `v` is Packable. -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.