Преглед на файлове

moar optimization, memory limit

Innocenty Enikeew преди 8 години
родител
ревизия
027c09df73
променени са 2 файла, в които са добавени 5 реда и са изтрити 4 реда
  1. 1 1
      Dockerfile
  2. 4 3
      travels.lisp

+ 1 - 1
Dockerfile

@@ -41,4 +41,4 @@ COPY travels.asd *.lisp travels/
 RUN sbcl --eval '(ql:quickload :travels)' --eval '(sb-ext:quit)'
 
 EXPOSE 80
-CMD ["sbcl", "--eval", "(ql:quickload :travels)", "--eval", "(travels:main :port 80 :data \"/tmp/data/data.zip\" :worker-num 4)"]
+CMD ["sbcl", "--dynamic-space-size",  "4096", "--eval", "(ql:quickload :travels)", "--eval", "(travels:main :port 80 :data \"/tmp/data/data.zip\" :worker-num 4)"]

+ 4 - 3
travels.lisp

@@ -77,12 +77,13 @@
   `(200 (:content-type "application/json") ,(dumps data)))
 
 (defun get-entity (params)
+  (declare (optimize (speed 3) (safety 0)))
   (let ((id (parse-integer (getf params :id) :junk-allowed t))
-        (entity (getkey params :entity)))
+        (entity (the symbol (getkey params :entity))))
     (if id
         (case entity
           ((:|users| :|visits| :|locations|)
-           (let ((entity (gethash id (gethash entity *storage*))))
+           (let ((entity (gethash (the fixnum id) (gethash (the symbol entity) *storage*))))
              (if entity
                  `(200 (:content-type "application/json") ,entity)
                  +404+)))
@@ -283,7 +284,7 @@
   (setf *storage-users* (gethash :|users| *storage*)
         *storage-locations* (gethash :|locations| *storage*)
         *storage-visits* (gethash :|visits| *storage*))
-  #+sbcl (sb-ext:gc)
+  #+sbcl (sb-ext:gc :full t)
   (room)
   (format t "Loaded ~A~%" data)
   (apply #'clack:clackup