opencog / atomspace

The OpenCog (hyper-)graph database and graph rewriting system
https://wiki.opencog.org/w/AtomSpace
Other
798 stars 225 forks source link

compiling scheme atomese #2916

Closed mjsduncan closed 2 years ago

mjsduncan commented 2 years ago

is there any advantage to allowing guile to compile atomese hypergraphs or is that a mistake?

linas commented 2 years ago

A three-part answer:

1) If a file contains mostly "ordinary" scheme code, then yes, let guile compile it. It does this only once, and the code will run faster.

2) If the file contains mostly plain Atomese, then there is no advantage to compiling. In fact, waiting for the compile to happen is infuriatingly slow. This can be overcome in two ways. These are:

2a) Use (load-primitive "some-file.scm") There's also a variant, called load-primitve-from-path or something like that, that uses assorted default search paths. Search engines know more.

2b) if the file is huge (e.g. genome data) and is "pure" Atomese, then there is an even faster way: there is a custom loader in the atomspace that runs 4x or 8x faster. Created by our pal Alexey Potapov. There are two ways of using it. If I recall correctly, then this should work:

(use-modules (opencog persist-file))
(load-file "/tmp/foobar.scm")

That should work.

There is also a fancier API to this loader, with a demo here: https://github.com/opencog/atomspace/blob/master/examples/atomspce/persist-store.scm and documentation for it here: https://wiki.opencg.org/w/StorageNode