Skip to content

Commit e06a423

Browse files
author
Qi Chen
committed
add more log and change Multiget to use buffer
1 parent c6e0dfc commit e06a423

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

AnnService/inc/Core/SPANN/ExtraDynamicSearcher.h

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1267,8 +1267,6 @@ namespace SPTAG::SPANN {
12671267
std::vector<SizeType> HeadPrevTopK;
12681268
newHeadsDist.clear();
12691269
newHeadsDist.resize(0);
1270-
postingLists.clear();
1271-
postingLists.resize(0);
12721270
COMMON::QueryResultSet<ValueType> nearbyHeads(headVector, m_opt->m_reassignK);
12731271
p_index->SearchIndex(nearbyHeads);
12741272
BasicResult* queryResults = nearbyHeads.GetResults();
@@ -1284,7 +1282,10 @@ namespace SPTAG::SPANN {
12841282
}
12851283
auto reassignScanIOBegin = std::chrono::high_resolution_clock::now();
12861284
ErrorCode ret;
1287-
if ((ret=db->MultiGet(HeadPrevTopK, &postingLists, m_hardLatencyLimit, &(p_exWorkSpace->m_diskRequests))) != ErrorCode::Success || !ValidatePostings(HeadPrevTopK, postingLists)) {
1285+
if ((ret = db->MultiGet(HeadPrevTopK, p_exWorkSpace->m_pageBuffers, m_hardLatencyLimit,
1286+
&(p_exWorkSpace->m_diskRequests))) != ErrorCode::Success ||
1287+
!ValidatePostings(HeadPrevTopK, p_exWorkSpace->m_pageBuffers))
1288+
{
12881289
SPTAGLIB_LOG(Helper::LogLevel::LL_Error, "ReAssign can't get all the near postings\n");
12891290
return ret;
12901291
}
@@ -1293,15 +1294,16 @@ namespace SPTAG::SPANN {
12931294
auto elapsedMSeconds = std::chrono::duration_cast<std::chrono::microseconds>(reassignScanIOEnd - reassignScanIOBegin).count();
12941295
m_stat.m_reassignScanIOCost += elapsedMSeconds;
12951296

1296-
for (int i = 0; i < postingLists.size(); i++) {
1297-
auto& postingList = postingLists[i];
1298-
size_t postVectorNum = postingList.size() / m_vectorInfoSize;
1299-
auto* postingP = reinterpret_cast<uint8_t*>(postingList.data());
1297+
for (int i = 0; i < HeadPrevTopK.size(); i++)
1298+
{
1299+
auto &buffer = (p_exWorkSpace->m_pageBuffers[i]);
1300+
size_t postVectorNum = (int)(buffer.GetAvailableSize() / m_vectorInfoSize);
1301+
auto *postingP = buffer.GetBuffer();
13001302
for (int j = 0; j < postVectorNum; j++) {
13011303
uint8_t* vectorId = postingP + j * m_vectorInfoSize;
13021304
SizeType vid = *(reinterpret_cast<SizeType*>(vectorId));
13031305
// SPTAGLIB_LOG(Helper::LogLevel::LL_Info, "%d: VID: %d, Head: %d, size:%d/%d\n", i, vid, HeadPrevTopK[i], postingLists.size(), HeadPrevTopK.size());
1304-
uint8_t version = *(reinterpret_cast<uint8_t*>(vectorId + sizeof(int)));
1306+
uint8_t version = *(reinterpret_cast<uint8_t*>(vectorId + sizeof(SizeType)));
13051307
ValueType* vector = reinterpret_cast<ValueType*>(vectorId + m_metaDataSize);
13061308
if (reAssignVectorsTopK.find(vid) == reAssignVectorsTopK.end() && !m_versionMap->Deleted(vid) && m_versionMap->GetVersion(vid) == version) {
13071309
m_stat.m_reAssignScanNum++;

AnnService/inc/Helper/ThreadPool.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,11 @@ namespace SPTAG
104104

105105
inline uint32_t runningJobs() { return currentJobs; }
106106

107-
inline bool allClear() { return currentJobs == 0 && jobsize() == 0; }
107+
inline bool allClear() {
108+
SPTAGLIB_LOG(Helper::LogLevel::LL_Info, "currentJobs: %u, jobsize: %zu\n", currentJobs.load(),
109+
jobsize());
110+
return currentJobs == 0 && jobsize() == 0;
111+
}
108112

109113
protected:
110114
std::atomic_uint32_t currentJobs{ 0 };

0 commit comments

Comments
 (0)