未验证 提交 e580dab8 编写于 作者: X xiong-gang 提交者: GitHub

Change the size of interconnect connection hash table

As discussed in #6932, the size of interconnect connection hash table is 16,
which would be too small for large cluster and could bring too many hash table
collisions. Set to (2 * number segments).
上级 c9655e2d
......@@ -60,6 +60,12 @@ int qe_identifier = 0;
*/
int host_segments = 0;
/*
* size of hash table of interconnect connections
* equals to 2 * (the number of total segments)
*/
int ic_htab_size = 0;
Gang *CurrentGangCreating = NULL;
CreateGangFunc pCreateGangFunc = cdbgang_createGang_async;
......@@ -357,7 +363,7 @@ makeOptions(void)
*/
bool
build_gpqeid_param(char *buf, int bufsz,
bool is_writer, int identifier, int hostSegs)
bool is_writer, int identifier, int hostSegs, int icHtabSize)
{
int len;
#ifdef HAVE_INT64_TIMESTAMP
......@@ -370,9 +376,9 @@ build_gpqeid_param(char *buf, int bufsz,
#endif
#endif
len = snprintf(buf, bufsz, "%d;" TIMESTAMP_FORMAT ";%s;%d;%d",
len = snprintf(buf, bufsz, "%d;" TIMESTAMP_FORMAT ";%s;%d;%d;%d",
gp_session_id, PgStartTime,
(is_writer ? "true" : "false"), identifier, hostSegs);
(is_writer ? "true" : "false"), identifier, hostSegs, icHtabSize);
return (len > 0 && len < bufsz);
}
......@@ -444,11 +450,16 @@ cdbgang_parse_gpqeid_params(struct Port *port __attribute__((unused)),
host_segments = (int) strtol(cp, NULL, 10);
}
if (gpqeid_next_param(&cp, &np))
{
ic_htab_size = (int) strtol(cp, NULL, 10);
}
/* Too few items, or too many? */
if (!cp || np)
goto bad;
if (gp_session_id <= 0 || PgStartTime <= 0 || qe_identifier < 0 || host_segments <= 0)
if (gp_session_id <= 0 || PgStartTime <= 0 || qe_identifier < 0 || host_segments <= 0 || ic_htab_size <= 0)
goto bad;
pfree(gpqeid);
......
......@@ -54,6 +54,7 @@ cdbgang_createGang_async(List *segments, SegmentType segmentType)
int i = 0;
int size = 0;
bool retry = false;
int totalSegs = 0;
/*
* true means connection status is confirmed, either established or in
......@@ -72,6 +73,8 @@ cdbgang_createGang_async(List *segments, SegmentType segmentType)
/* allocate and initialize a gang structure */
newGangDefinition = buildGangDefinition(segments, segmentType);
CurrentGangCreating = newGangDefinition;
totalSegs = getgpsegmentCount();
Assert(totalSegs > 0);
create_gang_retry:
Assert(newGangDefinition != NULL);
......@@ -120,7 +123,8 @@ create_gang_retry:
ret = build_gpqeid_param(gpqeid, sizeof(gpqeid),
segdbDesc->isWriter,
segdbDesc->identifier,
segdbDesc->segment_database_info->hostSegs);
segdbDesc->segment_database_info->hostSegs,
totalSegs * 2);
if (!ret)
ereport(ERROR,
......
......@@ -177,7 +177,6 @@ struct ConnHashTable
int size;
};
#define DEFAULT_CONN_HTAB_SIZE 16
#define CONN_HASH_VALUE(icpkt) ((uint32)((((icpkt)->srcPid ^ (icpkt)->dstPid)) + (icpkt)->dstContentId))
#define CONN_HASH_MATCH(a, b) (((a)->motNodeId == (b)->motNodeId && \
(a)->dstContentId == (b)->dstContentId && \
......@@ -1511,7 +1510,8 @@ initConnHashTable(ConnHashTable *ht, MemoryContext cxt)
int i;
ht->cxt = cxt;
ht->size = DEFAULT_CONN_HTAB_SIZE;
ht->size = Gp_role == GP_ROLE_DISPATCH ? (getgpsegmentCount() * 2) : ic_htab_size;
Assert(ht->size > 0);
if (ht->cxt)
{
......
......@@ -53,6 +53,7 @@ typedef struct Gang
extern int qe_identifier;
extern int host_segments;
extern int ic_htab_size;
extern MemoryContext GangContext;
extern Gang *CurrentGangCreating;
......@@ -86,7 +87,7 @@ extern void CheckForResetSession(void);
extern struct SegmentDatabaseDescriptor *getSegmentDescriptorFromGang(const Gang *gp, int seg);
Gang *buildGangDefinition(List *segments, SegmentType segmentType);
bool build_gpqeid_param(char *buf, int bufsz, bool is_writer, int identifier, int hostSegs);
bool build_gpqeid_param(char *buf, int bufsz, bool is_writer, int identifier, int hostSegs, int icHtabSize);
char *makeOptions(void);
extern bool segment_failure_due_to_recovery(const char *error_message);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册