Skip to content

[CUBVEC-172] Add L0-level stats and graph profile for HNSW#6897

Merged
hgryoo merged 24 commits intoCUBRID:cubvec/cubvecfrom
hgryoo:CUBVEC-172
Mar 21, 2026
Merged

[CUBVEC-172] Add L0-level stats and graph profile for HNSW#6897
hgryoo merged 24 commits intoCUBRID:cubvec/cubvecfrom
hgryoo:CUBVEC-172

Conversation

@hgryoo
Copy link
Copy Markdown
Member

@hgryoo hgryoo commented Mar 11, 2026

http://jira.cubrid.org/browse/CUBVEC-172

Purpose

  • HNSW의 탐색 및 인덱스 빌드 과정에 대한 성능 분석을 보다 정밀하게 수행할 수 있도록
    추가적인 통계 정보를 수집한다.
  • batch 입력 후 HNSW 그래프의 구조에 대한 프로파일 정보를 수집하고 출력한다.
  • 특히 대부분의 연산 비용이 발생하는 Layer 0(L0) 에 대한 별도 통계를 수집하고,
    그래프 탐색 과정에서 발생하는 candidate queue 동작, neighbor scan, storage 접근 등의
    내부 동작을 분석할 수 있는 통계를 추가한다.

Implementation

  • 현재 탐색 중인 HNSW level을 함수 내부의 지역 변수 대신 algo_context::m_level에서 관리하도록 변경
  • 현재 연산이 Layer 0(L0) 에서 수행되는지 여부를 판단하여 L0에 대한 통계를 별도로 수집
  • 다음 통계에 대해 L0 전용 통계를 추가
Num_hnsw_visited_node_l0
Num_hnsw_computed_distances_l0
Num_hnsw_computed_distances_in_refines_l0
Num_hnsw_computed_distances_in_reverse_refines_l0
  • Entry point 변경 통계 추가: 인덱스 빌드 과정에서 새로 삽입된 노드가 더 높은 level을 가질 경우 HNSW의 entry point가 변경
Num_hnsw_entrypoint_updates
  • 그래프 탐색 과정의 내부 동작을 분석하기 위해 다음 통계를 추가:
// candidate queue
Num_hnsw_candidates_push
Num_hnsw_candidates_pop
Num_hnsw_candidates_prune
Num_hnsw_candidates_push_l0
Num_hnsw_candidates_pop_l0
Num_hnsw_candidates_prune_l0

// Neighbor traversal
Num_hnsw_neighbors_scan
Num_hnsw_neighbors_scan_l0
  • 디스크 기반 HNSW 환경에서 I/O 비용을 분석하기 위해 다음 통계를 추가하였다. 이전에는 visited_nodes에서 이 통계를 반영했지만, 그 의미를 명확히 변경하여 visited_nodes는 실제로 그 노드를 방문할때에만 반영하고, 어떤 노드를 방문해야 할 지 판단하기 위해 페이지에 접근하는 경우를 별도로 반영하기 위해서 page_access를 추가했다:
Num_hnsw_page_access
Num_hnsw_vector_access
Num_hnsw_vector_cache_hit
Num_hnsw_vector_cache_miss

(layer 0에 대한 것도 마찬가지로 추가)
  • 그래프 프로파일 수집 및 출력

m=8, 29만건 입력

==== HNSW Graph Profile ====
Total nodes: 289764
Max level: 5
[Level 0] nodes: 289764, avg_degree: 15.9773
[Level 1] nodes: 36208, avg_degree: 7.99699
[Level 2] nodes: 4548, avg_degree: 7.99692
[Level 3] nodes: 557, avg_degree: 7.99641
[Level 4] nodes: 61, avg_degree: 7.13115
[Level 5] nodes: 6, avg_degree: 5

Remarks

