Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
别团等shy哥发育
redis
提交
30a26d36
R
redis
项目概览
别团等shy哥发育
/
redis
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
redis
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
30a26d36
编写于
2月 25, 2014
作者:
J
jonathan pickett
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
added --bypass-system-reserve flag for Azure team to test maximum heap allocation
上级
f5245a44
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
43 addition
and
35 deletion
+43
-35
bin/release/redis-2.8.4.zip
bin/release/redis-2.8.4.zip
+0
-0
src/Win32_Interop/Win32_QFork.cpp
src/Win32_Interop/Win32_QFork.cpp
+38
-34
src/config.c
src/config.c
+5
-1
未找到文件。
bin/release/redis-2.8.4.zip
浏览文件 @
30a26d36
无法预览此类型文件
src/Win32_Interop/Win32_QFork.cpp
浏览文件 @
30a26d36
...
...
@@ -121,13 +121,16 @@ How the parent invokes the QFork process:
const
SIZE_T
cAllocationGranularity
=
1
<<
26
;
// 64MB per dlmalloc heap block
const
int
cMaxBlocks
=
1
<<
16
;
// 64KB*64K sections = 4TB. 4TB is the largest memory config Windows supports at present.
const
SIZE_T
cSystemReserve
=
3
*
1024
i64
*
1024
i64
*
1024
i64
;
// Reserve left for Windows to operate on when we are heavily loaded.
const
wchar_t
*
cMapFileBaseName
=
L"RedisQFork"
;
const
char
*
qforkFlag
=
"--QFork"
;
const
char
*
maxmemoryFlag
=
"maxmemory"
;
const
int
cDeadForkWait
=
30000
;
const
size_t
pageSize
=
4096
;
// for Azure team testing
const
char
*
bypassSystemReserveFlag
=
"bypass-system-reserve"
;
typedef
enum
BlockState
{
bsINVALID
=
0
,
bsUNMAPPED
=
1
,
...
...
@@ -252,7 +255,7 @@ BOOL QForkSlaveInit(HANDLE QForkConrolMemoryMapHandle, DWORD ParentProcessID) {
}
BOOL
QForkMasterInit
(
__int64
maxmemoryBytes
)
{
BOOL
QForkMasterInit
(
__int64
maxmemoryBytes
,
bool
bypassSystemReserve
)
{
try
{
// allocate file map for qfork control so it can be passed to the forked process
g_hQForkControlFileMap
=
CreateFileMappingW
(
...
...
@@ -298,7 +301,7 @@ BOOL QForkMasterInit( __int64 maxmemoryBytes ) {
}
SIZE_T
maxSystemReservePages
=
3
i64
*
1024
i64
*
1024
i64
*
1024
i64
/
pageSize
;
SIZE_T
twentyPercentPhysical
=
(
perfinfo
.
PhysicalTotal
*
2
i64
)
/
10
i64
;
SIZE_T
maxPhysicalPagesToUse
=
perfinfo
.
PhysicalTotal
-
min
(
maxSystemReservePages
,
twentyPercentPhysical
);
SIZE_T
maxPhysicalPagesToUse
=
perfinfo
.
PhysicalTotal
-
min
(
maxSystemReservePages
,
bypassSystemReserve
?
0
:
twentyPercentPhysical
);
SIZE_T
maxPhysicalMapping
=
maxPhysicalPagesToUse
*
pageSize
;
if
(
maxmemoryBytes
!=
-
1
)
{
SIZE_T
allocationBlocks
=
maxmemoryBytes
/
cAllocationGranularity
;
...
...
@@ -452,7 +455,8 @@ StartupStatus QForkStartup(int argc, char** argv) {
bool
foundSlaveFlag
=
false
;
HANDLE
QForkConrolMemoryMapHandle
=
NULL
;
DWORD
PPID
=
0
;
int
maxmemory
=
-
1
;
__int64
maxmemory
=
-
1
;
bool
bypassSystemReserve
=
false
;
if
((
argc
==
3
)
&&
(
strcmp
(
argv
[
0
],
qforkFlag
)
==
0
))
{
// slave command line looks like: --QFork [QForkConrolMemoryMap handle] [parent process id]
foundSlaveFlag
=
true
;
...
...
@@ -463,10 +467,7 @@ StartupStatus QForkStartup(int argc, char** argv) {
}
else
{
bool
maxMemoryFlagFound
=
false
;
for
(
int
n
=
1
;
n
<
argc
;
n
++
)
{
if
(
maxMemoryFlagFound
)
break
;
// check for maxmemory flag in .conf file
// check for maxmemory + reserve bypass flags in .conf file
if
(
n
==
1
&&
strncmp
(
argv
[
n
],
"--"
,
2
)
!=
0
)
{
ifstream
config
;
config
.
open
(
argv
[
n
]);
...
...
@@ -477,39 +478,45 @@ StartupStatus QForkStartup(int argc, char** argv) {
getline
(
config
,
line
);
istringstream
iss
(
line
);
string
token
;
if
(
getline
(
iss
,
token
,
' '
)
&&
(
_stricmp
(
token
.
c_str
(),
maxmemoryFlag
)
==
0
))
{
string
maxmemoryString
;
if
(
getline
(
iss
,
maxmemoryString
,
' '
))
{
maxmemory
=
_atoi64
(
maxmemoryString
.
c_str
());
maxMemoryFlagFound
=
true
;
break
;
if
(
getline
(
iss
,
token
,
' '
))
{
if
(
_stricmp
(
token
.
c_str
(),
maxmemoryFlag
)
==
0
)
{
string
maxmemoryString
;
if
(
getline
(
iss
,
maxmemoryString
,
' '
))
{
maxmemory
=
_atoi64
(
maxmemoryString
.
c_str
());
maxMemoryFlagFound
=
true
;
}
}
else
if
(
_stricmp
(
token
.
c_str
(),
bypassSystemReserveFlag
)
==
0
)
{
bypassSystemReserve
=
true
;
}
}
}
continue
;
}
if
(
strncmp
(
argv
[
n
],
"--"
,
2
)
==
0
&&
_stricmp
(
argv
[
n
]
+
2
,
maxmemoryFlag
)
==
0
)
{
maxmemory
=
_atoi64
(
argv
[
n
+
1
]);
if
(
maxmemory
==
0
)
{
printf
(
"%s specified. Unable to convert %s to the maximum number of bytes to use for the heap.
\n
"
,
maxmemory
,
argv
[
n
+
1
]
);
printf
(
"Failing startup.
\n
"
);
return
StartupStatus
::
ssFAILED
;
}
else
{
maxMemoryFlagFound
=
true
;
break
;
}
}
if
(
strncmp
(
argv
[
n
],
"--"
,
2
)
==
0
)
{
if
(
_stricmp
(
argv
[
n
]
+
2
,
maxmemoryFlag
)
==
0
)
{
maxmemory
=
_atoi64
(
argv
[
n
+
1
]);
if
(
maxmemory
==
0
)
{
printf
(
"%s specified. Unable to convert %s to the maximum number of bytes to use for the heap.
\n
"
,
maxmemory
,
argv
[
n
+
1
]
);
printf
(
"Failing startup.
\n
"
);
return
StartupStatus
::
ssFAILED
;
}
else
{
maxMemoryFlagFound
=
true
;
}
}
else
if
(
_stricmp
(
argv
[
n
]
+
2
,
bypassSystemReserveFlag
)
==
0
)
{
bypassSystemReserve
=
true
;
}
}
}
}
if
(
foundSlaveFlag
)
{
return
QForkSlaveInit
(
QForkConrolMemoryMapHandle
,
PPID
)
?
StartupStatus
::
ssSLAVE_EXIT
:
StartupStatus
::
ssFAILED
;
}
else
{
return
QForkMasterInit
(
maxmemory
)
?
StartupStatus
::
ssCONTINUE_AS_MASTER
:
StartupStatus
::
ssFAILED
;
return
QForkMasterInit
(
maxmemory
,
bypassSystemReserve
)
?
StartupStatus
::
ssCONTINUE_AS_MASTER
:
StartupStatus
::
ssFAILED
;
}
}
...
...
@@ -848,9 +855,6 @@ BOOL EndForkOperation() {
}
}
}
#ifdef _DEBUG
// cout << cowList.size() << " of " << (mmSize / pageSize) << " are modified" << endl;
#endif
if
(
cowList
.
size
()
>
0
)
{
LPBYTE
cowBuffer
=
(
LPBYTE
)
malloc
(
cowList
.
size
()
*
pageSize
);
...
...
@@ -953,7 +957,7 @@ int totalFreeCalls = 0;
LPVOID
AllocHeapBlock
(
size_t
size
,
BOOL
allocateHigh
)
{
totalAllocCalls
++
;
LPVOID
retPtr
=
(
LPVOID
)
-
1
;
LPVOID
retPtr
=
(
LPVOID
)
NULL
;
if
(
size
%
g_pQForkControl
->
heapBlockSize
!=
0
)
{
errno
=
EINVAL
;
return
retPtr
;
...
...
src/config.c
浏览文件 @
30a26d36
...
...
@@ -491,7 +491,11 @@ void loadServerConfigFromString(char *config) {
err
=
sentinelHandleConfiguration
(
argv
+
1
,
argc
-
1
);
if
(
err
)
goto
loaderr
;
}
}
else
{
#ifdef _WIN32
}
else
if
(
!
strcasecmp
(
argv
[
0
],
"bypass-system-reserve"
))
{
// handled in qfork init. bypass here,
#endif
}
else
{
err
=
"Bad directive or wrong number of arguments"
;
goto
loaderr
;
}
sdsfreesplitres
(
argv
,
argc
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录