[racket-dev] [plt] Push #28450: master branch updated

From: Eric Dobson (eric.n.dobson at gmail.com)
Date: Mon Mar 31 23:01:07 EDT 2014

Do we have a performance test case which shows improvment with this change?

On Mon, Mar 31, 2014 at 3:21 PM,  <asumu at racket-lang.org> wrote:
> asumu has updated `master' from 6722b7a71e to 92b0e86ed1.
>   http://git.racket-lang.org/plt/6722b7a71e..92b0e86ed1
>
> =====[ One Commit ]=====================================================
> Directory summary:
>  100.0% pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/base-env/
>
> ~~~~~~~~~~
>
> 92b0e86 Asumu Takikawa <asumu at racket-lang.org> 2014-03-31 17:46
> :
> | Refactor TR `define` to avoid a performance bug
> |
> | After commit 3d177e454ea3634060a4b9b0814f588bc7c74e49
> | running the main `math.scrbl` file would show peak memory
> | usage of around 600-700MB when before it was around 400MB.
> |
> | The proximal cause appears to be the expansion of TR
> | definitions, which added an extra `begin` in some cases,
> | combined with redefinitions at the top-level. I don't
> | know the core cause yet.
> |
> | Thanks to Matthew for pointing out the issue and to
> | Vincent for helping with debugging.
> :
>   M .../typed-racket-lib/typed-racket/base-env/prims.rkt   | 15 +++++++++------
>
> =====[ Overall Diff ]===================================================
>
> pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/base-env/prims.rkt
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> --- OLD/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/base-env/prims.rkt
> +++ NEW/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/base-env/prims.rkt
> @@ -1218,15 +1218,18 @@ This file defines two sorts of primitives. All of them are provided into any mod
>
>  (define-syntax (-define stx)
>    (syntax-parse stx #:literals (:)
> -    ;; the first two cases are actually subsumed by the last,
> +    ;; the first three cases are actually subsumed by the last,
>      ;; but manually expanding to using the : annotation form
>      ;; produces better error messages on duplicate annotations
> +    ;;
> +    ;; note, these first two cases can be collapsed into one
> +    ;; but we keep them separate because in some cases it ruins
> +    ;; typechecking performance to merge them.
> +    [(-define nm:id body)
> +     (syntax/loc stx (define nm body))]
>      [(-define nm:id return:return-ann body)
> -     (define/with-syntax maybe-ann
> -       (if (attribute return.type)
> -           #'(: nm return.type)
> -           #'(void)))
> -     (syntax/loc stx (begin maybe-ann (define nm body)))]
> +     (quasisyntax/loc stx
> +       (begin (: nm #,(attribute return.type)) (define nm body)))]
>      [(-define vars:lambda-type-vars nm:id : ty body)
>       (define/with-syntax type
>         (syntax/loc #'ty (All vars.type-vars ty)))

Posted on the dev mailing list.