[racket] Performance. How to disable contract checks?

From: Daniel Prager (daniel.a.prager at gmail.com)
Date: Tue Jun 3 00:38:08 EDT 2014

> I propose something like two contracts: for debug and production modes.

Eiffel compilers implement a sliding scale of contract-checking, something

   1. Check nothing [naive]
   2. Check pre-conditions only [good for production - quick]
   3. Check pre- and post-conditions only [can be slow]
   4. Check pre- and post-conditions and invariants [van be very slow]

[Loop and ad hoc assertions would have been in there too.]

Post-conditions and invariants can be *very* expensive to check, but are
great when debugging.

Pre-condition checking is typically cheap, and quickly tells you when
trusted code is being called with bad arguments.

Recommeneded development practice was to start with all contracts checked,
and as one's code iterated towards trustworthiness turn down the
checking-level (but leave pre-conduitions on) and enjoy the huge speed

There's value in being able to control checking on a per module basis,
essentially doing deep checks on newer / less-tested / less-trusted parts
of the system.

How does the picture change with higher-order contracts and checking at
module boundaries?


On Tue, Jun 3, 2014 at 6:20 AM, Roman Klochkov <kalimehtar at mail.ru> wrote:

> The problem is that, when debbugging, contract should be precise. For
> example, insert-in-sorted-queue may check that queue is orted before and
> after the function.
> But inserting the element is O(log n) and testing will be O(n).
> option contracts -- 1) unstable 2) should be turned off and on
> individually.
> For quick hack, I'll simply redefine contract-out and recompile all. But I
> propose something like two contracts: for debug and production modes.
> Mon, 2 Jun 2014 15:49:05 -0400 от Matthias Felleisen <matthias at ccs.neu.edu
> >:
> On Jun 2, 2014, at 3:42 PM, Roman Klochkov <kalimehtar at mail.ru
> <https://e.mail.ru/compose?To=kalimehtar@mail.ru>> wrote:
> > Is there a way to disable all contract checks?
> >
> > Suppose, I debugged my program and sure that it is reliable. I disable
> debugging, but as I understand, contracts are still checked in every
> function.
> > But I want to maximize the performance of my program. Is there a way to
> do that or I have to manually hack racket/contract/base to do that?
> No.
> ;; ---
> Programmers who disable assertion checking as they are deploying software
> are like people who wear life vests on land when they learn about the
> theory of sailing and take them off as soon as they board the boat for
> practical exercises on the water. -- somebody famous
> ;; ---
> You will need to define a version of provide and/or contract-out that
> throws away contracts based on a switch.
> Or you check out option contracts and use those.
> -- Matthias
> --
> Roman Klochkov
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users

*Daniel Prager*
Agile/Lean Coaching, Software Development and Leadership
Startup: www.youpatch.com
Twitter: @agilejitsu <https://twitter.com/agilejitsu>
Blog: agile-jitsu.blogspot.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20140603/f1454da3/attachment.html>

Posted on the users mailing list.