NB *BREAKING*: refactor type defs, variable-sized types, etc.

Changes incl:
  - Hid a bunch of undocumented impl. details
  - A number of performance optimizations
This commit is contained in:
Peter Taoussanis 2016-04-07 12:49:26 +07:00
parent 3f43542adb
commit b623b4a8cc
4 changed files with 837 additions and 503 deletions

View file

@ -50,18 +50,22 @@ As an example of what it can do, let's take a look at Nippy's own reference stre
```clojure ```clojure
nippy/stress-data nippy/stress-data
=> =>
{:bytes (byte-array [(byte 1) (byte 2) (byte 3)]) {:bytes (byte-array [(byte 1) (byte 2) (byte 3)])
:nil nil :nil nil
:boolean true :true true
:false false
:char-utf8 \ಬ :char \ಬ
:string-utf8 "ಬಾ ಇಲ್ಲಿ ಸಂಭವಿಸ" :str-short "ಬಾ ಇಲ್ಲಿ ಸಂಭವಿಸ"
:string-long (apply str (range 1000)) :str-long (apply str (range 1000))
:keyword :keyword :kw :keyword
:ns-keyword ::keyword :kw-ns ::keyword
:sym 'foo
:sym-ns 'foo/bar
:regex #"^(https?:)?//(www\?|\?)?"
:queue (-> (PersistentQueue/EMPTY) (conj :a :b :c :d :e :f :g)) :queue (-> (PersistentQueue/EMPTY) (conj :a :b :c :d :e :f :g))
:queue-empty (PersistentQueue/EMPTY) :queue-empty (PersistentQueue/EMPTY)
:queue-empty (enc/queue)
:sorted-set (sorted-set 1 2 3 4 5) :sorted-set (sorted-set 1 2 3 4 5)
:sorted-map (sorted-map :b 2 :a 1 :d 4 :c 3) :sorted-map (sorted-map :b 2 :a 1 :d 4 :c 3)
@ -75,7 +79,12 @@ nippy/stress-data
:set #{1 2 3 4 5 #{6 7 8 #{9 10}}} :set #{1 2 3 4 5 #{6 7 8 #{9 10}}}
:set-empty #{} :set-empty #{}
:meta (with-meta {:a :A} {:metakey :metaval}) :meta (with-meta {:a :A} {:metakey :metaval})
:lazy-seq (repeatedly 1000 rand) :nested [#{{1 [:a :b] 2 [:c :d] 3 [:e :f]} [] #{:a :b}}
#{{1 [:a :b] 2 [:c :d] 3 [:e :f]} [] #{:a :b}}
[1 [1 2 [1 2 3 [1 2 3 4 [1 2 3 4 5]]]]]]
:lazy-seq (repeatedly 1000 rand)
:lazy-seq-empty (map identity '())
:byte (byte 16) :byte (byte 16)
:short (short 42) :short (short 42)

View file

@ -15,7 +15,7 @@
:dependencies :dependencies
[[org.clojure/clojure "1.5.1"] [[org.clojure/clojure "1.5.1"]
[org.clojure/tools.reader "0.10.0"] [org.clojure/tools.reader "0.10.0"]
[com.taoensso/encore "2.42.0"] [com.taoensso/encore "2.49.0"]
[org.iq80.snappy/snappy "0.4"] [org.iq80.snappy/snappy "0.4"]
[org.tukaani/xz "1.5"] [org.tukaani/xz "1.5"]
[net.jpountz.lz4/lz4 "1.3"]] [net.jpountz.lz4/lz4 "1.3"]]
@ -30,11 +30,11 @@
:test {:jvm-opts ["-Xms1024m" "-Xmx2048m"] :test {:jvm-opts ["-Xms1024m" "-Xmx2048m"]
:dependencies [[org.clojure/test.check "0.9.0"] :dependencies [[org.clojure/test.check "0.9.0"]
[org.clojure/data.fressian "0.2.1"] [org.clojure/data.fressian "0.2.1"]
[org.xerial.snappy/snappy-java "1.1.2.1"]]} [org.xerial.snappy/snappy-java "1.1.2.4"]]}
:dev [:1.8 :test :dev [:1.8 :test
{:plugins {:plugins
[[lein-pprint "1.1.2"] [[lein-pprint "1.1.2"]
[lein-ancient "0.6.8"] [lein-ancient "0.6.10"]
[lein-codox "0.9.4"]]}]} [lein-codox "0.9.4"]]}]}
:test-paths ["test" "src"] :test-paths ["test" "src"]

File diff suppressed because it is too large Load diff

View file

@ -65,17 +65,18 @@
(comment (comment
(set! *unchecked-math* false) (set! *unchecked-math* false)
;; (bench {:reader? true :lzma2? true :fressian? true :laps 3}) ;; (bench {:reader? true :lzma2? true :fressian? true :laps 2})
;; (bench {:laps 4}) ;; (bench {:laps 2})
;;; 2016 Mar 8, v2.12.0-SNAPSHOT, new hardware ;;; 2016 Apr 12, v2.12.0-SNAPSHOT, refactor + larger data + new hardware
{:reader {:round 51217, :freeze 16729, :thaw 34488, :size 27698}} {:reader {:round 52734, :freeze 18066, :thaw 34668, :size 27839}}
{:lzma2 {:round 42066, :freeze 27249, :thaw 14817, :size 11232}} {:lzma2 {:round 42746, :freeze 27586, :thaw 15160, :size 11252}}
{:fressian {:round 6594, :freeze 4789, :thaw 1805, :size 16985}} {:fressian {:round 6700, :freeze 4968, :thaw 1732, :size 17074}}
{:encrypted {:round 4664, :freeze 2856, :thaw 1808, :size 16132}} {:encrypted {:round 4819, :freeze 3024, :thaw 1795, :size 16164}}
{:default {:round 4127, :freeze 2546, :thaw 1581, :size 16113}} {:default {:round 4362, :freeze 2695, :thaw 1667, :size 16134}}
{:fast1 {:round 3541, :freeze 2024, :thaw 1517, :size 16975}} {:fast1 {:round 3754, :freeze 2149, :thaw 1605, :size 17052}}
{:fast2 {:round 3497, :freeze 2018, :thaw 1479, :size 16971}} {:fast2 {:round 3730, :freeze 2156, :thaw 1574, :size 17048}}
;; :reader/:default ratio: ~12.09
;;; 2015 Oct 6, v2.11.0-alpha4 ;;; 2015 Oct 6, v2.11.0-alpha4
{:reader {:round 73409, :freeze 21823, :thaw 51586, :size 27672}} {:reader {:round 73409, :freeze 21823, :thaw 51586, :size 27672}}
@ -85,6 +86,7 @@
{:default {:round 6304, :freeze 3824, :thaw 2480, :size 16122}} {:default {:round 6304, :freeze 3824, :thaw 2480, :size 16122}}
{:fast1 {:round 5352, :freeze 3272, :thaw 2080, :size 16976}} {:fast1 {:round 5352, :freeze 3272, :thaw 2080, :size 16976}}
{:fast2 {:round 5243, :freeze 3238, :thaw 2005, :size 16972}} {:fast2 {:round 5243, :freeze 3238, :thaw 2005, :size 16972}}
;; :reader/:default ratio: 11.64
;; ;;
{:reader {:round 26, :freeze 17, :thaw 9, :size 2}} {:reader {:round 26, :freeze 17, :thaw 9, :size 2}}
{:lzma2 {:round 3648, :freeze 3150, :thaw 498, :size 68}} {:lzma2 {:round 3648, :freeze 3150, :thaw 498, :size 68}}