From e1bf53906d837dd7c7af1daf3db319fb717950af Mon Sep 17 00:00:00 2001 From: Dimitri Fontaine Date: Mon, 26 May 2014 16:59:12 +0200 Subject: [PATCH] Don't send over useless verbose log messages. When in :data logging mode we log the whole data set as we read then write it, which is quite a lot of data. Our current logging system works by filling up a queue that the cl-log lib is then fed from, and sending lots of data in that queue is way expensive, stop doing that. Hopefully we don't need to revisit the logs more than that, the other messages should be few enough not to count much when doing a full load. --- src/pgsql/pgsql.lisp | 4 +++- src/queue.lisp | 4 +++- src/utils.lisp | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/pgsql/pgsql.lisp b/src/pgsql/pgsql.lisp index 3684017..781b6ba 100644 --- a/src/pgsql/pgsql.lisp +++ b/src/pgsql/pgsql.lisp @@ -20,7 +20,9 @@ (unwind-protect (loop for i below batch-rows for copy-string = (aref batch i) - do (log-message :data "> ~s" copy-string) + do (when (or (eq :data *log-min-messages*) + (eq :data *client-min-messages*)) + (log-message :data "> ~s" copy-string)) do (cl-postgres:db-write-row copier nil copy-string) finally (return batch-rows)) (cl-postgres:close-db-writer copier)))) diff --git a/src/queue.lisp b/src/queue.lisp index 55925c8..deb4be1 100644 --- a/src/queue.lisp +++ b/src/queue.lisp @@ -33,7 +33,9 @@ (defun batch-row (row copy queue) "Add ROW to the reader batch. When the batch is full, provide it to the writer as the *writer-batch*." - (log-message :data "< ~s" row) + (when (or (eq :data *log-min-messages*) + (eq :data *client-min-messages*)) + (log-message :data "< ~s" row)) (let ((oversized? (oversized? *current-batch*))) (when (or (= (batch-count *current-batch*) *copy-batch-rows*) oversized?) diff --git a/src/utils.lisp b/src/utils.lisp index 878b4f4..4f21d4f 100644 --- a/src/utils.lisp +++ b/src/utils.lisp @@ -332,6 +332,8 @@ (*myconn-port* . ,*myconn-port*) (*myconn-user* . ,*myconn-user*) (*myconn-pass* . ,*myconn-pass*) - (*state* . ,*state*)))) + (*state* . ,*state*) + (*client-min-messages* . ,*client-min-messages*) + (*log-min-messages* . ,*log-min-messages*)))) "Wrapper around lparallel:make-kernel that sets our usual bindings." (lp:make-kernel worker-count :bindings bindings))