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

Commit418451b

Browse files
committed
bufmgr: Make it easier to change number of buffer state bits
In an upcoming commit I'd like to change the number of bits for the usagecount (the current max is 5, fitting in three bits, but we reserve fourbits). Until now that required adjusting a bunch of magic constants, now theconstants are defined based on the number of bits reserved.Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>Discussion:https://postgr.es/m/lxzj26ga6ippdeunz6kuncectr5gfuugmm2ry22qu6hcx6oid6@lzx3sjsqhmt6Discussion:https://postgr.es/m/riivolmg6uzfvpzfn6wjo3ghwt42rcec43ok6mv4oenfg654y7@x7dbposbskwd
1 parentcd3ccf8 commit418451b

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

‎src/include/storage/buf_internals.h

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,19 @@
3939
*
4040
* The definition of buffer state components is below.
4141
*/
42+
#defineBUF_REFCOUNT_BITS 18
43+
#defineBUF_USAGECOUNT_BITS 4
44+
#defineBUF_FLAG_BITS 10
45+
46+
StaticAssertDecl(BUF_REFCOUNT_BITS+BUF_USAGECOUNT_BITS+BUF_FLAG_BITS==32,
47+
"parts of buffer state space need to equal 32");
48+
4249
#defineBUF_REFCOUNT_ONE 1
43-
#defineBUF_REFCOUNT_MASK ((1U <<18) - 1)
44-
#defineBUF_USAGECOUNT_MASK0x003C0000U
45-
#defineBUF_USAGECOUNT_ONE (1U <<18)
46-
#defineBUF_USAGECOUNT_SHIFT18
47-
#defineBUF_FLAG_MASK0xFFC00000U
50+
#defineBUF_REFCOUNT_MASK ((1U <<BUF_REFCOUNT_BITS) - 1)
51+
#defineBUF_USAGECOUNT_MASK(((1U << BUF_USAGECOUNT_BITS) - 1) << (BUF_REFCOUNT_BITS))
52+
#defineBUF_USAGECOUNT_ONE (1U <<BUF_REFCOUNT_BITS)
53+
#defineBUF_USAGECOUNT_SHIFTBUF_REFCOUNT_BITS
54+
#defineBUF_FLAG_MASK(((1U << BUF_FLAG_BITS) - 1) << (BUF_REFCOUNT_BITS + BUF_USAGECOUNT_BITS))
4855

4956
/* Get refcount and usagecount from buffer state */
5057
#defineBUF_STATE_GET_REFCOUNT(state) ((state) & BUF_REFCOUNT_MASK)
@@ -77,6 +84,9 @@
7784
*/
7885
#defineBM_MAX_USAGE_COUNT5
7986

87+
StaticAssertDecl(BM_MAX_USAGE_COUNT< (1 <<BUF_USAGECOUNT_BITS),
88+
"BM_MAX_USAGE_COUNT doesn't fit in BUF_USAGECOUNT_BITS bits");
89+
8090
/*
8191
* Buffer tag identifies which disk block the buffer contains.
8292
*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp