nmslib / hnswlib

Header-only C++/python library for fast approximate nearest neighbors
https://github.com/nmslib/hnswlib
Apache License 2.0
4.12k stars 609 forks source link

Optimize rebuildIndex memory allocation #517

Open Axlgrep opened 8 months ago

Axlgrep commented 8 months ago
  1. The current data_level0memory continuous memory block design can result in memory doubling during large index resize, which is very unfriendly to memory and performance(the realloc operation may trigger an expensive data copy action),so we redesigned data_level0memory (using multiple small memory blocks linked together).
  2. In addition, we found some obvious _mm_prefetch out-of-bounds access issues and fixed them (there may be other hidden issues, please check them as well).

510