Please review this diff, which basically makes two changes:

- Refer to the mp:*current-process* symbol once rather than twice to
  avoid redundant resolution
- Since the lock object's count slot is considered a fixnum by the
  internal code, also declare it as fixnum to avoid calling a
  comparison function

Since WITH-LOCK is a macro that's called rather often in MP code, this
provides some performance improvement with a few tests I've ran.

One thing also, is that I currently have various custom changes in my
tree which I wouldn't want to necessarily push to the official
repository (at least not immediately).  I began reading the progit book
so eventually I should know better what I'm doing with GIT, hopefully.
As such, feel free to commit the change if you have commit access and
like the diff.

It's also unclear to me if we should use this list for reviews in
general before commiting changes, but it's the policy of some projects
I've participated in; the opinion of others (especially the main
maintainer) on this would be good to have.

Thanks,
-- 
Matt
diff --git a/src/lsp/mp.lsp b/src/lsp/mp.lsp
index b4c4521..66dff01 100644
--- a/src/lsp/mp.lsp
+++ b/src/lsp/mp.lsp
@@ -116,16 +116,20 @@ by ALLOW-WITH-INTERRUPTS."
   ;; the get-lock statement, to ensure that the unlocking is done with
   ;; interrupts disabled.
   #+threads
-  (ext:with-unique-names (lock owner count)
+  (ext:with-unique-names (lock owner count process)
     `(let* ((,lock ,lock-form)
             (,owner (mp:lock-owner ,lock))
            (,count (mp:lock-count ,lock)))
+       (declare (type fixnum ,count))
        (without-interrupts
            (unwind-protect
                 (with-restored-interrupts
                     (mp::get-lock ,lock)
                   (locally ,@body))
-             (when (and (eq mp:*current-process* (mp:lock-owner ,lock))
-                       (or (not (eq ,owner mp:*current-process*))
-                           (> (mp:lock-count ,lock) ,count)))
-               (mp::giveup-lock ,lock)))))))
+            (let ((,process mp:*current-process*))
+              (declare (optimize (speed 3) (safety 0) (debug 0)))
+              (when (and (eq ,process (mp:lock-owner ,lock))
+                         (or (not (eq ,owner ,process))
+                             (> (the fixnum (mp:lock-count ,lock))
+                                (the fixnum ,count))))
+                (mp::giveup-lock ,lock))))))))
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk
_______________________________________________
Ecls-list mailing list
Ecls-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ecls-list

Reply via email to