Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit641a9b7

Browse files
committed
Avoid using large pass-by-value struct arguments in pgbench.
In the wake of commit4a39f87, which noticeably increased thesize of struct StatsData and thereby ParsedScript, Coverity startedto complain that ParsedScript was unreasonably large to be passingby value. The two places that do this are only used during setup,so they're not really dragging down benchmark measurements --- butgratuitous inefficiency is not a good look in a benchmarking program.Convert to use pointers instead.
1 parent0fb6954 commit641a9b7

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

‎src/bin/pgbench/pgbench.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,7 @@ static void doLog(TState *thread, CState *st,
832832
StatsData*agg,boolskipped,doublelatency,doublelag);
833833
staticvoidprocessXactStats(TState*thread,CState*st,pg_time_usec_t*now,
834834
boolskipped,StatsData*agg);
835-
staticvoidaddScript(ParsedScriptscript);
835+
staticvoidaddScript(constParsedScript*script);
836836
staticTHREAD_FUNC_RETURN_TYPETHREAD_FUNC_CCthreadRun(void*arg);
837837
staticvoidfinishCon(CState*st);
838838
staticvoidsetalarm(intseconds);
@@ -5743,15 +5743,15 @@ ConditionError(const char *desc, int cmdn, const char *msg)
57435743
* Partial evaluation of conditionals before recording and running the script.
57445744
*/
57455745
staticvoid
5746-
CheckConditional(ParsedScriptps)
5746+
CheckConditional(constParsedScript*ps)
57475747
{
57485748
/* statically check conditional structure */
57495749
ConditionalStackcs=conditional_stack_create();
57505750
inti;
57515751

5752-
for (i=0;ps.commands[i]!=NULL;i++)
5752+
for (i=0;ps->commands[i]!=NULL;i++)
57535753
{
5754-
Command*cmd=ps.commands[i];
5754+
Command*cmd=ps->commands[i];
57555755

57565756
if (cmd->type==META_COMMAND)
57575757
{
@@ -5762,20 +5762,20 @@ CheckConditional(ParsedScript ps)
57625762
break;
57635763
caseMETA_ELIF:
57645764
if (conditional_stack_empty(cs))
5765-
ConditionError(ps.desc,i+1,"\\elif without matching \\if");
5765+
ConditionError(ps->desc,i+1,"\\elif without matching \\if");
57665766
if (conditional_stack_peek(cs)==IFSTATE_ELSE_FALSE)
5767-
ConditionError(ps.desc,i+1,"\\elif after \\else");
5767+
ConditionError(ps->desc,i+1,"\\elif after \\else");
57685768
break;
57695769
caseMETA_ELSE:
57705770
if (conditional_stack_empty(cs))
5771-
ConditionError(ps.desc,i+1,"\\else without matching \\if");
5771+
ConditionError(ps->desc,i+1,"\\else without matching \\if");
57725772
if (conditional_stack_peek(cs)==IFSTATE_ELSE_FALSE)
5773-
ConditionError(ps.desc,i+1,"\\else after \\else");
5773+
ConditionError(ps->desc,i+1,"\\else after \\else");
57745774
conditional_stack_poke(cs,IFSTATE_ELSE_FALSE);
57755775
break;
57765776
caseMETA_ENDIF:
57775777
if (!conditional_stack_pop(cs))
5778-
ConditionError(ps.desc,i+1,"\\endif without matching \\if");
5778+
ConditionError(ps->desc,i+1,"\\endif without matching \\if");
57795779
break;
57805780
default:
57815781
/* ignore anything else... */
@@ -5784,7 +5784,7 @@ CheckConditional(ParsedScript ps)
57845784
}
57855785
}
57865786
if (!conditional_stack_empty(cs))
5787-
ConditionError(ps.desc,i+1,"\\if without matching \\endif");
5787+
ConditionError(ps->desc,i+1,"\\if without matching \\endif");
57885788
conditional_stack_destroy(cs);
57895789
}
57905790

@@ -5916,7 +5916,7 @@ ParseScript(const char *script, const char *desc, int weight)
59165916

59175917
ps.commands[index]=NULL;
59185918

5919-
addScript(ps);
5919+
addScript(&ps);
59205920

59215921
termPQExpBuffer(&line_buf);
59225922
psql_scan_finish(sstate);
@@ -6093,11 +6093,11 @@ parseScriptWeight(const char *option, char **script)
60936093

60946094
/* append a script to the list of scripts to process */
60956095
staticvoid
6096-
addScript(ParsedScriptscript)
6096+
addScript(constParsedScript*script)
60976097
{
6098-
if (script.commands==NULL||script.commands[0]==NULL)
6098+
if (script->commands==NULL||script->commands[0]==NULL)
60996099
{
6100-
pg_log_fatal("empty command list for script \"%s\"",script.desc);
6100+
pg_log_fatal("empty command list for script \"%s\"",script->desc);
61016101
exit(1);
61026102
}
61036103

@@ -6109,7 +6109,7 @@ addScript(ParsedScript script)
61096109

61106110
CheckConditional(script);
61116111

6112-
sql_script[num_scripts]=script;
6112+
sql_script[num_scripts]=*script;
61136113
num_scripts++;
61146114
}
61156115

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp