From d3cc0899604698f1e78867cf5396031268db55f1 Mon Sep 17 00:00:00 2001 From: searchivairus Date: Tue, 13 Feb 2018 19:48:40 -0500 Subject: [PATCH 1/2] updating README for 1.7.1 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c223cd2..2ba4bb0 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Non-Metric Space Library (NMSLIB) ================= -The latest **pre**-release is [1.7](https://github.com/searchivarius/nmslib/releases/tag/v1.7). Note that the manual is not updated to reflect some of the changes. In particular, we changed the build procedure for Windows. Also note that the manual targets primiarily developers who will extend the library. For most other folks, [Python binding docs should be sufficient](python_bindings). +The latest **pre**-release is [1.7.1](https://github.com/searchivarius/nmslib/releases/tag/v1.7.1). Note that the manual is not updated to reflect some of the changes. In particular, we changed the build procedure for Windows. Also note that the manual targets primiarily developers who will extend the library. For most other folks, [Python binding docs should be sufficient](python_bindings). ----------------- Non-Metric Space Library (NMSLIB) is an **efficient** cross-platform similarity search library and a toolkit for evaluation of similarity search methods. The core-library does **not** have any third-party dependencies. From 6e3f91dc6b79475a411b79b1880c45f2a99bdfa5 Mon Sep 17 00:00:00 2001 From: Ben Frederickson Date: Fri, 16 Feb 2018 10:15:55 -0800 Subject: [PATCH 2/2] Fix deadlock in child threads launched from python Pybind11 seems to have an issue in gil_scoped_acquire when being called from child threads created from python. This resulted in a deadlock here: https://github.com/searchivarius/nmslib/issues/291 A simple workaround is to use the PyGILState_Ensure from the python c-api directly instead. --- python_bindings/nmslib.cc | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/python_bindings/nmslib.cc b/python_bindings/nmslib.cc index 6bc86ca..764de97 100644 --- a/python_bindings/nmslib.cc +++ b/python_bindings/nmslib.cc @@ -74,12 +74,12 @@ struct IndexWrapper { loadParams(space_params))) { auto vectSpacePtr = dynamic_cast*>(space.get()); if (data_type == DATATYPE_DENSE_VECTOR && vectSpacePtr == nullptr) { - throw std::invalid_argument("The space type " + space_type + + throw std::invalid_argument("The space type " + space_type + " is not compatible with the type DENSE_VECTOR, only dense vector spaces are allowed!"); } auto vectSiftPtr = dynamic_cast(space.get()); if (data_type == DATATYPE_DENSE_UINT8_VECTOR && vectSiftPtr == nullptr) { - throw std::invalid_argument("The space type " + space_type + + throw std::invalid_argument("The space type " + space_type + " is not compatible with the type DENSE_UINT8_VECTOR!"); } } @@ -361,6 +361,20 @@ struct IndexWrapper { ObjectVector data; }; +// pybind11::gil_scoped_acquire can deadlock when acquiring the GIL on threads +// created from python (https://github.com/searchivarius/nmslib/issues/291) +// This might be fixed in a future version of pybind11 (https://github.com/pybind/pybind11/pull/1211) +// but until then, lets fall back to the python c-api to fix. +struct AcquireGIL { + PyGILState_STATE state; + AcquireGIL() + : state(PyGILState_Ensure()) { + } + ~AcquireGIL() { + PyGILState_Release(state); + } +}; + class PythonLogger : public Logger { public: @@ -374,7 +388,7 @@ class PythonLogger int line, const char * function, const std::string & message) { - py::gil_scoped_acquire l; + AcquireGIL l; switch(severity) { case LIB_DEBUG: inner.attr("debug")(message);