ewfian / faiss-node

Node.js bindings for faiss
https://www.npmjs.com/package/faiss-node
MIT License
107 stars 10 forks source link

Support reset & dispose #42

Open asilvas opened 11 months ago

ewfian commented 11 months ago

Thanks for your new PR, Noticed that dispose method was added. Could you please clarify the indentation? I see that it's being checked in every method, and I'm trying to understand its necessity.

Also, I noticed that the underlying implementation of the dispose method is actually calling index_.release();. If we keep this method, would it be more appropriate to rename it to release to reflect its actual functionality?

asilvas commented 11 months ago

Thanks for your new PR, Noticed that dispose method was added. Could you please clarify the indentation? I see that it's being checked in every method, and I'm trying to understand its necessity.

Also, I noticed that the underlying implementation of the dispose method is actually calling index_.release();. If we keep this method, would it be more appropriate to rename it to release to reflect its actual functionality?

Dispose is used to free all memory associated with an index. If you're OK with a segfault if calling a method on a released index, then I'm fine reverting the checks from every method.

dispose is consistent naming across ML frameworks for freeing memory. But up to you if you want to change it.

ewfian commented 11 months ago

@asilvas In the world of javascript, memory is rarely dealt with, the reset and dispose have similar uses. I want to remove the dispose method first, and merge this pr. Is this okay?

asilvas commented 11 months ago

@asilvas In the world of javascript, memory is rarely dealt with, the reset and dispose have similar uses. I want to remove the dispose method first, and merge this pr. Is this okay?

I'd prefer to keep both as there is no other way to free all memory, and have need for recreating a lot of indexes.