>> 2. Profile. Use SB-SPROF to locate bottlenecks.
I'd very much like to try that in my own work, but I'm having trouble
getting it loaded. I tried following the example in Section 15.2.1
(Example Usage) of the SBCL manual at
http://www.sbcl.org/manual/Statistical-Profiler.html, Section 15.2
Below is a log. I also looked in the manual at documentation for
*MODULE-PROVIDER-FUNCTIONS* and REQUIRE, but I didn't see anything
that would help me. Am I doing something wrong?
sloth:/projects/acl2/devel> uname -a
Linux sloth 2.6.32-32-server #62-Ubuntu SMP Wed Apr 20 22:07:43 UTC 2011 x86_64 GNU/Linux
This is SBCL 1.0.49, an implementation of ANSI Common Lisp.
More information about SBCL is available at <http://www.sbcl.org/>.
SBCL is free software, provided as is, with absolutely no warranty.
It is mostly in the public domain; some portions are provided under
BSD-style licenses. See the CREDITS and COPYING files in the
distribution for more information.
* (in-package :cl-user)
* (require :sb-sprof)
debugger invoked on a SB-INT:EXTENSION-FAILURE in thread #<THREAD
"initial thread" RUNNING
Don't know how to REQUIRE SB-SPROF.
The SBCL Manual, Variable *MODULE-PROVIDER-FUNCTIONS*
The SBCL Manual, Function REQUIRE
Type HELP for debugger help, or (SB-EXT:QUIT) to exit from SBCL.
restarts (invokable by number or by possibly-abbreviated name):
0: [ABORT] Exit debugger, returning to top level.
(SB-IMPL::REQUIRE-ERROR "Don't know how to ~S ~A." REQUIRE :SB-SPROF)
Date: Tue, 14 Jun 2011 19:17:13 +0300
From: Nikodemus Siivola <nikodemus@...>
Cc: "sbcl-help@..." <sbcl-help@...>
Content-Type: text/plain; charset="utf-8"
On 14 June 2011 19:01, Cheung, Matthew G <mgcheung@...> wrote:
> Thanks for your reply. I did look at what the manual had to say, but I wasn't sure how that was helpful to my situation. What I have been trying to do is see if using a fast reduction algorithm for the NIST prime P256
> would be faster than the builtin mod operator. Since I'm assuming my
> input is no bigger than p^2, I did a (declare (type (unsigned-byte 512))
> c) and then in my let I used declare to make all of those variables of
> type (unsigned-byte 256). Now that I have learned about ldb I now know
Ouch. Not much help from SBCL's modular arithmetic, then -- it's
limited to native word size at most.
> using the ash function to shift to the left. Would it be more efficient
> to use dpb to write directly to the bytes in question? I'm starting to
I can't really say offhand -- especially not without seeing the code.
On bignums MOD's speed is essentially down to the speed of
BIGNUM-TRUNCATE. I'm quite not sure how good ours is, but IIRC as long
the bignums aren't particularly huge it should be pretty decent.
> Do you have any more advice on how I can improve efficiency?
Without knowing more of the specifics and seeing the code, not really,
but some general advice:
1. Algorithmic efficiency trumps micro-efficiency 99 times out of 100.
...but you know that already.
2. Profile. Use SB-SPROF to locate bottlenecks.
3. When you identify a bottleneck, understand why it's a bottleneck
before trying to fix it. DISASSEMBLE and the compiler notes from
(declaim (optimize speed)) are a great help here -- and feel free to
ask help in understanding them here.
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
Sbcl-help mailing list