Uploaded image for project: 'Couchbase Server'
  1. Couchbase Server
  2. MB-61410

Build jemalloc without 'je_' prefix for FAISS

    XMLWordPrintable

Details

    • Improvement
    • Resolution: Fixed
    • Major
    • 7.6.2
    • 7.6.2
    • build, fts
    • 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

        1. lddPic.png
          lddPic.png
          153 kB
        2. symbolComp.png
          symbolComp.png
          175 kB

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              abhinav Abhi Dangeti
              rahul.rampure Rahul Rampure
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 25h
                  25h

                  PagerDuty