2009/10/28 Robert Goldman rpgoldman@sift.info:
Faré wrote:
2009/10/28 Gary King gwking@metabang.com:
Speaking of optimization settings, does anyone see any problem with putting in ASDF something that deterministically (re)sets the optimization setting before each and any perform operation? Otherwise, optimization settings will vary wildly depending on what implementation you use, which files get recompiled, etc.
I think we should do this; it's on my list.
Here's a skeleton of implementation (don't forget a defgeneric).
(defmethod perform :before (operation component) (proclaim-optimization-settings-for operation component))
(defmethod proclaim-optimization-settings-for (op component) (declare (ignorable op component)) (proclaim `(optimize ,@*default-optimization-settings*)))
Unrelatedly, a slight refactoring patch is attached. It would makes it easier for ADG and other ASDF add-ons to reuse in a future-proof way the ASDF pathname merging algorithm.
Do we need a :after method to restore the old settings? I'm not sure how to do that actually, since I don't believe there's a portable way to record them. Do you have thoughts about this?
(rpg replied to me in private but I'm Cc'ing back the list)
At ITA, we actually use a :around method with
(defun call-with-local-compilation-settings (thunk) (let #+clozure ((ccl::*nx-speed* ccl::*nx-speed*) (ccl::*nx-space* ccl::*nx-space*) (ccl::*nx-safety* ccl::*nx-safety*) (ccl::*nx-cspeed* ccl::*nx-cspeed*) (ccl::*nx-debug* ccl::*nx-debug*)) #+sbcl ((sb-c::*policy* sb-c::*policy*)) #-(or clozure sbcl) () (funcall thunk)))
(defmacro with-local-compilation-settings (() &body body) `(call-with-local-compilation-settings (lambda () ,@body)))
[ François-René ÐVB Rideau | Reflection&Cybernethics | http://fare.tunes.org ] The American Republic will endure, until politicians realize they can bribe the people with their own money. -- Alexis de Tocqueville (attributed)
Faré wrote:
2009/10/28 Robert Goldman rpgoldman@sift.info:
Faré wrote:
2009/10/28 Gary King gwking@metabang.com:
Speaking of optimization settings, does anyone see any problem with putting in ASDF something that deterministically (re)sets the optimization setting before each and any perform operation? Otherwise, optimization settings will vary wildly depending on what implementation you use, which files get recompiled, etc.
I think we should do this; it's on my list.
Here's a skeleton of implementation (don't forget a defgeneric).
(defmethod perform :before (operation component) (proclaim-optimization-settings-for operation component))
(defmethod proclaim-optimization-settings-for (op component) (declare (ignorable op component)) (proclaim `(optimize ,@*default-optimization-settings*)))
Unrelatedly, a slight refactoring patch is attached. It would makes it easier for ADG and other ASDF add-ons to reuse in a future-proof way the ASDF pathname merging algorithm.
Do we need a :after method to restore the old settings? I'm not sure how to do that actually, since I don't believe there's a portable way to record them. Do you have thoughts about this?
(rpg replied to me in private but I'm Cc'ing back the list)
At ITA, we actually use a :around method with
(defun call-with-local-compilation-settings (thunk) (let #+clozure ((ccl::*nx-speed* ccl::*nx-speed*) (ccl::*nx-space* ccl::*nx-space*) (ccl::*nx-safety* ccl::*nx-safety*) (ccl::*nx-cspeed* ccl::*nx-cspeed*) (ccl::*nx-debug* ccl::*nx-debug*)) #+sbcl ((sb-c::*policy* sb-c::*policy*)) #-(or clozure sbcl) () (funcall thunk)))
(defmacro with-local-compilation-settings (() &body body) `(call-with-local-compilation-settings (lambda () ,@body)))
Gary, got some Allegro fu that we could shovel into with-local-compilation-settings?
best, r
Robert Goldman writes:
Fare wrote:
Do we need a :after method to restore the old settings? I'm not sure how to do that actually, since I don't believe there's a portable way to record them. Do you have thoughts about this?
(rpg replied to me in private but I'm Cc'ing back the list)
At ITA, we actually use a :around method with
(defun call-with-local-compilation-settings (thunk) (let #+clozure ((ccl::*nx-speed* ccl::*nx-speed*) (ccl::*nx-space* ccl::*nx-space*) (ccl::*nx-safety* ccl::*nx-safety*) (ccl::*nx-cspeed* ccl::*nx-cspeed*) (ccl::*nx-debug* ccl::*nx-debug*)) #+sbcl ((sb-c::*policy* sb-c::*policy*)) #-(or clozure sbcl) () (funcall thunk)))
(defmacro with-local-compilation-settings (() &body body) `(call-with-local-compilation-settings (lambda () ,@body)))
Gary, got some Allegro fu that we could shovel into with-local-compilation-settings?
A somewhat-portable way would be to query current optimization settings, and reset them appropriately. ("somewhat-portable" because the environment access stuff specified in CLtL2 allows for the querying.)
This way you also can easily define a default value for implementations where you do not (yet) know how to get that information from; my gut feeling for the default values would be (debug 2) (speed 2) (safety 2).
-T.
Tobias C. Rittweiler wrote:
Robert Goldman writes:
Fare wrote:
Do we need a :after method to restore the old settings? I'm not sure how to do that actually, since I don't believe there's a portable way to record them. Do you have thoughts about this?
(rpg replied to me in private but I'm Cc'ing back the list)
At ITA, we actually use a :around method with
(defun call-with-local-compilation-settings (thunk) (let #+clozure ((ccl::*nx-speed* ccl::*nx-speed*) (ccl::*nx-space* ccl::*nx-space*) (ccl::*nx-safety* ccl::*nx-safety*) (ccl::*nx-cspeed* ccl::*nx-cspeed*) (ccl::*nx-debug* ccl::*nx-debug*)) #+sbcl ((sb-c::*policy* sb-c::*policy*)) #-(or clozure sbcl) () (funcall thunk)))
(defmacro with-local-compilation-settings (() &body body) `(call-with-local-compilation-settings (lambda () ,@body)))
Gary, got some Allegro fu that we could shovel into with-local-compilation-settings?
A somewhat-portable way would be to query current optimization settings, and reset them appropriately. ("somewhat-portable" because the environment access stuff specified in CLtL2 allows for the querying.)
This way you also can easily define a default value for implementations where you do not (yet) know how to get that information from; my gut feeling for the default values would be (debug 2) (speed 2) (safety 2).
According to recent (8.1) allegro docs, the effects of DECLAIM should not leak out of the current file, but I'm not sure that agrees with my experience where optimization settings are concerned. I have certainly found what looks like leakage of optimization settings.
Franz recommends a default as follows:
;; For the most debuggable (and yet reasonably fast) code, use ;; ;; (proclaim '(optimize (speed 2) (safety 1) (space 1) (debug 3)))
I can't find any documented solution to getting the current compiler settings on ACL beyond calling (excl:explain-compiler-settings) and parsing its output, but I imagine someone from Franz could find a better solution.