Skip to content

Conversation

@wxyucs
Copy link
Collaborator

@wxyucs wxyucs commented Aug 26, 2025

Summary by Sourcery

Update codebase to conform to revised clang-tidy rules by modernizing C++ idioms, refining build flags, and refreshing lint configurations.

Enhancements:

  • Replace raw new/reset pointer usage with std::shared_ptr and std::make_shared for reader_ and index_ objects
  • Use std::conditional_t, emplace(), and emplace_back() in place of older type traits and push operations
  • Remove redundant static_casts in BLAS calls, arithmetic expressions, and container initializations
  • Add missing includes and fully qualify calls, and eliminate unnecessary return statements in void functions

Build:

  • Add -Wno-knl-knm-isa-support-removed flag to AVX512 targets in simd CMakeLists

Documentation:

  • Refresh .clang-tidy configurations in the project root and key subdirectories

@wxyucs wxyucs self-assigned this Aug 26, 2025
@wxyucs wxyucs added the kind/improvement Code improvements (variable/function renaming, refactoring, etc. ) label Aug 26, 2025
@wxyucs wxyucs requested a review from LHT129 as a code owner August 26, 2025 11:37
@gemini-code-assist
Copy link

Important

Installation incomplete: to start using Gemini Code Assist, please ask the organization owner(s) to visit the Gemini Code Assist Admin Console and sign the Terms of Services.

@sourcery-ai
Copy link

sourcery-ai bot commented Aug 26, 2025

Reviewer's Guide

This PR updates the clang-tidy configuration throughout the codebase and applies corresponding lint-driven modernizations: it transitions raw pointer usage to make_shared, tidies up includes, simplifies API calls (e.g., BLAS and STL), adjusts CMake compile flags for AVX512, and propagates updated .clang-tidy files into subdirectories.

Class diagram for simplified heap and container usage

classDiagram
    class DistanceHeap {
        + Push(const DistanceRecord& record)
        + Push(float dist, InnerIdType id)
    }
    class MemmoveHeap {
        + Push(float dist, InnerIdType id)
    }
    DistanceHeap --> DistanceRecord
    MemmoveHeap --> DistanceRecord
Loading

Class diagram for simplified container initialization in HGraph and ODescent

classDiagram
    class HGraph {
        - Vector<InnerIdType> route_graph_ids
        - InnerIdType entry_point_id_
        + build_by_odescent(DatasetPtr data)
    }
    class ODescent {
        - Vector<Linklist> graph_
        + Build(Vector<InnerIdType> ids_sequence, GraphInterfacePtr graph)
    }
    HGraph --> Vector
    ODescent --> Linklist
Loading

Class diagram for IVFParameter bucket count calculation

classDiagram
    class IVFParameter {
        - BucketParam* bucket_param
        - IVFPartitionStrategyParameter* ivf_partition_strategy_parameter
        + FromJson(JsonType json)
    }
    class BucketParam {
        - int buckets_count
    }
    class IVFPartitionStrategyParameter {
        - GNOIMIParam* gnoimi_param
        - IVFPartitionStrategyType partition_strategy_type
    }
    class GNOIMIParam {
        - int first_order_buckets_count
        - int second_order_buckets_count
    }
    IVFParameter --> BucketParam
    IVFParameter --> IVFPartitionStrategyParameter
    IVFPartitionStrategyParameter --> GNOIMIParam
Loading

File-Level Changes

Change Details Files
Modernize smart pointer usage and includes
  • Add includes where missing
  • Replace reset(new T(...)) with make_shared(...) assignments
src/index/diskann.cpp
src/quantization/rabitq_quantization/rabitq_quantizer.cpp
Simplify CBLAS sgemv calls
  • Remove redundant static_cast on matrix dimensions
  • Use plain blasint variables for rows, cols, and leading dimension
src/impl/transform/random_orthogonal_transformer.cpp
Enhance CMake AVX512 compile flags
  • Add -Wno-knl-knm-isa-support-removed to AVX512 build flags
