Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
0fb3152e
Commit
0fb3152e
authored
Sep 29, 2004
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor adjustments to improve the accuracy of our computation of required
shared memory size.
parent
1bb38bb4
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
44 additions
and
22 deletions
+44
-22
src/backend/storage/freespace/freespace.c
src/backend/storage/freespace/freespace.c
+2
-2
src/backend/storage/ipc/ipci.c
src/backend/storage/ipc/ipci.c
+2
-1
src/backend/storage/lmgr/lock.c
src/backend/storage/lmgr/lock.c
+9
-4
src/backend/storage/lmgr/proc.c
src/backend/storage/lmgr/proc.c
+29
-14
src/include/storage/proc.h
src/include/storage/proc.h
+2
-1
No files found.
src/backend/storage/freespace/freespace.c
View file @
0fb3152e
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/storage/freespace/freespace.c,v 1.3
5 2004/09/28 20:46:27
tgl Exp $
* $PostgreSQL: pgsql/src/backend/storage/freespace/freespace.c,v 1.3
6 2004/09/29 15:15:54
tgl Exp $
*
*
*
*
* NOTES:
* NOTES:
...
@@ -330,7 +330,7 @@ FreeSpaceShmemSize(void)
...
@@ -330,7 +330,7 @@ FreeSpaceShmemSize(void)
size
=
MAXALIGN
(
sizeof
(
FSMHeader
));
size
=
MAXALIGN
(
sizeof
(
FSMHeader
));
/* hash table, including the FSMRelation objects */
/* hash table, including the FSMRelation objects */
size
+=
hash_estimate_size
(
MaxFSMRelations
,
sizeof
(
FSMRelation
));
size
+=
hash_estimate_size
(
MaxFSMRelations
+
1
,
sizeof
(
FSMRelation
));
/* page-storage arena */
/* page-storage arena */
nchunks
=
(
MaxFSMPages
-
1
)
/
CHUNKPAGES
+
1
;
nchunks
=
(
MaxFSMPages
-
1
)
/
CHUNKPAGES
+
1
;
...
...
src/backend/storage/ipc/ipci.c
View file @
0fb3152e
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/storage/ipc/ipci.c,v 1.7
1 2004/08/29 05:06:48 momjian
Exp $
* $PostgreSQL: pgsql/src/backend/storage/ipc/ipci.c,v 1.7
2 2004/09/29 15:15:55 tgl
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -69,6 +69,7 @@ CreateSharedMemoryAndSemaphores(bool makePrivate,
...
@@ -69,6 +69,7 @@ CreateSharedMemoryAndSemaphores(bool makePrivate,
size
=
hash_estimate_size
(
SHMEM_INDEX_SIZE
,
sizeof
(
ShmemIndexEnt
));
size
=
hash_estimate_size
(
SHMEM_INDEX_SIZE
,
sizeof
(
ShmemIndexEnt
));
size
+=
BufferShmemSize
();
size
+=
BufferShmemSize
();
size
+=
LockShmemSize
(
maxBackends
);
size
+=
LockShmemSize
(
maxBackends
);
size
+=
ProcGlobalShmemSize
(
maxBackends
);
size
+=
XLOGShmemSize
();
size
+=
XLOGShmemSize
();
size
+=
CLOGShmemSize
();
size
+=
CLOGShmemSize
();
size
+=
SUBTRANSShmemSize
();
size
+=
SUBTRANSShmemSize
();
...
...
src/backend/storage/lmgr/lock.c
View file @
0fb3152e
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/storage/lmgr/lock.c,v 1.14
1 2004/09/28 20:46:32
tgl Exp $
* $PostgreSQL: pgsql/src/backend/storage/lmgr/lock.c,v 1.14
2 2004/09/29 15:15:55
tgl Exp $
*
*
* NOTES
* NOTES
* Outside modules can create a lock table and acquire/release
* Outside modules can create a lock table and acquire/release
...
@@ -1689,15 +1689,17 @@ LockReassignCurrentOwner(void)
...
@@ -1689,15 +1689,17 @@ LockReassignCurrentOwner(void)
}
}
/*
* Estimate shared-memory space used for lock tables
*/
int
int
LockShmemSize
(
int
maxBackends
)
LockShmemSize
(
int
maxBackends
)
{
{
int
size
=
0
;
int
size
=
0
;
long
max_table_size
=
NLOCKENTS
(
maxBackends
);
long
max_table_size
=
NLOCKENTS
(
maxBackends
);
size
+=
MAXALIGN
(
sizeof
(
PROC_HDR
));
/* ProcGlobal */
/* lock method headers */
size
+=
maxBackends
*
MAXALIGN
(
sizeof
(
PGPROC
));
/* each MyProc */
size
+=
MAX_LOCK_METHODS
*
MAXALIGN
(
sizeof
(
LockMethodData
));
size
+=
MAX_LOCK_METHODS
*
MAXALIGN
(
sizeof
(
LockMethodData
));
/* each lock method */
/* lockHash table */
/* lockHash table */
size
+=
hash_estimate_size
(
max_table_size
,
sizeof
(
LOCK
));
size
+=
hash_estimate_size
(
max_table_size
,
sizeof
(
LOCK
));
...
@@ -1706,6 +1708,9 @@ LockShmemSize(int maxBackends)
...
@@ -1706,6 +1708,9 @@ LockShmemSize(int maxBackends)
size
+=
hash_estimate_size
(
max_table_size
,
sizeof
(
PROCLOCK
));
size
+=
hash_estimate_size
(
max_table_size
,
sizeof
(
PROCLOCK
));
/*
/*
* Note we count only one pair of hash tables, since the userlocks
* table actually overlays the main one.
*
* Since the lockHash entry count above is only an estimate, add 10%
* Since the lockHash entry count above is only an estimate, add 10%
* safety margin.
* safety margin.
*/
*/
...
...
src/backend/storage/lmgr/proc.c
View file @
0fb3152e
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/storage/lmgr/proc.c,v 1.15
3 2004/08/29 05:06:48 momjian
Exp $
* $PostgreSQL: pgsql/src/backend/storage/lmgr/proc.c,v 1.15
4 2004/09/29 15:15:55 tgl
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -89,6 +89,22 @@ static void DummyProcKill(int code, Datum arg);
...
@@ -89,6 +89,22 @@ static void DummyProcKill(int code, Datum arg);
static
bool
CheckStatementTimeout
(
void
);
static
bool
CheckStatementTimeout
(
void
);
/*
* Report shared-memory space needed by InitProcGlobal.
*/
int
ProcGlobalShmemSize
(
int
maxBackends
)
{
int
size
=
0
;
size
+=
MAXALIGN
(
sizeof
(
PROC_HDR
));
/* ProcGlobal */
size
+=
MAXALIGN
(
NUM_DUMMY_PROCS
*
sizeof
(
PGPROC
));
/* DummyProcs */
size
+=
MAXALIGN
(
maxBackends
*
sizeof
(
PGPROC
));
/* MyProcs */
size
+=
MAXALIGN
(
sizeof
(
slock_t
));
/* ProcStructLock */
return
size
;
}
/*
/*
* Report number of semaphores needed by InitProcGlobal.
* Report number of semaphores needed by InitProcGlobal.
*/
*/
...
@@ -134,7 +150,7 @@ InitProcGlobal(int maxBackends)
...
@@ -134,7 +150,7 @@ InitProcGlobal(int maxBackends)
* processes, too. These do not get linked into the freeProcs list.
* processes, too. These do not get linked into the freeProcs list.
*/
*/
DummyProcs
=
(
PGPROC
*
)
DummyProcs
=
(
PGPROC
*
)
ShmemInitStruct
(
"DummyProcs"
,
sizeof
(
PGPROC
)
*
NUM_DUMMY_PROCS
,
ShmemInitStruct
(
"DummyProcs"
,
NUM_DUMMY_PROCS
*
sizeof
(
PGPROC
)
,
&
foundDummy
);
&
foundDummy
);
if
(
foundProcGlobal
||
foundDummy
)
if
(
foundProcGlobal
||
foundDummy
)
...
@@ -147,6 +163,7 @@ InitProcGlobal(int maxBackends)
...
@@ -147,6 +163,7 @@ InitProcGlobal(int maxBackends)
/*
/*
* We're the first - initialize.
* We're the first - initialize.
*/
*/
PGPROC
*
procs
;
int
i
;
int
i
;
ProcGlobal
->
freeProcs
=
INVALID_OFFSET
;
ProcGlobal
->
freeProcs
=
INVALID_OFFSET
;
...
@@ -155,22 +172,20 @@ InitProcGlobal(int maxBackends)
...
@@ -155,22 +172,20 @@ InitProcGlobal(int maxBackends)
* Pre-create the PGPROC structures and create a semaphore for
* Pre-create the PGPROC structures and create a semaphore for
* each.
* each.
*/
*/
procs
=
(
PGPROC
*
)
ShmemAlloc
(
maxBackends
*
sizeof
(
PGPROC
));
if
(
!
procs
)
ereport
(
FATAL
,
(
errcode
(
ERRCODE_OUT_OF_MEMORY
),
errmsg
(
"out of shared memory"
)));
MemSet
(
procs
,
0
,
maxBackends
*
sizeof
(
PGPROC
));
for
(
i
=
0
;
i
<
maxBackends
;
i
++
)
for
(
i
=
0
;
i
<
maxBackends
;
i
++
)
{
{
PGPROC
*
proc
;
PGSemaphoreCreate
(
&
(
procs
[
i
].
sem
));
procs
[
i
].
links
.
next
=
ProcGlobal
->
freeProcs
;
proc
=
(
PGPROC
*
)
ShmemAlloc
(
sizeof
(
PGPROC
));
ProcGlobal
->
freeProcs
=
MAKE_OFFSET
(
&
procs
[
i
]);
if
(
!
proc
)
ereport
(
FATAL
,
(
errcode
(
ERRCODE_OUT_OF_MEMORY
),
errmsg
(
"out of shared memory"
)));
MemSet
(
proc
,
0
,
sizeof
(
PGPROC
));
PGSemaphoreCreate
(
&
proc
->
sem
);
proc
->
links
.
next
=
ProcGlobal
->
freeProcs
;
ProcGlobal
->
freeProcs
=
MAKE_OFFSET
(
proc
);
}
}
MemSet
(
DummyProcs
,
0
,
sizeof
(
PGPROC
)
*
NUM_DUMMY_PROCS
);
MemSet
(
DummyProcs
,
0
,
NUM_DUMMY_PROCS
*
sizeof
(
PGPROC
)
);
for
(
i
=
0
;
i
<
NUM_DUMMY_PROCS
;
i
++
)
for
(
i
=
0
;
i
<
NUM_DUMMY_PROCS
;
i
++
)
{
{
DummyProcs
[
i
].
pid
=
0
;
/* marks dummy proc as not in use */
DummyProcs
[
i
].
pid
=
0
;
/* marks dummy proc as not in use */
...
...
src/include/storage/proc.h
View file @
0fb3152e
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
* Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* $PostgreSQL: pgsql/src/include/storage/proc.h,v 1.7
5 2004/08/29 05:06:58 momjian
Exp $
* $PostgreSQL: pgsql/src/include/storage/proc.h,v 1.7
6 2004/09/29 15:15:56 tgl
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -122,6 +122,7 @@ extern int StatementTimeout;
...
@@ -122,6 +122,7 @@ extern int StatementTimeout;
* Function Prototypes
* Function Prototypes
*/
*/
extern
int
ProcGlobalSemas
(
int
maxBackends
);
extern
int
ProcGlobalSemas
(
int
maxBackends
);
extern
int
ProcGlobalShmemSize
(
int
maxBackends
);
extern
void
InitProcGlobal
(
int
maxBackends
);
extern
void
InitProcGlobal
(
int
maxBackends
);
extern
void
InitProcess
(
void
);
extern
void
InitProcess
(
void
);
extern
void
InitDummyProcess
(
int
proctype
);
extern
void
InitDummyProcess
(
int
proctype
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment