Giter Site home page Giter Site logo

Comments (5)

jelmerk avatar jelmerk commented on June 3, 2024

Do you have the code somewhere ? It's definitely slower but not 100 times for sure

from hnswlib.

siddhsql avatar siddhsql commented on June 3, 2024

I have attached the code as zip file. I am testing against the glove-100-angular dataset that can be downloaded from ann-benchmarks.com. It has 1M vectors. d = 100. and 10k test vectors.

src.zip

The Java code (this library) takes 2 mins to build the index (i.e., adding 1M vectors to the index) and 4.6s to query the index (10k test vectors).

The C++ code (original hnswlib) takes 35.94 seconds to build the index and 0.048 seconds to query the index (i.e., 100x faster).

Both tests run on same Linux machine with 14 threads (1 thread per vCPU). the multi-threading only applies when building the index. Querying is single-threaded in both cases.

from hnswlib.

siddhsql avatar siddhsql commented on June 3, 2024

one question (unrelated to the topic in this thread btw) is that w.r.t. this:

Object lock = locks.computeIfAbsent(item.id(), k -> new Object());

Can't you just use

synchronized (node)

like you do on line 268

Another question I have is that I tried the code with SIMD optimizations on a AVX512 CPU but the perf is basically the same. Do you know why? I was expecting 16x improvement in perf (16*32=512) as one instruction would process 16 floats.

from hnswlib.

siddhsql avatar siddhsql commented on June 3, 2024

re: this: Another question I have is that I tried the code with SIMD optimizations on a AVX512 CPU but the perf is basically the same. Do you know why? I was expecting 16x improvement in perf (16*32=512) as one instruction would process 16 floats.

could it be that Java compiler is auto-vectorizing the code without explicit SIMD optimizations? e.g., see this:

However, Oracle has apparently just accepted Intel's contribution to the HotSpot that enables FMA vectorization using AVX-512. To the delight of auto-vectorization fans and those lucky ones to have access to AVX-512 hardware, this may (with some luck) appear in one of the next jdk9 EA builds (beyond b175).

A link to support the previous statement (RFR(M): 8181616: FMA Vectorization on x86): mail.openjdk.java.net/pipermail/hotspot-compiler-dev/2017-June/…

do you know if is there any way to verify?

from hnswlib.

jianshu93 avatar jianshu93 commented on June 3, 2024

Hello All,
Is this issue fixed or something. Just want to check the most recent status on the java implementation. And also, I think bray-curtis distance is not a metric while hnsw requires that distance should be a metric.

Thanks,

Jianshu

from hnswlib.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.