examples/bench.lisp @ ba205f6b2875

Excise the stupid fucking `set-*` opcodes

The book uses the horribly-confusingly-named `set-*` operations for handling
subterms in query mode.  The author does this because he claims this is both
easier to understand and more performant.  In reality it is neither of these
things.

If you just name the subterm-handling opcodes something not completely stupid,
like `handle-subterm-*` instead of `unify-*` it becomes obvious what they do.

Also, despite the fact that `put-*` instructions now need to set the WAM's
`mode`, we still get about a 10% speedup here, likely from some combination of
reducing the VM loop code size and simplifying the compilation process.  So it's
not even more performant.

TL;DR: Just say "No" to `set-*`.
author Steve Losh <steve@stevelosh.com>
date Sun, 10 Jul 2016 14:21:18 +0000
parents 410acaae0c14
children 8897604cb9dd
(ql:quickload 'bones)
(ql:quickload 'paiprolog)

(load "examples/ggp-paip-compiled.lisp")
(load "examples/ggp-paip-interpreted.lisp")
(load "examples/ggp-wam.lisp")

(in-package :bones)

(defun reload ()
  (let ((*standard-output* (make-broadcast-stream))
        (*debug-io* (make-broadcast-stream))
        (*terminal-io* (make-broadcast-stream))
        (*error-output* (make-broadcast-stream)))
    (asdf:load-system 'bones :force t)
    (asdf:load-system 'paiprolog :force t)
    (load "examples/ggp-paip-compiled.lisp")
    (load "examples/ggp-paip-interpreted.lisp")
    (load "examples/ggp-wam.lisp")))

(defun run-test% ()
  ; (format t "PAIP (Compiled) --------------------~%")
  ; (time (paiprolog-test::dfs-exhaust))

  ; (format t "PAIP (Interpreted) -----------------~%")
  ; (time (bones.paip::depth-first-search :exhaust t))

  (format t "WAM --------------------------------~%")
  (time (bones.wam::depth-first-search :exhaust t)))

(defmacro run-test (&rest settings)
  `(progn
    (declaim (optimize ,@settings))
    (format t "~%~%========================================================~%")
    (format t "~S~%" ',settings)
    (format t "--------------------------------------------------------~%")
    (reload)
    (run-test%)))

; (run-test (speed 3) (safety 1) (debug 1))
(run-test (speed 3) (safety 0) (debug 0))