Details
-
Improvement
-
Resolution: Fixed
-
Major
-
7.6.2
-
Linux, MacOS, Windows
-
0
-
Build Team 2024 Sprint 3
Description
- the deps in tlm builds `libjemalloc.so` with a prefix `je_`. Given the numerous dependent .so files for faiss, we have to update every `malloc` symbol to a `je_malloc` symbol in all the shared objects that faiss depends on such as
- libopenblas.so
- libpthread.so
- libsigar.so (cbft dep)
- CGO package (go-faiss)
- MB-60913 shows the advantage of linking a normal `libjemalloc.so` (which is built from source without the prefix) (at runtime) is huge, and there is no advantage in linking tlm's libjemalloc.so.
- We require jemalloc to be built without the prefix specifically for faiss. So that jemalloc.exploded will have
- libjemalloc.so (used by memcached and indexer and which has prefix ="je_")
- libjemallocd.so
- libjemalloc_faiss.so (used for cbft only ... built normally without any prefix, but built with suffix "_faiss"
- I have done this manually in https://github.com/blevesearch/faiss/pull/16 where I build jemalloc from scratch as part of the faiss build process.
- Linking this libjemalloc_faiss.so file at build time is now giving the same improvement as runtime linking as seen in local test.
- Required to set CMake variables
- FAISS_JEMALLOC_LIBRARY = libjemalloc_faiss.so
- FAISS_JEMALLOC_INCLUDE_DIR = jemalloc/jemalloc_faiss.h
- We will use these CMAKE variables over
- JEMALLOC_LIBRARIES = libjemalloc.so
- JEMALLOC_INCLUDE_DIR = jemalloc/jemalloc.h
- So that in FAISS i can directly use these CMAKE variables to link to jemalloc and not have to build jemalloc from scratch ... in faiss
- TLM code attached here, doesnt seem to do anything - need some assistance in getting cdeps to give the libjemalloc_faiss.so file in jemalloc.exploded and setting the new CMAKE variables.
- tlm example https://review.couchbase.org/c/tlm/+/208103
- By ensuring that libjemalloc_faiss.so is linked first to cbft (before libc.so) as shown in lddPic.png we can ensure that every call to malloc will be resolved by the symbol table of libjemalloc_faiss.so
- the symbol table of libjemalloc.so and libjemalloc_faiss.so is shown in symbolComp.png and we can see that libjemalloc_faiss.so defines the overriding symbols for malloc and free
Attachments
Issue Links
- relates to
-
MB-61499 FTS latency is getting regressed with jemalloc
- Closed