Kouhei Sutou
null+****@clear*****
Wed Jun 29 15:45:09 JST 2016
Kouhei Sutou 2016-06-29 15:45:09 +0900 (Wed, 29 Jun 2016) New Revision: 6e1dc086021e51a541f2d7b5fdce7f525eba41c8 https://github.com/groonga/groonga/commit/6e1dc086021e51a541f2d7b5fdce7f525eba41c8 Message: experimental ii: reduce the max N chunks for tiny index column The default max N segments is 1024 (= 1 << 10). It will be changed after our checks. The value can be customized by GRN_II_MAX_N_CHUNKS_TINY environment variable. Modified files: lib/grn_ii.h lib/ii.c Modified: lib/grn_ii.h (+2 -0) =================================================================== --- lib/grn_ii.h 2016-06-29 15:30:43 +0900 (193484d) +++ lib/grn_ii.h 2016-06-29 15:45:09 +0900 (7201291) @@ -51,6 +51,8 @@ struct _grn_ii { #define GRN_II_MAX_CHUNK (1 << (GRN_II_W_TOTAL_CHUNK - GRN_II_W_CHUNK)) #define GRN_II_N_CHUNK_VARIATION (GRN_II_W_CHUNK - GRN_II_W_LEAST_CHUNK) +#define GRN_II_MAX_CHUNK_TINY (1 << (GRN_II_W_TOTAL_CHUNK - GRN_II_W_CHUNK - 8)) + struct grn_ii_header { uint64_t total_chunk_size; uint64_t bmax; Modified: lib/ii.c (+23 -2) =================================================================== --- lib/ii.c 2016-06-29 15:30:43 +0900 (2e5cfe3) +++ lib/ii.c 2016-06-29 15:45:09 +0900 (283f807) @@ -78,6 +78,7 @@ static double grn_ii_estimate_size_for_query_reduce_ratio = 0.9; static grn_bool grn_ii_overlap_token_skip_enable = GRN_FALSE; static uint32_t grn_ii_builder_block_threshold_force = 0; static uint32_t grn_ii_max_n_segments_tiny = MAX_PSEG_TINY; +static uint32_t grn_ii_max_n_chunks_tiny = GRN_II_MAX_CHUNK_TINY; void grn_ii_init_from_env(void) @@ -160,6 +161,23 @@ grn_ii_init_from_env(void) } } } + + { + char grn_ii_max_n_chunks_tiny_env[GRN_ENV_BUFFER_SIZE]; + grn_getenv("GRN_II_MAX_N_CHUNKS_TINY", + grn_ii_max_n_chunks_tiny_env, + GRN_ENV_BUFFER_SIZE); + if (grn_ii_max_n_chunks_tiny_env[0]) { + grn_ii_max_n_chunks_tiny = + grn_atoui(grn_ii_max_n_chunks_tiny_env, + grn_ii_max_n_chunks_tiny_env + + strlen(grn_ii_max_n_chunks_tiny_env), + NULL); + if (grn_ii_max_n_chunks_tiny > GRN_II_MAX_CHUNK) { + grn_ii_max_n_chunks_tiny = GRN_II_MAX_CHUNK; + } + } + } } /* segment */ @@ -3750,6 +3768,7 @@ _grn_ii_create(grn_ctx *ctx, grn_ii *ii, const char *path, grn_obj *lexicon, uin { int i; uint32_t max_n_segments; + uint32_t max_n_chunks; grn_io *seg, *chunk; char path2[PATH_MAX]; struct grn_ii_header *header; @@ -3770,8 +3789,10 @@ _grn_ii_create(grn_ctx *ctx, grn_ii *ii, const char *path, grn_obj *lexicon, uin if (flags & GRN_OBJ_INDEX_TINY) { max_n_segments = grn_ii_max_n_segments_tiny; + max_n_chunks = grn_ii_max_n_chunks_tiny; } else { max_n_segments = MAX_PSEG; + max_n_chunks = GRN_II_MAX_CHUNK; } seg = grn_io_create(ctx, @@ -3785,10 +3806,10 @@ _grn_ii_create(grn_ctx *ctx, grn_ii *ii, const char *path, grn_obj *lexicon, uin if (path) { grn_strcpy(path2, PATH_MAX, path); grn_strcat(path2, PATH_MAX, ".c"); - chunk = grn_io_create(ctx, path2, 0, S_CHUNK, GRN_II_MAX_CHUNK, grn_io_auto, + chunk = grn_io_create(ctx, path2, 0, S_CHUNK, max_n_chunks, grn_io_auto, GRN_IO_EXPIRE_SEGMENT); } else { - chunk = grn_io_create(ctx, NULL, 0, S_CHUNK, GRN_II_MAX_CHUNK, grn_io_auto, 0); + chunk = grn_io_create(ctx, NULL, 0, S_CHUNK, max_n_chunks, grn_io_auto, 0); } if (!chunk) { grn_io_close(ctx, seg); -------------- next part -------------- HTML����������������������������...Download