News for hackers. Stuff that matters.
Re:Dimsum is like head or tail, but pulls randomly from the ... by nullc on Monday November 26, 2012 @02:59PM (#4833668)
uhhh. You mean like shuf -n NNNN ?
Re:Dimsum is like head or tail, but pulls randomly from the ... by bo1024 on Monday November 26, 2012 @03:08PM (#4833724)
I wonder if the implementation of shuf would handle very large input efficiently? Reservoir sampling wouldn't need to keep the whole input in memory, which could be an advantage. But I don't know how shuf works.
Re:Dimsum is like head or tail, but pulls randomly from the ... by teraflop on Monday November 26, 2012 @03:20PM (#4833788)
Doesn't look like it. I just tried running "yes | shuf -n 1" (using the latest version of GNU coreutils, 8.20) and its memory consumption increased steadily until I killed it.

It seems like this would be a really useful improvement, and I'm surprised that it doesn't already seem to have been requested on the coreutils issue tracker.

Re:Dimsum is like head or tail, but pulls randomly from the ... by malcook on Monday November 26, 2012 @06:18PM (#4834569)
did you try "yes | dimsum -n 1"?

In my hands, `top` shows resident memory increasing steadily too....

It is perhaps more instructive to compare output from, for example

seq 1 1000000 | valgrind --time-unit=B --pages-as-heap=yes --trace-children=yes --tool=massif --massif-out-file=massif.dimsum.100000.out.%p dimsum -n 1

with

seq 1 1000000 | valgrind --time-unit=B --pages-as-heap=yes --trace-children=yes --tool=massif --massif-out-file=massif.shuf.100000.out.%p shuf -n 1

in my hands, shuf is faster and uses less memory for this task.

How about you?

Re:Dimsum is like head or tail, but pulls randomly from the ... by snoble on Monday November 26, 2012 @08:29PM (#4835074)
sigh, memory leak. It's fixed in github. When camilo is around I'll get him to update the gem
Re:Dimsum is like head or tail, but pulls randomly from the ... by malcook on Tuesday November 27, 2012 @01:25PM (#4837972)
thanks - looking forward to the patch
Re:Dimsum is like head or tail, but pulls randomly from the ... by snoble on Tuesday November 27, 2012 @03:28PM (#4838778)
try a `gem update`. Memory performance should be much better now but I'm still curious about speed
Re:Dimsum is like head or tail, but pulls randomly from the ... by malcook on Tuesday November 27, 2012 @01:24PM (#4837960)
Agreed it would be.

So, let's pursue this: http://lists.gnu.org/archive/html/coreutils/2012-11/msg00079...

Re:Dimsum is like head or tail, but pulls randomly from the ... by nburger on Monday November 26, 2012 @03:11PM (#4833733)
or "sort -R"...
Re:Dimsum is like head or tail, but pulls randomly from the ... by gwern on Monday November 26, 2012 @03:37PM (#4833879)
sort -R isn't actually a random permutation or shuffle like one would ordinarily expect from a 'random' output: if you read the man page very carefully, you'll notice it only speaks of 'random hash' which means that 2 lines which are identical (quite possible and common) will be hashed to the same value and placed consecutively in the output.

(This bit me once. Filed a bug about maybe clarifying the man page, but nope, apparently we're all supposed to recognize instantly the implication of a random hash.)