Skip to content

Commit 70868c0

Browse files
committed
Increase the initial size of StringInfo buffers to 1024 bytes (from 256);
likewise increase the initial size of the scanner's literal buffer to 1024 (from 128). Instrumentation of the regression tests suggests that this saves a useful amount of repalloc() traffic --- the number of calls occurring during one set of tests drops from about 6900 to about 3900. The old sizes were chosen in the late 90's with an eye to machines much smaller than are common today.
1 parent ae65ca3 commit 70868c0

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/backend/lib/stringinfo.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
1010
* Portions Copyright (c) 1994, Regents of the University of California
1111
*
12-
* $PostgreSQL: pgsql/src/backend/lib/stringinfo.c,v 1.46 2007/05/28 16:43:24 tgl Exp $
12+
* $PostgreSQL: pgsql/src/backend/lib/stringinfo.c,v 1.47 2007/08/12 20:18:06 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -45,7 +45,7 @@ makeStringInfo(void)
4545
void
4646
initStringInfo(StringInfo str)
4747
{
48-
int size = 256; /* initial default buffer size */
48+
int size = 1024; /* initial default buffer size */
4949

5050
str->data = (char *) palloc(size);
5151
str->maxlen = size;

src/backend/parser/scan.l

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
* Portions Copyright (c) 1994, Regents of the University of California
2525
*
2626
* IDENTIFICATION
27-
* $PostgreSQL: pgsql/src/backend/parser/scan.l,v 1.139 2007/01/05 22:19:34 momjian Exp $
27+
* $PostgreSQL: pgsql/src/backend/parser/scan.l,v 1.140 2007/08/12 20:18:06 tgl Exp $
2828
*
2929
*-------------------------------------------------------------------------
3030
*/
@@ -820,7 +820,7 @@ scanner_init(const char *str)
820820
scanbufhandle = yy_scan_buffer(scanbuf, slen + 2);
821821

822822
/* initialize literal buffer to a reasonable but expansible size */
823-
literalalloc = 128;
823+
literalalloc = 1024;
824824
literalbuf = (char *) palloc(literalalloc);
825825
startlit();
826826

0 commit comments

Comments
 (0)