[rucksack-devel] PATCH: without-rucksack-gcing

Cyrus Harmon ch-rucksack at bobobeach.com
Fri Jan 12 19:45:58 UTC 2007


The following patch defines a macro without-rucksack-gcing that can  
be used to cause the enclosed form to be executed without calling  
collect-some-garbage upon commit. Using this patch allows me to load  
400k objects into rucksack in a reasonable amount of time and seems  
to prevent (or reduce, at a minimum) the heap exhaustion errors on SBCL.

Cyrus



--- transactions.lisp	24 Aug 2006 08:21:25 -0700	1.11
+++ transactions.lisp	12 Jan 2007 11:41:07 -0800	
@@ -171,6 +171,16 @@
;; Committing a transaction
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
;;;;;;;

+(defparameter *collect-garbage-on-commit* t
+  "A flag to indicate whether or not transaction-commit collects  
garbage")
+
+;;; use without-rucksack-gcing to locally set
+;;; *collect-garbage-on-commit* to nil in order to supress rucksack
+;;; garbage collection on commit
+(defmacro without-rucksack-gcing (&body body)
+  `(let ((*collect-garbage-on-commit* nil))
+     , at body))
+
(defun transaction-commit (transaction &key (rucksack (current- 
rucksack)))
    "Call transaction-commit-1 to do the real work."
    (transaction-commit-1 transaction (rucksack-cache rucksack)  
rucksack))
@@ -216,8 +226,9 @@
          (delete-commit-file transaction cache)
          ;; 5. Let the garbage collector do an amount of work  
proportional
          ;; to the number of octets that were allocated during the  
commit.
-        (collect-some-garbage heap
-                              (gc-work-for-size heap nr-allocated- 
octets))
+        (when *collect-garbage-on-commit*
+          (collect-some-garbage heap
+                                (gc-work-for-size heap nr-allocated- 
octets)))
          ;; 6. Make sure that all changes are actually on disk before
          ;; we continue.
          (finish-all-output rucksack)))))




More information about the rucksack-devel mailing list