Hi,

Disclaimer: believing this kind of benchmark. No clue whether the
following is really valid.

On 5 Apr., 09:44, Ken Wesson <kwess...@gmail.com> wrote:

> If I understand your claim correctly, it's therefore wrong.

Since it's correct, you don't understand my claim correctly. The
numbers in between are the memrem runs.

Using your partition-by.

user=> (do ...) ; long command snipped
----> Start empty.
----> (def s nil)
0
1
2
3
4
5
6
----> (def s (partition-by alength (map byte-array [100000000
100000000 100000000 200000000])))
0
1
2
3
4
5
6
----> Nothing realised, yet. Get first group.
----> (first s)
0
1
----> Mem used. Drop head, get rest.
----> (def s (rest s))
0
1
----> Head is hold? Realise rest.
----> (def s (seq s))
0
1
2
3
4
----> References gone. Memory freed.
nil

Using core partition-by:

user=> (do ...) ; long command snipped
----> Start empty.
----> (def s nil)
0
1
2
3
4
5
6
----> (def s (clojure.core/partition-by alength (map byte-array
[100000000 100000000 100000000 200000000])))
0
1
2
3
4
5
6
----> Nothing realised, yet. Get first group.
----> (first s)
0
1
----> Mem used. Drop head, get rest.
----> (def s (rest s))
0
1
----> Head is hold? Realise rest.
----> (def s (seq s))
0
1
----> Huh?
nil

This was surprising and turned out to be a bug in core partition-by.
Using fixed core partition-by:

user=> (do ...) ; long command snipped
----> Start empty.
----> (def s nil)
0
1
2
3
4
5
6
----> (def s (fixed-core-partition-by alength (map byte-array
[100000000 100000000 100000000 200000000])))
0
1
2
3
4
5
6
----> Nothing realised, yet. Get first group.
----> (first s)
0
1
----> Mem used. Drop head, get rest.
----> (def s (rest s))
0
1
2
3
4
----> Note that head is *not* hold, references to first are dropped.
nil

Interesting where such discussions can lead: it helped to uncover an
issue on an edge case with core partition-by.

Sincerely
Meikel

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to