mirror of
https://github.com/facebookresearch/faiss.git
synced 2025-06-03 16:25:11 +08:00
Summary: Following up on issue https://github.com/facebookresearch/faiss/issues/2054 it seems that this code crashes Faiss (instead of just leaking memory). Findings: - when running in MT mode, each search in an indexflat used as coarse quantizer consumes some memory - this mem consumption does not appear in single-thread mode or with few threads - in gdb it appears that even when the nb of queries is 1, each search spawns max_threads threads (80 on the test machine) This diff: - adds a C++ test that checks how much mem is used when repeatedly searching a vector - adjusts the number of search threads to the number of query vectors. This is especially useful for single-vector queries. Reviewed By: beauby Differential Revision: D31142383 fbshipit-source-id: 134ddaf141e7c52a854cea398f5dbf89951a7ff8
50 lines
1.2 KiB
CMake
50 lines
1.2 KiB
CMake
# Copyright (c) Facebook, Inc. and its affiliates.
|
|
# All rights reserved.
|
|
#
|
|
# This source code is licensed under the BSD-style license found in the
|
|
# LICENSE file in the root directory of this source tree.
|
|
|
|
set(FAISS_TEST_SRC
|
|
test_binary_flat.cpp
|
|
test_dealloc_invlists.cpp
|
|
test_ivfpq_codec.cpp
|
|
test_ivfpq_indexing.cpp
|
|
test_lowlevel_ivf.cpp
|
|
test_merge.cpp
|
|
test_omp_threads.cpp
|
|
test_ondisk_ivf.cpp
|
|
test_pairs_decoding.cpp
|
|
test_params_override.cpp
|
|
test_pq_encoding.cpp
|
|
test_sliding_ivf.cpp
|
|
test_threaded_index.cpp
|
|
test_transfer_invlists.cpp
|
|
test_mem_leak.cpp
|
|
)
|
|
|
|
add_executable(faiss_test ${FAISS_TEST_SRC})
|
|
|
|
if(FAISS_OPT_LEVEL STREQUAL "avx2")
|
|
target_link_libraries(faiss_test PRIVATE faiss_avx2)
|
|
else()
|
|
target_link_libraries(faiss_test PRIVATE faiss)
|
|
endif()
|
|
|
|
include(FetchContent)
|
|
FetchContent_Declare(googletest
|
|
URL "https://github.com/google/googletest/archive/release-1.10.0.tar.gz")
|
|
set(BUILD_GMOCK CACHE BOOL OFF)
|
|
set(INSTALL_GTEST CACHE BOOL OFF)
|
|
FetchContent_MakeAvailable(googletest)
|
|
|
|
find_package(OpenMP REQUIRED)
|
|
|
|
target_link_libraries(faiss_test PRIVATE
|
|
OpenMP::OpenMP_CXX
|
|
gtest_main
|
|
)
|
|
|
|
# Defines `gtest_discover_tests()`.
|
|
include(GoogleTest)
|
|
gtest_discover_tests(faiss_test)
|