pmonks / clj-spdx

Clojure wrapper around spdx/Spdx-Java-Library
Apache License 2.0
2 stars 1 forks source link

Consider caching Spdx-Java-library state #22

Closed pmonks closed 11 months ago

pmonks commented 1 year ago

The Spdx-Java-Library is exceptionally expensive to initialise with the basic reference data (license and exception lists, templates etc.). On my laptop it generally takes more than a minute to pull this information down, parse it, and load it into memory.

There may be a way to cache the library's state to disk (e.g. via serialisation, perhaps using nippy) and only incur the cost of initialisation when the lists have changes (which can be determined via an eTag request to the two list URLs).

pmonks commented 1 year ago

A quick experiment with nippy suggests this may not be easy solely from Clojure:

$ clj -Sdeps '{:deps {com.taoensso/nippy {:mvn/version "RELEASE"}}}' -r
user=> (require '[taoensso.nippy :as nippy])
nil
user=> (require '[spdx.licenses :as sl])
nil
user=> (sl/init!)
nil
user=> (require '[spdx.exceptions :as se])
nil
user=> (se/init!)
nil
user=> (require '[spdx.impl.state :as sis])
nil
user=> (nippy/freeze @sis/list-obj)
Execution error (ExceptionInfo) at taoensso.nippy/throw-unfreezable (nippy.clj:999).
Unfreezable type: class org.spdx.library.model.license.ListedLicenses
user=> 
pmonks commented 1 year ago

Raised https://github.com/spdx/Spdx-Java-Library/issues/193 to see if this can be fixed in the underlying Java library (which is a better place for it anyway).

pmonks commented 11 months ago

This is fixed in Spdx-Java-Library v1.1.8.