src/simd/CMakeLists.txt
Adopt modern STL patterns
  • Use emplace/emplace_back instead of push({…}) or push_back
  • Replace std::conditional<…>::type with std::conditional_t
  • Eliminate unnecessary static_cast in bitwise operations
src/algorithm/sindi/sindi.cpp
src/algorithm/hgraph.cpp
src/algorithm/ivf.cpp
src/impl/heap/distance_heap.cpp
src/impl/heap/memmove_heap.cpp
src/impl/odescent_graph_builder.cpp
Qualify IO buffer release
  • Prefix ReleaseImpl calls with vsag::AsyncIO:: for clarity
src/io/async_io.cpp
Simplify dataset creation calls
  • Remove superfluous static_cast on dim argument
src/utils/util_functions.cpp
Propagate updated clang-tidy configs
  • Copy and align .clang-tidy in subdirectories to match root settings
.clang-tidy
src/algorithm/hnswlib/.clang-tidy
src/simd/.clang-tidy

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@mergify mergify bot added the module/simd label Aug 26, 2025
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes - here's some feedback:

  • You have the same reader_ = make_shared<LocalFileReader>(batch_read_); index_ = make_shared<diskann::PQFlashIndex<...>>(...) sequence in several methods—consider extracting that into a helper to reduce duplication.
  • The AVX-512 compile flags are duplicated with only the warning suppression added—consider defining a variable or property in CMake to DRY those flags and keep them in sync.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- You have the same `reader_ = make_shared<LocalFileReader>(batch_read_); index_ = make_shared<diskann::PQFlashIndex<...>>(...)` sequence in several methods—consider extracting that into a helper to reduce duplication.
- The AVX-512 compile flags are duplicated with only the warning suppression added—consider defining a variable or property in CMake to DRY those flags and keep them in sync.

## Individual Comments

### Comment 1
<location> `src/algorithm/ivf.cpp:943` </location>
<code_context>
                 throw VsagException(ErrorType::INTERNAL_ERROR, "invalid inner_id");
             }
             this->location_map_[ids[j]] =
-                (static_cast<uint64_t>(i) << LOCATION_SPLIT_BIT) | static_cast<uint64_t>(j);
+                (static_cast<uint64_t>(i) << LOCATION_SPLIT_BIT) | j;
         }
     }
</code_context>

<issue_to_address>
Removing static_cast for j may introduce type mismatch if j is not uint64_t.

Please verify that j is always a uint64_t, or retain the cast to prevent type issues.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

throw VsagException(ErrorType::INTERNAL_ERROR, "invalid inner_id");
}
this->location_map_[ids[j]] =
(static_cast<uint64_t>(i) << LOCATION_SPLIT_BIT) | static_cast<uint64_t>(j);
Copy link

Choose a reason for hiding this comment

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

issue (bug_risk): Removing static_cast for j may introduce type mismatch if j is not uint64_t.

Please verify that j is always a uint64_t, or retain the cast to prevent type issues.

@wxyucs wxyucs force-pushed the update-clang-tidy branch from 0aeafec to 42edb9c Compare August 26, 2025 11:42
@codecov
Copy link

codecov bot commented Aug 26, 2025

Codecov Report

❌ Patch coverage is 84.33735% with 13 lines in your changes missing coverage. Please review.

@@            Coverage Diff             @@
##             main    #1088      +/-   ##
==========================================
- Coverage   91.53%   91.31%   -0.22%     
==========================================
  Files         303      303              
  Lines       17497    17584      +87     
==========================================
+ Hits        16016    16057      +41     
- Misses       1481     1527      +46     
Flag Coverage Δ
cpp 91.31% <84.33%> (-0.22%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
common 92.64% <100.00%> (ø)
datacell 90.08% <83.87%> (-0.41%) ⬇️
index 90.52% <82.75%> (-0.22%) ⬇️
simd 100.00% <ø> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 791eb91...9f3638b. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@wxyucs wxyucs closed this Oct 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/improvement Code improvements (variable/function renaming, refactoring, etc. ) module/simd module/tools size/L version/0.17

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants