> 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:
Thanks, I will change the hash tables to immutable, but I am going to keep 
vector as it is until immutable vectors land in Typed Racket. A slow
implementation is better than an incomplete implementation.

> 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?)

Why is the version with immutable types still slower? Is it because it has 
recursively check the contents of the hash instead of just being satisfied 
anything? See, this is the thing that confuses me about Typed Racket, I 
that making types more specific should improve performance or at least 
leave it
as it is because Racket does not have to check types at runtime unless
explicitly requested. Is it because the tests are written in untyped Racket 
specifying the Packable type generates a more expensive contract than the 
type would?

> 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.
Racket 6.12 should come out around the end of January, right?

> 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? 
I think the problem is that Packable contains mutable types, which 
according to
the reference manual is not allowed:

> The type checker doesn't know that `v` is an integer. It just knows
> `v` is Packable. 
Right, that makes sense. Number and Packable intersect, but Packable is not 
subtype of Number.

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.

Reply via email to