From 1fa0bb0e033e6ed8172045ccb34f1df697636fec Mon Sep 17 00:00:00 2001 From: Vincent St-Amour Date: Fri, 28 Feb 2014 11:36:51 -0500 Subject: [PATCH] More docs about contract costs in TR. --- .../scribblings/guide/caveats.scrbl | 4 ++++ .../scribblings/guide/optimization.scrbl | 17 ++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/pkgs/typed-racket-pkgs/typed-racket-doc/typed-racket/scribblings/guide/caveats.scrbl b/pkgs/typed-racket-pkgs/typed-racket-doc/typed-racket/scribblings/guide/caveats.scrbl index 4f7a2d0dc4..be68dba923 100644 --- a/pkgs/typed-racket-pkgs/typed-racket-doc/typed-racket/scribblings/guide/caveats.scrbl +++ b/pkgs/typed-racket-pkgs/typed-racket-doc/typed-racket/scribblings/guide/caveats.scrbl @@ -166,3 +166,7 @@ Additionally, macros that are defined in Typed Racket modules cannot be used in ordinary Racket modules because such uses can circumvent the protections of the type system. +@section{Expensive contract boundaries} + +Contract boundaries installed for typed-untyped interaction may cause +significant slowdowns. See @secref{contract-costs} for details. diff --git a/pkgs/typed-racket-pkgs/typed-racket-doc/typed-racket/scribblings/guide/optimization.scrbl b/pkgs/typed-racket-pkgs/typed-racket-doc/typed-racket/scribblings/guide/optimization.scrbl index 80363365c3..5f63b38507 100644 --- a/pkgs/typed-racket-pkgs/typed-racket-doc/typed-racket/scribblings/guide/optimization.scrbl +++ b/pkgs/typed-racket-pkgs/typed-racket-doc/typed-racket/scribblings/guide/optimization.scrbl @@ -159,7 +159,7 @@ preferable to vectors. Typed Racket can optimize struct access in all cases. -@subsection[#:tag "optimization-coach"]{Optimization Coaching} +@subsection[#:tag "optimization-coach"]{Optimization coaching} The Optimization Coach package provides optimization coaching support to help you get the most of the Typed Racket optimizer. @@ -173,3 +173,18 @@ debugging information. Setting the Racket logging level can be done on the command line with the @racket[-W] flag: @commandline["racket -W debug@TR-optimizer my-typed-program.rkt"] + + +@subsection[#:tag "contract-costs"]{Contract boundaries} + +When interoperating with untyped code (see @secref{typed-untyped-interaction}), +contracts are installed between typed and untyped modules. Contracts can have +significant overhead, thus typed-untyped boundary crossings should be avoided +in performance-sensitive code. + +Typed Racket provides types for most of the bindings provided by @tt{#lang +racket}; using @racket[require/typed] is unnecessary in these cases. + +If you suspect that contracts at a typed-untyped boundary may be have a +significant cost in your program, you can investigate further using the +contract profiler.