Changeset 32948 in project


Ignore:
Timestamp:
11/29/15 17:51:14 (5 years ago)
Author:
sjamaan
Message:

spiffy: Precompile vhost-map irregexes for a nice performance boost. It cannot (or rather, should not!) be modified during request processing.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • release/4/spiffy/trunk/spiffy.scm

    r32947 r32948  
    481481        (car address-chain))))
    482482
    483 (define (handle-incoming-request in out)
     483(define (handle-incoming-request compiled-vhost-map in out)
    484484  (handle-exceptions exn   ; This should probably be more fine-grained
    485485    (let ((chain (with-output-to-string print-call-chain)))
     
    511511                 (if (and host (uri-path-absolute? (request-uri (current-request))))
    512512                     (let ((handler
    513                             (alist-ref host (vhost-map)
    514                                        (lambda (h _)
    515                                          (irregex-match (irregex h 'i) host)))))
     513                            (alist-ref host compiled-vhost-map
     514                                       (lambda (ir _)
     515                                         (irregex-match ir host)))))
    516516                       (if handler
    517517                           (handler (lambda ()
     
    596596  (let ((thread-count (make-mutex/value 'thread-count 0))
    597597        (thread-stopped! (make-condition-variable 'thread-stopped!))
    598         (exn-message (condition-property-accessor 'exn 'message "(no message)")))
     598        (exn-message (condition-property-accessor 'exn 'message "(no message)"))
     599        (compiled-vhost-map
     600         (map (lambda (irregex&handler)
     601                (cons (irregex (car irregex&handler) 'i)
     602                      (cdr irregex&handler)))
     603              (vhost-map))))
    599604    (let accept-next-connection ()
    600605      ;; Wait until we have a free connection slot
     
    626631                                  (load-verbose #f))
    627632                     (let handle-next-request ()
    628                        (when (and (handle-incoming-request in out)
     633                       (when (and (handle-incoming-request
     634                                   compiled-vhost-map in out)
    629635                                  (not (port-closed? in))
    630636                                  (not (port-closed? out)))
Note: See TracChangeset for help on using the changeset viewer.