Report struct constructors used in hot code.
This commit is contained in:
parent
696583582b
commit
9c73563705
|
@ -6,6 +6,8 @@
|
||||||
(optimizer utils logging)
|
(optimizer utils logging)
|
||||||
(types abbrev))
|
(types abbrev))
|
||||||
|
|
||||||
|
(require (types type-table))
|
||||||
|
|
||||||
(provide hidden-cost-log-expr)
|
(provide hidden-cost-log-expr)
|
||||||
|
|
||||||
(define-syntax-class hidden-port-parameter-function
|
(define-syntax-class hidden-port-parameter-function
|
||||||
|
@ -29,4 +31,11 @@
|
||||||
(syntax->list #'(args ...)))
|
(syntax->list #'(args ...)))
|
||||||
#:with opt
|
#:with opt
|
||||||
(begin (log-optimization-info "hidden parameter" #'op)
|
(begin (log-optimization-info "hidden parameter" #'op)
|
||||||
|
#`(op #,@(syntax-map (optimize) #'(args ...)))))
|
||||||
|
;; Log calls to struct constructors, so that OC can report those used in
|
||||||
|
;; hot loops.
|
||||||
|
(pattern (#%plain-app op:id args ...)
|
||||||
|
#:when (struct-constructor? #'op)
|
||||||
|
#:with opt
|
||||||
|
(begin (log-optimization-info "struct constructor" #'op)
|
||||||
#`(op #,@(syntax-map (optimize) #'(args ...))))))
|
#`(op #,@(syntax-map (optimize) #'(args ...))))))
|
||||||
|
|
|
@ -388,6 +388,24 @@
|
||||||
'() '()
|
'() '()
|
||||||
20)))) ;; TODO have actual badness
|
20)))) ;; TODO have actual badness
|
||||||
|
|
||||||
|
(when inside-hot-function?
|
||||||
|
(for ([TR-entry (in-list TR-log)]
|
||||||
|
#:when (info-log-entry? TR-entry)
|
||||||
|
#:when (equal? (log-entry-kind TR-entry) "struct constructor")
|
||||||
|
#:when (pos-inside-us? (log-entry-pos TR-entry)))
|
||||||
|
(emit (missed-opt-log-entry
|
||||||
|
"" ; kind not used at this point
|
||||||
|
(string-append
|
||||||
|
"This struct constructor is used in hot code. "
|
||||||
|
"Allocating structs is expensive, consider using vectors instead. "
|
||||||
|
"To keep the same interface, consider defining macro wrappers "
|
||||||
|
"around the vector operations that have the same name as the "
|
||||||
|
"struct constructor and accessors.")
|
||||||
|
(log-entry-located-stx TR-entry) (log-entry-located-stx TR-entry)
|
||||||
|
(log-entry-pos TR-entry) 'typed-racket
|
||||||
|
'() '()
|
||||||
|
20)))) ;; TODO have actual badness
|
||||||
|
|
||||||
produced-entries)
|
produced-entries)
|
||||||
|
|
||||||
(define (group-badness group)
|
(define (group-badness group)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user