[ 
https://issues.apache.org/jira/browse/MAHOUT-862?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13145276#comment-13145276
 ] 

Dawid Weiss commented on MAHOUT-862:
------------------------------------

Checked the source code of openjdk out of curiosity. Mapped buffers (for 
example longbuffer over bytebuffer) are implemented with a mix of various 
intrisics. For example in:
{code}
    public LongBuffer put(int i, long x) {
        Bits.putLongL(bb, ix(checkIndex(i)), x);
        return this;
    }
{code}

checkIndex is an intrinsic and putLongL uses internal unchecked _put methods, 
so the sequence:
{code}
    static void putLongL(ByteBuffer bb, int bi, long x) {
        bb._put(bi + 7, long7(x));
        bb._put(bi + 6, long6(x));
        bb._put(bi + 5, long5(x));
        bb._put(bi + 4, long4(x));
        bb._put(bi + 3, long3(x));
        bb._put(bi + 2, long2(x));
        bb._put(bi + 1, long1(x));
        bb._put(bi    , long0(x));
    } 
{code}
is pretty much index-checked once. Bits contains lots of other accesses to 
Unsafe and I bet this is most of the speedup over normal Java code.

I didn't have the time to inspect assembly dumps to verify for sure, but the 
above should pretty much address the questions raised earlier in this thread. 
[Applies to SUN/Oracle HotSpot only, didn't check other VMs.]
                
> MurmurHash 3.0
> --------------
>
>                 Key: MAHOUT-862
>                 URL: https://issues.apache.org/jira/browse/MAHOUT-862
>             Project: Mahout
>          Issue Type: Improvement
>            Reporter: Grant Ingersoll
>            Assignee: Grant Ingersoll
>            Priority: Minor
>             Fix For: 0.6
>
>         Attachments: MAHOUT-862.patch
>
>
> Yonik has ported an implementation of MurmurHash 3.0 and put it in the public 
> domain: http://www.lucidimagination.com/blog/2011/09/15/murmurhash3-for-java/
> It's a port of https://sites.google.com/site/murmurhash/ which says: 
> {quote}
> (I reserve the right to tweak the constants after people have had a chance to 
> bang on it). Murmur3 has better performance than MurmurHash2, no repetition 
> flaw, comes in 32/64/128-bit versions for both x86 and x64 platforms, and the 
> 128-bit x64 version is blazing fast - over 5 gigabytes per second on my 3 
> gigahertz Core 2.
> In addition, the library of test code that I use to test MurmurHash (called 
> SMHasher) has been released - it's still rough (and will only compile under 
> VC++ at the moment), but it contains everything needed to verify hash 
> functions of arbitrary output bit-lengths.
> Murmur3 and all future versions will be hosted on Google Code here - 
> http://code.google.com/p/smhasher/ - you can access the codebase via the 
> 'Source' tab at the top.
> {quote}
> See also http://code.google.com/p/smhasher/
> We should add support for it and hook into MinHash

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to