Skip to content

Computation Time is much longer for Float64 than Float32 #8

@JonasIsensee

Description

@JonasIsensee

This is really odd.
The computation time both for creating the graphs and for searching
is nearly 2× times longer for Float64 compared to Float32 data points.

How can this be? (The C++ library doesn't show this behaviour)
I thought my architecture is optimized for 64bit..

using HNSW
dim = 128
num_elements = 10000


data = [rand(Float32,dim) for n=1:num_elements];
 hnsw = HierarchicalNSW(data; efConstruction = 200, M = 16)
@time add_to_graph!(hnsw)
 # --> 4.820807 seconds (415.10 k allocations: 158.142 MiB, 1.29% gc time)

data = [rand(Float64,dim) for n=1:num_elements]
 hnsw = HierarchicalNSW(data; efConstruction = 200, M = 16)
@code_warntype  add_to_graph!(hnsw) #to trigger compilation
@time add_to_graph!(hnsw)

# -->   7.995207 seconds (379.92 k allocations: 294.682 MiB, 0.71% gc time)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions