增加hierarachy中为每个线程分配expr_buff,以修复使用用户设置的缓冲区大小,导致不命中的bug。

This commit is contained in:
zhengchao
2021-04-01 14:37:31 +08:00
parent e3b3288dc1
commit 0f6eccbb47
4 changed files with 18 additions and 14 deletions

View File

@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.5)
set(MAAT_FRAME_MAJOR_VERSION 3) set(MAAT_FRAME_MAJOR_VERSION 3)
set(MAAT_FRAME_MINOR_VERSION 1) set(MAAT_FRAME_MINOR_VERSION 1)
set(MAAT_FRAME_PATCH_VERSION 4) set(MAAT_FRAME_PATCH_VERSION 17)
set(MAAT_FRAME_VERSION ${MAAT_FRAME_MAJOR_VERSION}.${MAAT_FRAME_MINOR_VERSION}.${MAAT_FRAME_PATCH_VERSION}) set(MAAT_FRAME_VERSION ${MAAT_FRAME_MAJOR_VERSION}.${MAAT_FRAME_MINOR_VERSION}.${MAAT_FRAME_PATCH_VERSION})
message(STATUS "Maat Frame, Version: ${MAAT_FRAME_VERSION}") message(STATUS "Maat Frame, Version: ${MAAT_FRAME_VERSION}")

View File

@@ -110,6 +110,7 @@ struct Maat_hierarchy
int thread_num; int thread_num;
struct Maat_garbage_bin* garbage_bin; struct Maat_garbage_bin* garbage_bin;
void* logger; void* logger;
struct bool_expr_match *expr_match_buff;
}; };
int compare_literal_id(const void *pa, const void *pb) int compare_literal_id(const void *pa, const void *pb)
@@ -296,6 +297,7 @@ struct Maat_hierarchy* Maat_hierarchy_new(int thread_num, void* mesa_handle_logg
hier->hash_literal_by_id=NULL; hier->hash_literal_by_id=NULL;
hier->hash_region_by_id=NULL; hier->hash_region_by_id=NULL;
hier->expr_match_buff=ALLOC(struct bool_expr_match, thread_num*MAX_SCANNER_HIT_NUM);
ret=igraph_empty(&hier->group_graph, 0, IGRAPH_DIRECTED); ret=igraph_empty(&hier->group_graph, 0, IGRAPH_DIRECTED);
assert(ret==IGRAPH_SUCCESS); assert(ret==IGRAPH_SUCCESS);
@@ -345,6 +347,8 @@ void Maat_hierarchy_free(struct Maat_hierarchy* hier)
bool_matcher_free(hier->bm); bool_matcher_free(hier->bm);
hier->bm=NULL; hier->bm=NULL;
pthread_rwlock_unlock(&hier->rwlock); pthread_rwlock_unlock(&hier->rwlock);
free(hier->expr_match_buff);
hier->expr_match_buff=NULL;
free(hier); free(hier);
} }
@@ -1338,8 +1342,8 @@ int Maat_hierarchy_region_compile(struct Maat_hierarchy_compile_mid* mid, int is
{ {
int bool_match_ret=0, i=0; int bool_match_ret=0, i=0;
struct Maat_hierarchy* hier=mid->ref_hier; struct Maat_hierarchy* hier=mid->ref_hier;
struct Maat_hierarchy_compile* compile_array[ud_array_sz]; struct Maat_hierarchy_compile* compile_array=NULL;
struct bool_expr_match expr_match[ud_array_sz]; struct bool_expr_match *expr_match=hier->expr_match_buff+mid->thread_num*MAX_SCANNER_HIT_NUM;
size_t r_in_c_cnt=0, this_scan_region_hits=mid->this_scan_region_hit_cnt; size_t r_in_c_cnt=0, this_scan_region_hits=mid->this_scan_region_hit_cnt;
size_t ud_result_cnt=0; size_t ud_result_cnt=0;
@@ -1351,22 +1355,22 @@ int Maat_hierarchy_region_compile(struct Maat_hierarchy_compile_mid* mid, int is
pthread_rwlock_rdlock(&hier->rwlock); pthread_rwlock_rdlock(&hier->rwlock);
bool_match_ret=bool_matcher_match(hier->bm, mid->thread_num, bool_match_ret=bool_matcher_match(hier->bm, mid->thread_num,
(unsigned long long*)utarray_eltptr(mid->_all_hit_clause_array, 0), utarray_len(mid->_all_hit_clause_array), (unsigned long long*)utarray_eltptr(mid->_all_hit_clause_array, 0), utarray_len(mid->_all_hit_clause_array),
expr_match, ud_array_sz); expr_match, MAX_SCANNER_HIT_NUM);
for(i=0; i<bool_match_ret; i++) for(i=0; i<bool_match_ret && ud_result_cnt<ud_array_sz; i++)
{ {
compile_array[i]=(struct Maat_hierarchy_compile*)expr_match[i].user_tag; compile_array=(struct Maat_hierarchy_compile*)expr_match[i].user_tag;
assert((unsigned long long)compile_array[i]->compile_id==expr_match[i].expr_id); assert((unsigned long long)compile_array->compile_id==expr_match[i].expr_id);
r_in_c_cnt=Maat_hierarchy_compile_mid_update_by_compile(mid, compile_array[i]); r_in_c_cnt=Maat_hierarchy_compile_mid_update_by_compile(mid, compile_array);
if(compile_array[i]->not_clause_cnt>0 && !is_last_compile) if(compile_array->not_clause_cnt>0 && !is_last_compile)
{ {
mid->not_clause_hitted_flag=1; mid->not_clause_hitted_flag=1;
} }
else if(compile_array[i]->user_data)//For compile may be dettached by Maat_hierarchy_compile_dettach_user_data, only return non-NULL userdata. else if(compile_array->user_data)//For compile may be dettached by Maat_hierarchy_compile_dettach_user_data, only return non-NULL userdata.
{ {
if(r_in_c_cnt>0 || //compile hitted becasue of new reigon if(r_in_c_cnt>0 || //compile hitted becasue of new reigon
this_scan_region_hits==0) //or hit a compile that refer a NOT-logic group in previous scan. this_scan_region_hits==0) //or hit a compile that refer a NOT-logic group in previous scan.
{ {
user_data_array[ud_result_cnt]=compile_array[i]->user_data; user_data_array[ud_result_cnt]=compile_array->user_data;
ud_result_cnt++; ud_result_cnt++;
} }
} }

View File

@@ -57,7 +57,7 @@ extern "C"
} }
#endif #endif
int MAAT_FRAME_VERSION_3_1_16_20210320=1; int MAAT_FRAME_VERSION_3_1_17_20210323=1;
int is_valid_table_name(const char* str) int is_valid_table_name(const char* str)
{ {

View File

@@ -194,7 +194,7 @@ int bool_matcher_match(struct bool_matcher * matcher, unsigned int thread_id, co
for(unsigned int j=matcher->mapped_ptr[h]; j<matcher->mapped_ptr[h+1]; j++) for(unsigned int j=matcher->mapped_ptr[h]; j<matcher->mapped_ptr[h+1]; j++)
{ {
if(ids_num==MAX_ARRAY_SIZE) return -1; if(ids_num==MAX_ARRAY_SIZE) continue;
mapped_ids[ids_num++]=matcher->mapped_ids[j]; mapped_ids[ids_num++]=matcher->mapped_ids[j];
} }
} }
@@ -203,7 +203,7 @@ int bool_matcher_match(struct bool_matcher * matcher, unsigned int thread_id, co
unsigned int used_num=0; unsigned int used_num=0;
for(unsigned int i=0; i<ids_num; i++) for(unsigned int i=0; i<ids_num; i++)
{ {
if(used_num==MAX_ARRAY_SIZE) return -1; if(used_num==MAX_ARRAY_SIZE) continue;
used_cells[used_num++]=(mapped_ids[i]>>3); used_cells[used_num++]=(mapped_ids[i]>>3);
} }