mirror of
https://gitee.com/milvus-io/milvus.git
synced 2025-12-28 22:45:26 +08:00
Enable backtrace for better debugging
Signed-off-by: FluorineDog <guilin.gou@zilliz.com>
This commit is contained in:
parent
998e750468
commit
466508332c
@ -1,5 +1,6 @@
|
||||
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/../pb PB_SRC_FILES)
|
||||
|
||||
# add_definitions(-DBOOST_STACKTRACE_USE_ADDR2LINE)
|
||||
set(DOG_SEGMENT_FILES
|
||||
SegmentNaive.cpp
|
||||
IndexMeta.cpp
|
||||
@ -9,6 +10,7 @@ set(DOG_SEGMENT_FILES
|
||||
collection_c.cpp
|
||||
partition_c.cpp
|
||||
segment_c.cpp
|
||||
EasyAssert.cpp
|
||||
${PB_SRC_FILES}
|
||||
)
|
||||
add_library(milvus_dog_segment SHARED
|
||||
@ -18,4 +20,5 @@ add_library(milvus_dog_segment SHARED
|
||||
|
||||
#add_dependencies( segment sqlite mysqlpp )
|
||||
|
||||
target_link_libraries(milvus_dog_segment tbb utils pthread knowhere log libprotobuf)
|
||||
target_link_libraries(milvus_dog_segment tbb utils pthread knowhere log libprotobuf dl backtrace
|
||||
)
|
||||
|
||||
26
core/src/dog_segment/EasyAssert.cpp
Normal file
26
core/src/dog_segment/EasyAssert.cpp
Normal file
@ -0,0 +1,26 @@
|
||||
|
||||
#include <iostream>
|
||||
#include "EasyAssert.h"
|
||||
// #define BOOST_STACKTRACE_USE_ADDR2LINE
|
||||
#define BOOST_STACKTRACE_USE_BACKTRACE
|
||||
#include <boost/stacktrace.hpp>
|
||||
|
||||
|
||||
namespace milvus::impl {
|
||||
void EasyAssertInfo(bool value, std::string_view expr_str, std::string_view filename, int lineno,
|
||||
std::string_view extra_info) {
|
||||
if (!value) {
|
||||
std::string info;
|
||||
info += "Assert \"" + std::string(expr_str) + "\"";
|
||||
info += " at " + std::string(filename) + ":" + std::to_string(lineno) + "\n";
|
||||
if(!extra_info.empty()) {
|
||||
info += " => " + std::string(extra_info);
|
||||
}
|
||||
auto fuck = boost::stacktrace::stacktrace();
|
||||
std::cout << fuck;
|
||||
// std::string s = fuck;
|
||||
// info += ;
|
||||
throw std::runtime_error(info);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,18 +1,13 @@
|
||||
#pragma once
|
||||
#include <string_view>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/* Paste this on the file you want to debug. */
|
||||
|
||||
namespace milvus::impl {
|
||||
inline
|
||||
void EasyAssertInfo(bool value, std::string_view expr_str, std::string_view filename, int lineno,
|
||||
std::string_view extra_info) {
|
||||
if (!value) {
|
||||
std::string info;
|
||||
info += "Assert \"" + std::string(expr_str) + "\"";
|
||||
info += " at " + std::string(filename) + ":" + std::to_string(lineno);
|
||||
info += " => " + std::string(extra_info);
|
||||
throw std::runtime_error(info);
|
||||
}
|
||||
}
|
||||
std::string_view extra_info);
|
||||
}
|
||||
|
||||
#define AssertInfo(expr, info) impl::EasyAssertInfo(bool(expr), #expr, __FILE__, __LINE__, (info))
|
||||
|
||||
@ -171,9 +171,7 @@ class Schema {
|
||||
const FieldMeta&
|
||||
operator[](const std::string& field_name) const {
|
||||
auto offset_iter = offsets_.find(field_name);
|
||||
if (offset_iter == offsets_.end()) {
|
||||
throw std::runtime_error("Cannot found field_name: " + field_name);
|
||||
}
|
||||
AssertInfo(offset_iter != offsets_.end(), "Cannot found field_name: " + field_name);
|
||||
auto offset = offset_iter->second;
|
||||
return (*this)[offset];
|
||||
}
|
||||
|
||||
@ -96,9 +96,6 @@ auto SegmentNaive::get_deleted_bitmap(int64_t del_barrier, Timestamp query_times
|
||||
if (offset >= insert_barrier) {
|
||||
continue;
|
||||
}
|
||||
if (offset >= insert_barrier) {
|
||||
continue;
|
||||
}
|
||||
if (record_.timestamps_[offset] < query_timestamp) {
|
||||
Assert(offset < insert_barrier);
|
||||
the_offset = std::max(the_offset, offset);
|
||||
|
||||
@ -24,6 +24,34 @@ using std::cin;
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
|
||||
namespace {
|
||||
auto
|
||||
generate_data(int N) {
|
||||
std::vector<char> raw_data;
|
||||
std::vector<uint64_t> timestamps;
|
||||
std::vector<int64_t> uids;
|
||||
std::default_random_engine er(42);
|
||||
std::normal_distribution<> distribution(0.0, 1.0);
|
||||
std::default_random_engine ei(42);
|
||||
|
||||
for (int i = 0; i < N; ++i) {
|
||||
uids.push_back(10 * N + i);
|
||||
timestamps.push_back(0);
|
||||
// append vec
|
||||
float vec[16];
|
||||
for (auto& x : vec) {
|
||||
x = distribution(er);
|
||||
}
|
||||
raw_data.insert(
|
||||
raw_data.end(), (const char*)std::begin(vec), (const char*)std::end(vec));
|
||||
int age = ei() % 100;
|
||||
raw_data.insert(
|
||||
raw_data.end(), (const char*)&age, ((const char*)&age) + sizeof(age));
|
||||
}
|
||||
return std::make_tuple(raw_data, timestamps, uids);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
|
||||
TEST(DogSegmentTest, TestABI) {
|
||||
using namespace milvus::engine;
|
||||
@ -32,6 +60,20 @@ TEST(DogSegmentTest, TestABI) {
|
||||
assert(true);
|
||||
}
|
||||
|
||||
TEST(DogSegmentTest, NormalDistributionTest) {
|
||||
using namespace milvus::dog_segment;
|
||||
using namespace milvus::engine;
|
||||
auto schema = std::make_shared<Schema>();
|
||||
schema->AddField("fakevec", DataType::VECTOR_FLOAT, 16);
|
||||
schema->AddField("age", DataType::INT32);
|
||||
int N = 1000* 1000;
|
||||
auto [raw_data, timestamps, uids] = generate_data(N);
|
||||
auto segment = CreateSegment(schema);
|
||||
segment->PreInsert(N);
|
||||
segment->PreDelete(N);
|
||||
|
||||
}
|
||||
|
||||
|
||||
TEST(DogSegmentTest, MockTest) {
|
||||
using namespace milvus::dog_segment;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user