Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip rebuild from scratch after cmake is ran #1636

Merged
merged 1 commit into from
Apr 23, 2024

Conversation

jmazanec15
Copy link
Member

@jmazanec15 jmazanec15 commented Apr 19, 2024

Description

By commiting the patch changes (via git am instead of git apply), this commit prevents the libraries to be built from scratch every time cmake is ran. This will save additional build time.

from cmake, this looks like:

-- Applying custom patches.
Applying: Add IDGrouper for HNSW
Using index info to reconstruct a base tree...
M	faiss/CMakeLists.txt
M	faiss/Index.h
M	faiss/IndexHNSW.cpp
M	faiss/IndexIDMap.cpp
M	faiss/IndexIDMap.h
M	faiss/impl/HNSW.cpp
M	faiss/impl/ResultHandler.h
M	tests/CMakeLists.txt
Falling back to patching base and 3-way merge...
Auto-merging tests/CMakeLists.txt
Auto-merging faiss/impl/HNSW.cpp
Auto-merging faiss/IndexIDMap.cpp
Auto-merging faiss/Index.h
No changes -- Patch already applied.
Applying: Enable precomp table to be shared ivfpq
Using index info to reconstruct a base tree...
M	faiss/IndexIVFPQ.cpp
M	faiss/IndexIVFPQ.h
M	faiss/IndexIVFPQFastScan.cpp
M	faiss/IndexIVFPQFastScan.h
M	tests/CMakeLists.txt
M	tests/test_disable_pq_sdc_tables.cpp
Falling back to patching base and 3-way merge...
Auto-merging tests/CMakeLists.txt
No changes -- Patch already applied.

In addition to this, this commit separates out the different functionality to make the build system more readable. We can continue to iterate on this in the future.

Issues Resolved

#1552

Check List

  • New functionality includes testing.
    • All tests pass
  • New functionality has been documented.
    • New functionality has javadoc added
  • Commits are signed as per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@navneet1v
Copy link
Collaborator

@jmazanec15 something seems to go wrong with BWC.. Not sure if it is because of this change

@jmazanec15
Copy link
Member Author

@navneet1v Windows was a GHA failure to setup Java. The BWC seem more related to this change. Taking a look

@@ -17,9 +17,7 @@ oss/*
jni/CMakeCache.txt
jni/CMakeFiles
jni/Makefile
jni/cmake*
jni/CPack*
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already removed CPack in #1620

@jmazanec15 jmazanec15 force-pushed the issue-1552 branch 16 times, most recently from 6243eba to d4dbc51 Compare April 23, 2024 15:54
@jmazanec15 jmazanec15 force-pushed the issue-1552 branch 2 times, most recently from 5e01d7b to 698b4f3 Compare April 23, 2024 16:03
@@ -38,19 +38,10 @@ jobs:
with:
submodules: true

# Git functionality in CMAKE file does not work with given ubuntu image. Therefore, handling it here.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is no longer issue so I removed. All patches should be specified directly in build system.

navneet1v
navneet1v previously approved these changes Apr 23, 2024
endif()
endif()

include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/init-faiss.cmake)
find_package(OpenMP REQUIRED)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we move this to init script like for other packages?
find_package(OpenMP REQUIRED)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question - I held off here because we directly link the shared library (opensearch_faiss) against openmp here - so I figured it was good to keep in main cmake because its related to opensearch_faiss

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense. Thanks!

set(FAISS_ENABLE_PYTHON OFF)

if(NOT DEFINED SIMD_ENABLED)
set(SIMD_ENABLED true) # set default value as true if the argument is not set
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you verified if it is passing the argument properly for SIMD_ENABLED after these refactoring changes?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, include directive will just basically copy and paste the code into the section its included. See https://cmake.org/cmake/help/latest/command/include.html.

# Git functionality in CMAKE file does not work with given ubuntu image. Therefore, handling it here.
- name: Apply Git Patch
# Deleting file at the end to skip `git apply` inside CMAKE file
- name: Setup git user
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add one comment for setting up a git user just for reference?

By commiting the patch changes, this commit prevents the libraries to be
built from scratch every time cmake is ran. This will save additional
build time.

In addition to this, this commit separates out the different
functionality to make the build system more readable. We can continue to
iterate on this in the future.

Signed-off-by: John Mazanec <[email protected]>
@jmazanec15 jmazanec15 merged commit c35f6ad into opensearch-project:main Apr 23, 2024
52 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Apr 23, 2024
By commiting the patch changes, this commit prevents the libraries to be
built from scratch every time cmake is ran. This will save additional
build time.

In addition to this, this commit separates out the different
functionality to make the build system more readable. We can continue to
iterate on this in the future.

Signed-off-by: John Mazanec <[email protected]>
(cherry picked from commit c35f6ad)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 2.x Infrastructure Changes to infrastructure, testing, CI/CD, pipelines, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants