Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
别团等shy哥发育
redis
提交
0fe43c6c
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,体验更适合开发者的 AI 搜索 >>
提交
0fe43c6c
编写于
3月 05, 2014
作者:
K
Kirk Shoop (MS Open Tech)
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
attempt to prototype SEC_RESERVE
上级
0742446f
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
26 addition
and
3 deletion
+26
-3
src/Win32_Interop/Win32_QFork.cpp
src/Win32_Interop/Win32_QFork.cpp
+26
-3
未找到文件。
src/Win32_Interop/Win32_QFork.cpp
浏览文件 @
0fe43c6c
...
...
@@ -300,15 +300,25 @@ BOOL QForkMasterInit( __int64 maxmemoryBytes, bool bypassSystemReserve ) {
throw
system_error
(
GetLastError
(),
system_category
(),
"GetPerformanceInfo failed"
);
}
SIZE_T
maxSystemReservePages
=
3
i64
*
1024
i64
*
1024
i64
*
1024
i64
/
pageSize
;
#if COMMIT_ALL_PAGES
SIZE_T
twentyPercentPhysical
=
(
perfinfo
.
PhysicalTotal
*
2
i64
)
/
10
i64
;
SIZE_T
maxPhysicalPagesToUse
=
perfinfo
.
PhysicalTotal
-
min
(
maxSystemReservePages
,
bypassSystemReserve
?
0
:
twentyPercentPhysical
);
ULONG
secFlags
=
0
;
#else
SIZE_T
maxPhysicalPagesToUse
=
perfinfo
.
PhysicalTotal
*
2
i64
;
ULONG
secFlags
=
SEC_RESERVE
;
#endif
SIZE_T
maxPhysicalMapping
=
maxPhysicalPagesToUse
*
pageSize
;
if
(
maxmemoryBytes
!=
-
1
)
{
SIZE_T
allocationBlocks
=
maxmemoryBytes
/
cAllocationGranularity
;
allocationBlocks
+=
((
maxmemoryBytes
%
cAllocationGranularity
)
!=
0
);
allocationBlocks
=
(
SIZE_T
)
ceil
(
allocationBlocks
*
1.5
);
// extra reserve for fragmentation
allocationBlocks
=
max
(
2
,
allocationBlocks
);
#if COMMIT_ALL_PAGES
allocationBlocks
=
(
SIZE_T
)
ceil
(
allocationBlocks
*
1.5
);
// extra reserve for fragmentation
maxPhysicalMapping
=
min
(
maxPhysicalMapping
,
allocationBlocks
*
cAllocationGranularity
);
#else
maxPhysicalMapping
=
allocationBlocks
*
cAllocationGranularity
;
#endif
}
g_pQForkControl
->
availableBlocksInHeap
=
(
int
)(
maxPhysicalMapping
/
cAllocationGranularity
);
if
(
g_pQForkControl
->
availableBlocksInHeap
<=
0
)
{
...
...
@@ -345,7 +355,7 @@ BOOL QForkMasterInit( __int64 maxmemoryBytes, bool bypassSystemReserve ) {
CreateFileMappingW
(
g_pQForkControl
->
heapMemoryMapFile
,
NULL
,
PAGE_READWRITE
,
PAGE_READWRITE
|
secFlags
,
HIDWORD
(
mmSize
),
LODWORD
(
mmSize
),
NULL
);
...
...
@@ -363,7 +373,7 @@ BOOL QForkMasterInit( __int64 maxmemoryBytes, bool bypassSystemReserve ) {
GetCurrentProcess
(),
NULL
,
mmSize
,
MEM_RESERVE
|
MEM_
COMMIT
|
MEM_
TOP_DOWN
,
MEM_RESERVE
|
MEM_TOP_DOWN
,
PAGE_READWRITE
);
if
(
pHigh
==
NULL
)
{
throw
std
::
system_error
(
...
...
@@ -992,6 +1002,19 @@ LPVOID AllocHeapBlock(size_t size, BOOL allocateHigh) {
LPVOID
blockStart
=
reinterpret_cast
<
byte
*>
(
g_pQForkControl
->
heapStart
)
+
(
g_pQForkControl
->
heapBlockSize
*
allocationStart
);
#if COMMIT_ALL_PAGES
#else
LPVOID
pActual
=
VirtualAllocEx
(
GetCurrentProcess
(),
blockStart
,
g_pQForkControl
->
heapBlockSize
*
contiguousBlocksToAllocate
,
MEM_COMMIT
,
PAGE_READWRITE
);
if
(
pActual
==
NULL
||
pActual
!=
blockStart
)
{
contiguousBlocksFound
=
0
;
errno
=
ENOMEM
;
}
#endif
for
(
int
n
=
0
;
n
<
contiguousBlocksToAllocate
;
n
++
)
{
g_pQForkControl
->
heapBlockMap
[
allocationStart
+
n
]
=
BlockState
::
bsMAPPED
;
blocksMapped
++
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录