함께 포함된 리팩토링 변경:

  • 기존에는 탐색 과정 중 perfmon_add_stat()을 직접 호출하여 통계를 기록
  • 이번 변경에서는 탐색 과정 동안 algo_context 내부 구조체에 통계를 누적한 뒤, 탐색 종료 시 collect_perf_stats()를 호출하여 perfmon 통계에 반영하도록 변경
  • 탐색 루프 내부에서 발생하는 통계 업데이트 오버헤드를 줄이고 코드를 단순화

@hgryoo hgryoo self-assigned this Mar 11, 2026
@hgryoo hgryoo changed the title [CUBVEC-172] Add L0-level stats and entry update counter [CUBVEC-172] Add L0-level stats and entry update counter for HNSW Mar 11, 2026
@hgryoo hgryoo marked this pull request as ready for review March 11, 2026 12:11
@hgryoo hgryoo requested a review from a team as a code owner March 11, 2026 12:11
@hgryoo hgryoo requested review from YeunjunLee, hornetmj, mhoh3963 and vimkim and removed request for a team March 11, 2026 12:11
@greptile-apps
Copy link
Copy Markdown

greptile-apps bot commented Mar 11, 2026

Last reviewed commit: cbd330d

Comment thread src/storage/index_hnsw/hnsw_algo_common.hpp Outdated
Comment thread src/storage/index_hnsw/hnsw_algo.hpp Outdated
Comment thread src/storage/index_hnsw/hnsw_algo_common.hpp Outdated
@greptile-apps
Copy link
Copy Markdown

greptile-apps bot commented Mar 11, 2026

Last reviewed commit: 2cc4125

Comment thread src/storage/index_hnsw/hnsw_algo.hpp
@greptile-apps
Copy link
Copy Markdown

greptile-apps bot commented Mar 11, 2026

Last reviewed commit: 66144bb

Comment thread src/storage/index_hnsw/hnsw_algo.hpp
@greptile-apps
Copy link
Copy Markdown

greptile-apps bot commented Mar 15, 2026

Last reviewed commit: f7951a6

Comment thread src/storage/index_hnsw/hnsw_algo.hpp Outdated
Comment thread src/storage/index_hnsw/hnsw_algo.hpp
Comment thread src/storage/index_hnsw/hnsw_algo.hpp Outdated
@greptile-apps
Copy link
Copy Markdown

greptile-apps bot commented Mar 19, 2026

Last reviewed commit: "revert change"

Comment thread src/storage/index_hnsw/hnsw_storage.cpp Outdated
@greptile-apps
Copy link
Copy Markdown

greptile-apps bot commented Mar 20, 2026

Last reviewed commit: "atomics"

@greptile-apps
Copy link
Copy Markdown

greptile-apps bot commented Mar 20, 2026

Last reviewed commit: "apply suggesion of g..."

@greptile-apps
Copy link
Copy Markdown

greptile-apps bot commented Mar 20, 2026

Last reviewed commit: "refactor: improve re..."

@greptile-apps
Copy link
Copy Markdown

greptile-apps bot commented Mar 20, 2026

Last reviewed commit: "refactor: remove add..."

Comment thread src/storage/index_hnsw/hnsw_algo.hpp Outdated
@greptile-apps
Copy link
Copy Markdown

greptile-apps bot commented Mar 20, 2026

Last reviewed commit: "Apply suggestion fro..."

@greptile-apps
Copy link
Copy Markdown

greptile-apps bot commented Mar 20, 2026

Last reviewed commit: "Merge remote-trackin..."

@hgryoo hgryoo merged commit c41743c into CUBRID:cubvec/cubvec Mar 21, 2026
8 of 9 checks passed
@github-actions
Copy link
Copy Markdown

TC Branch Finalized for cubrid-testcases

Engine PR was merged.

Cleanup Results:

TC develop branch is ready for the next PR.

@github-actions
Copy link
Copy Markdown

TC Branch Finalized for cubrid-testcases-private-ex

Engine PR was merged.

Cleanup Results:

TC develop branch is ready for the next PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants