Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
别团等shy哥发育
redis
提交
1ff98040
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 搜索 >>
提交
1ff98040
编写于
10月 14, 2015
作者:
E
Enrico Giordani
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[Change] Switched from dlmalloc to jemalloc.
上级
2c355ebb
变更
14
隐藏空白更改
内联
并排
Showing
14 changed file
with
204 addition
and
68 deletion
+204
-68
deps/jemalloc-win/include/msvc_compat/stdint.h
deps/jemalloc-win/include/msvc_compat/stdint.h
+1
-0
deps/jemalloc-win/projects/jemalloc/proj.win32/vc2013/jemalloc.vcxproj
...-win/projects/jemalloc/proj.win32/vc2013/jemalloc.vcxproj
+2
-0
deps/jemalloc-win/src/chunk_mmap.c
deps/jemalloc-win/src/chunk_mmap.c
+7
-11
msvs/RedisBenchmark/RedisBenchmark.vcxproj
msvs/RedisBenchmark/RedisBenchmark.vcxproj
+4
-4
msvs/RedisCheckAof/RedisCheckAof.vcxproj
msvs/RedisCheckAof/RedisCheckAof.vcxproj
+4
-4
msvs/RedisCheckDump/RedisCheckDump.vcxproj
msvs/RedisCheckDump/RedisCheckDump.vcxproj
+4
-4
msvs/RedisCli/RedisCli.vcxproj
msvs/RedisCli/RedisCli.vcxproj
+4
-4
msvs/RedisServer.vcxproj
msvs/RedisServer.vcxproj
+11
-8
src/Win32_Interop/Win32_Interop.vcxproj
src/Win32_Interop/Win32_Interop.vcxproj
+8
-8
src/Win32_Interop/Win32_QFork.cpp
src/Win32_Interop/Win32_QFork.cpp
+139
-15
src/Win32_Interop/Win32_QFork.h
src/Win32_Interop/Win32_QFork.h
+12
-9
src/Win32_Interop/Win32_dlmalloc.c
src/Win32_Interop/Win32_dlmalloc.c
+5
-0
src/Win32_Interop/Win32_dlmalloc.h
src/Win32_Interop/Win32_dlmalloc.h
+2
-0
src/networking.c
src/networking.c
+1
-1
未找到文件。
deps/jemalloc-win/include/msvc_compat/stdint.h
浏览文件 @
1ff98040
...
...
@@ -49,6 +49,7 @@
#ifdef __cplusplus
extern
"C"
{
#endif
# include "../../src/Win32_Interop/win32_types.h"
# include <wchar.h>
#ifdef __cplusplus
}
...
...
deps/jemalloc-win/projects/jemalloc/proj.win32/vc2013/jemalloc.vcxproj
浏览文件 @
1ff98040
...
...
@@ -153,6 +153,7 @@
</PrecompiledHeader>
<WarningLevel>
Level3
</WarningLevel>
<DebugInformationFormat>
ProgramDatabase
</DebugInformationFormat>
<DisableSpecificWarnings>
4267;4244;4090;4334
</DisableSpecificWarnings>
</ClCompile>
<Lib>
<AdditionalLibraryDirectories>
..\..\..\..\lib\$(MsvcPlatformToolset)\$(MsvcPlatformShortName);..\..\..\..\lib;..\..\..\..\deps;$(SolutionDir)lib\$(MsvcPlatformToolset)\$(MsvcPlatformShortName);$(SolutionDir)lib;$(SolutionDir)deps;.\lib\$(MsvcPlatformToolset)\$(MsvcPlatformShortName);.\lib;.\deps;$(ProjectDir)lib\$(MsvcPlatformToolset)\$(MsvcPlatformShortName);$(ProjectDir)lib;$(ProjectDir)deps;%(AdditionalLibraryDirectories)
</AdditionalLibraryDirectories>
...
...
@@ -171,6 +172,7 @@
</PrecompiledHeader>
<WarningLevel>
Level3
</WarningLevel>
<DebugInformationFormat>
ProgramDatabase
</DebugInformationFormat>
<DisableSpecificWarnings>
4267;4244;4090;4334
</DisableSpecificWarnings>
</ClCompile>
<Lib>
<AdditionalLibraryDirectories>
...
...
deps/jemalloc-win/src/chunk_mmap.c
浏览文件 @
1ff98040
...
...
@@ -9,9 +9,9 @@ static void pages_unmap(void *addr, size_t size);
static
void
*
chunk_alloc_mmap_slow
(
size_t
size
,
size_t
alignment
,
bool
*
zero
);
extern
LPVOID
AllocHeapBlock
Map
(
LPVOID
addr
,
size_t
size
,
BOOL
zero
);
extern
int
FreeHeapBlockMap
(
LPVOID
addr
,
size_t
size
);
extern
bool
PurgeHeapBlockMap
(
LPVOID
addr
,
size_t
length
);
extern
LPVOID
AllocHeapBlock
(
LPVOID
addr
,
size_t
size
,
BOOL
zero
);
extern
BOOL
FreeHeapBlock
(
LPVOID
addr
,
size_t
size
);
extern
BOOL
PurgePages
(
LPVOID
addr
,
size_t
length
);
/******************************************************************************/
...
...
@@ -27,9 +27,8 @@ pages_map(void *addr, size_t size)
* If VirtualAlloc can't allocate at the given address when one is
* given, it fails and returns NULL.
*/
// ret = VirtualAlloc(addr, size, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
ret
=
AllocHeapBlockMap
(
addr
,
size
,
TRUE
);
//ret = VirtualAlloc(addr, size, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
ret
=
AllocHeapBlock
(
addr
,
size
,
TRUE
);
#else
/*
* We don't use MAP_FIXED here, because it can cause the *replacement*
...
...
@@ -68,7 +67,7 @@ pages_unmap(void *addr, size_t size)
#ifdef _WIN32
//if (VirtualFree(addr, 0, MEM_RELEASE) == 0)
if
(
FreeHeapBlock
Map
(
addr
,
size
)
)
if
(
FreeHeapBlock
(
addr
,
size
)
==
FALSE
)
#else
if
(
munmap
(
addr
,
size
)
==
-
1
)
#endif
...
...
@@ -125,10 +124,7 @@ pages_purge(void *addr, size_t length)
bool
unzeroed
;
#ifdef _WIN32
PurgeHeapBlockMap
(
addr
,
length
);
PurgePages
(
addr
,
length
);
unzeroed
=
true
;
#else
# ifdef JEMALLOC_PURGE_MADVISE_DONTNEED
...
...
msvs/RedisBenchmark/RedisBenchmark.vcxproj
浏览文件 @
1ff98040
...
...
@@ -88,7 +88,7 @@
</PrecompiledHeader>
<WarningLevel>
Level3
</WarningLevel>
<Optimization>
Disabled
</Optimization>
<PreprocessorDefinitions>
_OFF_T_DEFINED;WIN32;
USE_DL_PREFIX;
LACKS_STDLIB_H;_DEBUG;_CONSOLE;%(PreprocessorDefinitions);NO_QFORKIMPL
</PreprocessorDefinitions>
<PreprocessorDefinitions>
_OFF_T_DEFINED;WIN32;LACKS_STDLIB_H;_DEBUG;_CONSOLE;%(PreprocessorDefinitions);NO_QFORKIMPL
</PreprocessorDefinitions>
<AdditionalIncludeDirectories>
$(SolutionDir)..\deps\hiredis;$(SolutionDir)..\deps\lua\src
</AdditionalIncludeDirectories>
<RuntimeLibrary>
MultiThreadedDebug
</RuntimeLibrary>
<DisableSpecificWarnings>
4996
</DisableSpecificWarnings>
...
...
@@ -109,7 +109,7 @@
</PrecompiledHeader>
<WarningLevel>
Level3
</WarningLevel>
<Optimization>
Disabled
</Optimization>
<PreprocessorDefinitions>
_OFF_T_DEFINED;WIN32;
USE_DL_PREFIX;
LACKS_STDLIB_H;_DEBUG;_CONSOLE;%(PreprocessorDefinitions);NO_QFORKIMPL;_WIN32_WINNT=0x0501
</PreprocessorDefinitions>
<PreprocessorDefinitions>
_OFF_T_DEFINED;WIN32;LACKS_STDLIB_H;_DEBUG;_CONSOLE;%(PreprocessorDefinitions);NO_QFORKIMPL;_WIN32_WINNT=0x0501
</PreprocessorDefinitions>
<AdditionalIncludeDirectories>
$(SolutionDir)..\deps\hiredis;$(SolutionDir)..\deps\lua\src
</AdditionalIncludeDirectories>
<RuntimeLibrary>
MultiThreadedDebug
</RuntimeLibrary>
<DisableSpecificWarnings>
4996
</DisableSpecificWarnings>
...
...
@@ -132,7 +132,7 @@
<Optimization>
MaxSpeed
</Optimization>
<FunctionLevelLinking>
true
</FunctionLevelLinking>
<IntrinsicFunctions>
true
</IntrinsicFunctions>
<PreprocessorDefinitions>
_OFF_T_DEFINED;WIN32;
USE_DL_PREFIX;
LACKS_STDLIB_H;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);NO_QFORKIMPL
</PreprocessorDefinitions>
<PreprocessorDefinitions>
_OFF_T_DEFINED;WIN32;LACKS_STDLIB_H;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);NO_QFORKIMPL
</PreprocessorDefinitions>
<AdditionalIncludeDirectories>
$(SolutionDir)..\deps\hiredis;$(SolutionDir)..\deps\lua\src
</AdditionalIncludeDirectories>
<RuntimeLibrary>
MultiThreaded
</RuntimeLibrary>
<DisableSpecificWarnings>
4996
</DisableSpecificWarnings>
...
...
@@ -156,7 +156,7 @@
<Optimization>
MaxSpeed
</Optimization>
<FunctionLevelLinking>
true
</FunctionLevelLinking>
<IntrinsicFunctions>
true
</IntrinsicFunctions>
<PreprocessorDefinitions>
_OFF_T_DEFINED;WIN32;
USE_DL_PREFIX;
LACKS_STDLIB_H;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);NO_QFORKIMPL;_WIN32_WINNT=0x0501
</PreprocessorDefinitions>
<PreprocessorDefinitions>
_OFF_T_DEFINED;WIN32;LACKS_STDLIB_H;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);NO_QFORKIMPL;_WIN32_WINNT=0x0501
</PreprocessorDefinitions>
<AdditionalIncludeDirectories>
$(SolutionDir)..\deps\hiredis;$(SolutionDir)..\deps\lua\src
</AdditionalIncludeDirectories>
<RuntimeLibrary>
MultiThreaded
</RuntimeLibrary>
<DisableSpecificWarnings>
4996
</DisableSpecificWarnings>
...
...
msvs/RedisCheckAof/RedisCheckAof.vcxproj
浏览文件 @
1ff98040
...
...
@@ -83,7 +83,7 @@
<ClCompile>
<WarningLevel>
Level3
</WarningLevel>
<Optimization>
Disabled
</Optimization>
<PreprocessorDefinitions>
_OFF_T_DEFINED;WIN32;_DEBUG;_CONSOLE;
USE_DL_PREFIX;
LACKS_STDLIB_H;%(PreprocessorDefinitions);NO_QFORKIMPL
</PreprocessorDefinitions>
<PreprocessorDefinitions>
_OFF_T_DEFINED;WIN32;_DEBUG;_CONSOLE;LACKS_STDLIB_H;%(PreprocessorDefinitions);NO_QFORKIMPL
</PreprocessorDefinitions>
<DisableSpecificWarnings>
4996
</DisableSpecificWarnings>
<RuntimeLibrary>
MultiThreadedDebug
</RuntimeLibrary>
<AdditionalIncludeDirectories>
$(SolutionDir)..\deps\lua\src
</AdditionalIncludeDirectories>
...
...
@@ -101,7 +101,7 @@
<ClCompile>
<WarningLevel>
Level3
</WarningLevel>
<Optimization>
Disabled
</Optimization>
<PreprocessorDefinitions>
_OFF_T_DEFINED;WIN32;_DEBUG;_CONSOLE;
USE_DL_PREFIX;
LACKS_STDLIB_H;%(PreprocessorDefinitions);NO_QFORKIMPL;_WIN32_WINNT=0x0501
</PreprocessorDefinitions>
<PreprocessorDefinitions>
_OFF_T_DEFINED;WIN32;_DEBUG;_CONSOLE;LACKS_STDLIB_H;%(PreprocessorDefinitions);NO_QFORKIMPL;_WIN32_WINNT=0x0501
</PreprocessorDefinitions>
<DisableSpecificWarnings>
4996
</DisableSpecificWarnings>
<RuntimeLibrary>
MultiThreadedDebug
</RuntimeLibrary>
<AdditionalIncludeDirectories>
$(SolutionDir)..\deps\lua\src
</AdditionalIncludeDirectories>
...
...
@@ -122,7 +122,7 @@
<Optimization>
MaxSpeed
</Optimization>
<FunctionLevelLinking>
true
</FunctionLevelLinking>
<IntrinsicFunctions>
true
</IntrinsicFunctions>
<PreprocessorDefinitions>
_OFF_T_DEFINED;WIN32;_CONSOLE;%(PreprocessorDefinitions);
USE_DL_PREFIX;
LACKS_STDLIB_H;NO_QFORKIMPL
</PreprocessorDefinitions>
<PreprocessorDefinitions>
_OFF_T_DEFINED;WIN32;_CONSOLE;%(PreprocessorDefinitions);LACKS_STDLIB_H;NO_QFORKIMPL
</PreprocessorDefinitions>
<DisableSpecificWarnings>
4996
</DisableSpecificWarnings>
<RuntimeLibrary>
MultiThreaded
</RuntimeLibrary>
<AdditionalIncludeDirectories>
$(SolutionDir)..\deps\lua\src
</AdditionalIncludeDirectories>
...
...
@@ -143,7 +143,7 @@
<Optimization>
MaxSpeed
</Optimization>
<FunctionLevelLinking>
true
</FunctionLevelLinking>
<IntrinsicFunctions>
true
</IntrinsicFunctions>
<PreprocessorDefinitions>
_OFF_T_DEFINED;WIN32;_CONSOLE;%(PreprocessorDefinitions);
USE_DL_PREFIX;
LACKS_STDLIB_H;NO_QFORKIMPL;_WIN32_WINNT=0x0501
</PreprocessorDefinitions>
<PreprocessorDefinitions>
_OFF_T_DEFINED;WIN32;_CONSOLE;%(PreprocessorDefinitions);LACKS_STDLIB_H;NO_QFORKIMPL;_WIN32_WINNT=0x0501
</PreprocessorDefinitions>
<DisableSpecificWarnings>
4996
</DisableSpecificWarnings>
<RuntimeLibrary>
MultiThreaded
</RuntimeLibrary>
<AdditionalIncludeDirectories>
$(SolutionDir)..\deps\lua\src
</AdditionalIncludeDirectories>
...
...
msvs/RedisCheckDump/RedisCheckDump.vcxproj
浏览文件 @
1ff98040
...
...
@@ -83,7 +83,7 @@
<ClCompile>
<WarningLevel>
Level3
</WarningLevel>
<Optimization>
Disabled
</Optimization>
<PreprocessorDefinitions>
_OFF_T_DEFINED;WIN32;
USE_DL_PREFIX;
LACKS_STDLIB_H;_DEBUG;_CONSOLE;%(PreprocessorDefinitions);NO_QFORKIMPL
</PreprocessorDefinitions>
<PreprocessorDefinitions>
_OFF_T_DEFINED;WIN32;LACKS_STDLIB_H;_DEBUG;_CONSOLE;%(PreprocessorDefinitions);NO_QFORKIMPL
</PreprocessorDefinitions>
<RuntimeLibrary>
MultiThreadedDebug
</RuntimeLibrary>
<DisableSpecificWarnings>
4996
</DisableSpecificWarnings>
<AdditionalIncludeDirectories>
$(SolutionDir)..\deps\lua\src
</AdditionalIncludeDirectories>
...
...
@@ -101,7 +101,7 @@
<ClCompile>
<WarningLevel>
Level3
</WarningLevel>
<Optimization>
Disabled
</Optimization>
<PreprocessorDefinitions>
_OFF_T_DEFINED;WIN32;
USE_DL_PREFIX;
LACKS_STDLIB_H;_DEBUG;_CONSOLE;%(PreprocessorDefinitions);NO_QFORKIMPL;_WIN32_WINNT=0x0501
</PreprocessorDefinitions>
<PreprocessorDefinitions>
_OFF_T_DEFINED;WIN32;LACKS_STDLIB_H;_DEBUG;_CONSOLE;%(PreprocessorDefinitions);NO_QFORKIMPL;_WIN32_WINNT=0x0501
</PreprocessorDefinitions>
<RuntimeLibrary>
MultiThreadedDebug
</RuntimeLibrary>
<DisableSpecificWarnings>
4996
</DisableSpecificWarnings>
<AdditionalIncludeDirectories>
$(SolutionDir)..\deps\lua\src
</AdditionalIncludeDirectories>
...
...
@@ -122,7 +122,7 @@
<Optimization>
Full
</Optimization>
<FunctionLevelLinking>
true
</FunctionLevelLinking>
<IntrinsicFunctions>
true
</IntrinsicFunctions>
<PreprocessorDefinitions>
_OFF_T_DEFINED;WIN32;
USE_DL_PREFIX;
LACKS_STDLIB_H;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);NO_QFORKIMPL
</PreprocessorDefinitions>
<PreprocessorDefinitions>
_OFF_T_DEFINED;WIN32;LACKS_STDLIB_H;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);NO_QFORKIMPL
</PreprocessorDefinitions>
<RuntimeLibrary>
MultiThreaded
</RuntimeLibrary>
<DisableSpecificWarnings>
4996
</DisableSpecificWarnings>
<AdditionalIncludeDirectories>
$(SolutionDir)..\deps\lua\src
</AdditionalIncludeDirectories>
...
...
@@ -144,7 +144,7 @@
<Optimization>
MaxSpeed
</Optimization>
<FunctionLevelLinking>
true
</FunctionLevelLinking>
<IntrinsicFunctions>
true
</IntrinsicFunctions>
<PreprocessorDefinitions>
_OFF_T_DEFINED;WIN32;
USE_DL_PREFIX;
LACKS_STDLIB_H;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);NO_QFORKIMPL;_WIN32_WINNT=0x0501
</PreprocessorDefinitions>
<PreprocessorDefinitions>
_OFF_T_DEFINED;WIN32;LACKS_STDLIB_H;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);NO_QFORKIMPL;_WIN32_WINNT=0x0501
</PreprocessorDefinitions>
<RuntimeLibrary>
MultiThreaded
</RuntimeLibrary>
<DisableSpecificWarnings>
4996
</DisableSpecificWarnings>
<AdditionalIncludeDirectories>
$(SolutionDir)..\deps\lua\src
</AdditionalIncludeDirectories>
...
...
msvs/RedisCli/RedisCli.vcxproj
浏览文件 @
1ff98040
...
...
@@ -84,7 +84,7 @@
<WarningLevel>
Level3
</WarningLevel>
<Optimization>
Disabled
</Optimization>
<AdditionalIncludeDirectories>
$(SolutionDir)..\deps\hiredis;$(SolutionDir)..\deps\linenoise;$(SolutionDir)..\deps\lua\src
</AdditionalIncludeDirectories>
<PreprocessorDefinitions>
_OFF_T_DEFINED;WIN32;
USE_DL_PREFIX;
LACKS_STDLIB_H;_DEBUG;_CONSOLE;%(PreprocessorDefinitions);NO_QFORKIMPL
</PreprocessorDefinitions>
<PreprocessorDefinitions>
_OFF_T_DEFINED;WIN32;LACKS_STDLIB_H;_DEBUG;_CONSOLE;%(PreprocessorDefinitions);NO_QFORKIMPL
</PreprocessorDefinitions>
<RuntimeLibrary>
MultiThreadedDebug
</RuntimeLibrary>
<DisableSpecificWarnings>
4996
</DisableSpecificWarnings>
</ClCompile>
...
...
@@ -103,7 +103,7 @@
<WarningLevel>
Level3
</WarningLevel>
<Optimization>
Disabled
</Optimization>
<AdditionalIncludeDirectories>
$(SolutionDir)..\deps\hiredis;$(SolutionDir)..\deps\linenoise;$(SolutionDir)..\deps\lua\src
</AdditionalIncludeDirectories>
<PreprocessorDefinitions>
_OFF_T_DEFINED;WIN32;
USE_DL_PREFIX;
LACKS_STDLIB_H;_DEBUG;_CONSOLE;%(PreprocessorDefinitions);NO_QFORKIMPL;_WIN32_WINNT=0x0501
</PreprocessorDefinitions>
<PreprocessorDefinitions>
_OFF_T_DEFINED;WIN32;LACKS_STDLIB_H;_DEBUG;_CONSOLE;%(PreprocessorDefinitions);NO_QFORKIMPL;_WIN32_WINNT=0x0501
</PreprocessorDefinitions>
<RuntimeLibrary>
MultiThreadedDebug
</RuntimeLibrary>
<DisableSpecificWarnings>
4996
</DisableSpecificWarnings>
</ClCompile>
...
...
@@ -125,7 +125,7 @@
<FunctionLevelLinking>
true
</FunctionLevelLinking>
<IntrinsicFunctions>
true
</IntrinsicFunctions>
<AdditionalIncludeDirectories>
$(SolutionDir)..\deps\hiredis;$(SolutionDir)..\deps\linenoise;$(SolutionDir)..\deps\lua\src
</AdditionalIncludeDirectories>
<PreprocessorDefinitions>
_OFF_T_DEFINED;WIN32;
USE_DL_PREFIX;
LACKS_STDLIB_H;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);NO_QFORKIMPL
</PreprocessorDefinitions>
<PreprocessorDefinitions>
_OFF_T_DEFINED;WIN32;LACKS_STDLIB_H;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);NO_QFORKIMPL
</PreprocessorDefinitions>
<RuntimeLibrary>
MultiThreaded
</RuntimeLibrary>
<DisableSpecificWarnings>
4996
</DisableSpecificWarnings>
<WholeProgramOptimization>
true
</WholeProgramOptimization>
...
...
@@ -148,7 +148,7 @@
<FunctionLevelLinking>
true
</FunctionLevelLinking>
<IntrinsicFunctions>
true
</IntrinsicFunctions>
<AdditionalIncludeDirectories>
$(SolutionDir)..\deps\hiredis;$(SolutionDir)..\deps\linenoise;$(SolutionDir)..\deps\lua\src
</AdditionalIncludeDirectories>
<PreprocessorDefinitions>
_OFF_T_DEFINED;WIN32;
USE_DL_PREFIX;
LACKS_STDLIB_H;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);NO_QFORKIMPL;_WIN32_WINNT=0x0501
</PreprocessorDefinitions>
<PreprocessorDefinitions>
_OFF_T_DEFINED;WIN32;LACKS_STDLIB_H;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);NO_QFORKIMPL;_WIN32_WINNT=0x0501
</PreprocessorDefinitions>
<RuntimeLibrary>
MultiThreaded
</RuntimeLibrary>
<DisableSpecificWarnings>
4996
</DisableSpecificWarnings>
</ClCompile>
...
...
msvs/RedisServer.vcxproj
浏览文件 @
1ff98040
...
...
@@ -84,8 +84,8 @@
</PropertyGroup>
<ItemDefinitionGroup
Condition=
"'$(Configuration)|$(Platform)'=='Debug|x64'"
>
<ClCompile>
<PreprocessorDefinitions>
_OFF_T_DEFINED;WIN32;USE_DL_PREFIX;LACKS_STDLIB_H;_DEBUG;_CONSOLE;__x86_64__;%(PreprocessorDefinitions);USE_DLMALLOC
</PreprocessorDefinitions>
<AdditionalIncludeDirectories>
$(SolutionDir)..\deps\lua\src;$(SolutionDir)..\deps\hiredis
</AdditionalIncludeDirectories>
<PreprocessorDefinitions>
USE_JEMALLOC;_OFF_T_DEFINED;WIN32;LACKS_STDLIB_H;_DEBUG;_CONSOLE;__x86_64__;%(PreprocessorDefinitions)
</PreprocessorDefinitions>
<AdditionalIncludeDirectories>
$(SolutionDir)..\deps\lua\src;$(SolutionDir)..\deps\hiredis
;$(SolutionDir)..\deps\jemalloc-win\include
</AdditionalIncludeDirectories>
<RuntimeLibrary>
MultiThreadedDebug
</RuntimeLibrary>
<WarningLevel>
Level3
</WarningLevel>
<DebugInformationFormat>
ProgramDatabase
</DebugInformationFormat>
...
...
@@ -105,8 +105,8 @@
</ItemDefinitionGroup>
<ItemDefinitionGroup
Condition=
"'$(Configuration)|$(Platform)'=='Debug|Win32'"
>
<ClCompile>
<PreprocessorDefinitions>
_OFF_T_DEFINED;WIN32;USE_DL_PREFIX;LACKS_STDLIB_H;_DEBUG;_CONSOLE;__x86_64__;%(PreprocessorDefinitions);USE_DLMALLOC
;_WIN32_WINNT=0x0501
</PreprocessorDefinitions>
<AdditionalIncludeDirectories>
$(SolutionDir)..\deps\lua\src;$(SolutionDir)..\deps\hiredis
</AdditionalIncludeDirectories>
<PreprocessorDefinitions>
USE_JEMALLOC;_OFF_T_DEFINED;WIN32;LACKS_STDLIB_H;_DEBUG;_CONSOLE;__x86_64__;%(PreprocessorDefinitions)
;_WIN32_WINNT=0x0501
</PreprocessorDefinitions>
<AdditionalIncludeDirectories>
$(SolutionDir)..\deps\lua\src;$(SolutionDir)..\deps\hiredis
;$(SolutionDir)..\deps\jemalloc-win\include
</AdditionalIncludeDirectories>
<RuntimeLibrary>
MultiThreadedDebug
</RuntimeLibrary>
<WarningLevel>
Level3
</WarningLevel>
<DebugInformationFormat>
ProgramDatabase
</DebugInformationFormat>
...
...
@@ -126,8 +126,8 @@
</ItemDefinitionGroup>
<ItemDefinitionGroup
Condition=
"'$(Configuration)|$(Platform)'=='Release|x64'"
>
<ClCompile>
<PreprocessorDefinitions>
_OFF_T_DEFINED;WIN32;USE_DL_PREFIX;LACKS_STDLIB_H;NDEBUG;_CONSOLE;__x86_64__;%(PreprocessorDefinitions);USE_DLMALLOC
</PreprocessorDefinitions>
<AdditionalIncludeDirectories>
$(SolutionDir)..\deps\lua\src;$(SolutionDir)..\deps\hiredis
</AdditionalIncludeDirectories>
<PreprocessorDefinitions>
USE_JEMALLOC;_OFF_T_DEFINED;WIN32;LACKS_STDLIB_H;NDEBUG;_CONSOLE;__x86_64__;%(PreprocessorDefinitions)
</PreprocessorDefinitions>
<AdditionalIncludeDirectories>
$(SolutionDir)..\deps\lua\src;$(SolutionDir)..\deps\hiredis
;$(SolutionDir)..\deps\jemalloc-win\include
</AdditionalIncludeDirectories>
<RuntimeLibrary>
MultiThreaded
</RuntimeLibrary>
<WarningLevel>
Level3
</WarningLevel>
<DebugInformationFormat>
ProgramDatabase
</DebugInformationFormat>
...
...
@@ -158,8 +158,8 @@
</ItemDefinitionGroup>
<ItemDefinitionGroup
Condition=
"'$(Configuration)|$(Platform)'=='Release|Win32'"
>
<ClCompile>
<PreprocessorDefinitions>
_OFF_T_DEFINED;_WIN32;USE_DL_PREFIX;LACKS_STDLIB_H;NDEBUG;_CONSOLE;__x86_64__;%(PreprocessorDefinitions);USE_DLMALLOC
;_WIN32_WINNT=0x0501
</PreprocessorDefinitions>
<AdditionalIncludeDirectories>
$(SolutionDir)..\deps\lua\src;$(SolutionDir)..\deps\hiredis
</AdditionalIncludeDirectories>
<PreprocessorDefinitions>
USE_JEMALLOC;_OFF_T_DEFINED;_WIN32;LACKS_STDLIB_H;NDEBUG;_CONSOLE;__x86_64__;%(PreprocessorDefinitions)
;_WIN32_WINNT=0x0501
</PreprocessorDefinitions>
<AdditionalIncludeDirectories>
$(SolutionDir)..\deps\lua\src;$(SolutionDir)..\deps\hiredis
;$(SolutionDir)..\deps\jemalloc-win\include
</AdditionalIncludeDirectories>
<RuntimeLibrary>
MultiThreaded
</RuntimeLibrary>
<WarningLevel>
Level3
</WarningLevel>
<DebugInformationFormat>
ProgramDatabase
</DebugInformationFormat>
...
...
@@ -267,6 +267,9 @@
<ClInclude
Include=
"..\src\zmalloc.h"
/>
</ItemGroup>
<ItemGroup>
<ProjectReference
Include=
"..\deps\jemalloc-win\projects\jemalloc\proj.win32\vc2013\jemalloc.vcxproj"
>
<Project>
{8b897e33-6428-4254-8335-4911d179bad1}
</Project>
</ProjectReference>
<ProjectReference
Include=
"..\src\Win32_Interop\Win32_Interop.vcxproj"
>
<Project>
{8c07f811-c81c-432c-b334-1ae6faecf951}
</Project>
</ProjectReference>
...
...
src/Win32_Interop/Win32_Interop.vcxproj
浏览文件 @
1ff98040
...
...
@@ -159,8 +159,8 @@ link.exe -dll -noentry resources/EventLog.res -out:$(TargetDir)EventLog.dll
</PrecompiledHeader>
<WarningLevel>
Level3
</WarningLevel>
<Optimization>
Disabled
</Optimization>
<PreprocessorDefinitions>
_OFF_T_DEFINED;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions);USE_DL_PREFIX;LACKS_STDLIB_H;USE_DLMALLOC
;_CRT_SECURE_NO_WARNINGS;PSAPI_VERSION=1
</PreprocessorDefinitions>
<AdditionalIncludeDirectories>
$(ProjectDir)..\..\deps\lua\src
</AdditionalIncludeDirectories>
<PreprocessorDefinitions>
USE_STATIC;USE_JEMALLOC;_OFF_T_DEFINED;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions);LACKS_STDLIB_H
;_CRT_SECURE_NO_WARNINGS;PSAPI_VERSION=1
</PreprocessorDefinitions>
<AdditionalIncludeDirectories>
$(ProjectDir)..\..\deps\lua\src
;$(ProjectDir)..\..\deps\jemalloc-win\include
</AdditionalIncludeDirectories>
<RuntimeLibrary>
MultiThreadedDebug
</RuntimeLibrary>
</ClCompile>
<Link>
...
...
@@ -179,8 +179,8 @@ link.exe -dll -noentry resources/EventLog.res -out:$(TargetDir)EventLog.dll
</PrecompiledHeader>
<WarningLevel>
Level3
</WarningLevel>
<Optimization>
Disabled
</Optimization>
<PreprocessorDefinitions>
_OFF_T_DEFINED;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions);USE_DL_PREFIX;LACKS_STDLIB_H;USE_DLMALLOC
;_CRT_SECURE_NO_WARNINGS;PSAPI_VERSION=1;_WIN32_WINNT=0x0501
</PreprocessorDefinitions>
<AdditionalIncludeDirectories>
$(ProjectDir)..\..\deps\lua\src
</AdditionalIncludeDirectories>
<PreprocessorDefinitions>
USE_STATIC;USE_JEMALLOC;_OFF_T_DEFINED;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions);LACKS_STDLIB_H
;_CRT_SECURE_NO_WARNINGS;PSAPI_VERSION=1;_WIN32_WINNT=0x0501
</PreprocessorDefinitions>
<AdditionalIncludeDirectories>
$(ProjectDir)..\..\deps\lua\src
;$(ProjectDir)..\..\deps\jemalloc-win\include
</AdditionalIncludeDirectories>
<RuntimeLibrary>
MultiThreadedDebug
</RuntimeLibrary>
</ClCompile>
<Link>
...
...
@@ -204,8 +204,8 @@ link.exe -dll -noentry resources/EventLog.res -out:$(TargetDir)EventLog.dll
<Optimization>
Full
</Optimization>
<FunctionLevelLinking>
true
</FunctionLevelLinking>
<IntrinsicFunctions>
true
</IntrinsicFunctions>
<PreprocessorDefinitions>
_OFF_T_DEFINED;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions);USE_DL_PREFIX;LACKS_STDLIB_H;USE_DLMALLOC
;_CRT_SECURE_NO_WARNINGS;PSAPI_VERSION=1
</PreprocessorDefinitions>
<AdditionalIncludeDirectories>
$(ProjectDir)..\..\deps\lua\src
</AdditionalIncludeDirectories>
<PreprocessorDefinitions>
USE_STATIC;USE_JEMALLOC;_OFF_T_DEFINED;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions);LACKS_STDLIB_H
;_CRT_SECURE_NO_WARNINGS;PSAPI_VERSION=1
</PreprocessorDefinitions>
<AdditionalIncludeDirectories>
$(ProjectDir)..\..\deps\lua\src
;$(ProjectDir)..\..\deps\jemalloc-win\include
</AdditionalIncludeDirectories>
<RuntimeLibrary>
MultiThreaded
</RuntimeLibrary>
<WholeProgramOptimization>
true
</WholeProgramOptimization>
</ClCompile>
...
...
@@ -228,8 +228,8 @@ link.exe -dll -noentry resources/EventLog.res -out:$(TargetDir)EventLog.dll
<Optimization>
MaxSpeed
</Optimization>
<FunctionLevelLinking>
true
</FunctionLevelLinking>
<IntrinsicFunctions>
true
</IntrinsicFunctions>
<PreprocessorDefinitions>
_OFF_T_DEFINED;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions);USE_DL_PREFIX;LACKS_STDLIB_H;USE_DLMALLOC
;_CRT_SECURE_NO_WARNINGS;PSAPI_VERSION=1;_WIN32_WINNT=0x0501
</PreprocessorDefinitions>
<AdditionalIncludeDirectories>
$(ProjectDir)..\..\deps\lua\src
</AdditionalIncludeDirectories>
<PreprocessorDefinitions>
USE_STATIC;USE_JEMALLOC;_OFF_T_DEFINED;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions);LACKS_STDLIB_H
;_CRT_SECURE_NO_WARNINGS;PSAPI_VERSION=1;_WIN32_WINNT=0x0501
</PreprocessorDefinitions>
<AdditionalIncludeDirectories>
$(ProjectDir)..\..\deps\lua\src
;$(ProjectDir)..\..\deps\jemalloc-win\include
</AdditionalIncludeDirectories>
<RuntimeLibrary>
MultiThreaded
</RuntimeLibrary>
</ClCompile>
<Link>
...
...
src/Win32_Interop/Win32_QFork.cpp
浏览文件 @
1ff98040
...
...
@@ -99,7 +99,6 @@ allocate a system paging file that will expand up to about (3.5 * physical).
#include "Win32_QFork.h"
#include "Win32_QFork_impl.h"
#include "Win32_dlmalloc.h"
#include "Win32_SmartHandle.h"
#include "Win32_Service.h"
#include "Win32_CommandLine.h"
...
...
@@ -107,6 +106,12 @@ allocate a system paging file that will expand up to about (3.5 * physical).
#include "Win32_StackTrace.h"
#include "Win32_ThreadControl.h"
#ifdef USE_DLMALLOC
#include "Win32_dlmalloc.h"
#elif USE_JEMALLOC
#include <jemalloc/jemalloc.h>
#endif
using
namespace
std
;
//#define DEBUG_WITH_PROCMON
...
...
@@ -170,18 +175,29 @@ extern "C"
void
InitTimeFunctions
();
PORT_LONGLONG
memtoll
(
const
char
*
p
,
int
*
err
);
// Forward def from util.h
#ifdef USE_DLMALLOC
void
*
(
*
g_malloc
)(
size_t
)
=
nullptr
;
void
*
(
*
g_calloc
)(
size_t
,
size_t
)
=
nullptr
;
void
*
(
*
g_realloc
)(
void
*
,
size_t
)
=
nullptr
;
void
(
*
g_free
)(
void
*
)
=
nullptr
;
size_t
(
*
g_msize
)(
void
*
)
=
nullptr
;
#endif
}
const
size_t
cAllocationGranularity
=
1
<<
18
;
// 256KB per heap block (matches large block allocation threshold of dlmalloc)
#ifdef _WIN64
const
int
cMaxBlocks
=
1
<<
22
;
// 256KB * 4M heap blocks = 1TB
#else
const
int
cMaxBlocks
=
1
<<
13
;
// 256KB * 8K heap blocks = 2GB
#ifdef USE_DLMALLOC
const
size_t
cAllocationGranularity
=
1
<<
18
;
// 256KB per heap block (matches large block allocation threshold of dlmalloc)
#ifdef _WIN64
const
int
cMaxBlocks
=
1
<<
22
;
// 256KB * 4M heap blocks = 1TB
#else
const
int
cMaxBlocks
=
1
<<
13
;
// 256KB * 8K heap blocks = 2GB
#endif
#elif USE_JEMALLOC
const
size_t
cAllocationGranularity
=
1
<<
22
;
// 4MB per heap block (matches the default allocation threshold of jemalloc)
#ifdef _WIN64
const
int
cMaxBlocks
=
1
<<
18
;
// 4MB * 256K heap blocks = 1TB
#else
const
int
cMaxBlocks
=
1
<<
9
;
// 4MB * 512 heap blocks = 2GB
#endif
#endif
const
int
cDeadForkWait
=
30000
;
...
...
@@ -206,8 +222,10 @@ struct QForkControl {
// Global data pointers to be passed to the forked process
QForkBeginInfo
globalData
;
#ifdef USE_DLMALLOC
BYTE
DLMallocGlobalState
[
1000
];
size_t
DLMallocGlobalStateSize
;
#endif
};
QForkControl
*
g_pQForkControl
;
...
...
@@ -215,6 +233,14 @@ HANDLE g_hQForkControlFileMap;
HANDLE
g_hForkedProcess
=
0
;
int
g_ChildExitCode
=
0
;
// For child process
BOOL
g_isForkedProcess
;
BOOL
g_SentinelMode
;
/* The system heap is used instead of the system paging file heap one of
the following case is true:
- Redis is running as a sentinel
- the current instance is a forked (child) process
- the persistence-available configuration flag value is 'no' */
BOOL
g_UseSystemHeap
;
bool
ReportSpecialSystemErrors
(
int
error
)
{
switch
(
error
)
...
...
@@ -241,6 +267,7 @@ bool ReportSpecialSystemErrors(int error) {
}
}
#ifdef USE_DLMALLOC
BOOL
DLMallocInizialized
=
false
;
void
DLMallocInit
()
{
// This must be called only once per process
...
...
@@ -249,6 +276,7 @@ void DLMallocInit() {
DLMallocInizialized
=
TRUE
;
}
}
#endif
BOOL
QForkChildInit
(
HANDLE
QForkControlMemoryMapHandle
,
DWORD
ParentProcessID
)
{
SmartHandle
shParent
;
...
...
@@ -297,10 +325,12 @@ BOOL QForkChildInit(HANDLE QForkControlMemoryMapHandle, DWORD ParentProcessID) {
}
}
#ifdef USE_DLMALLOC
// Setup DLMalloc global data
if
(
SetDLMallocGlobalState
(
g_pQForkControl
->
DLMallocGlobalStateSize
,
g_pQForkControl
->
DLMallocGlobalState
)
!=
0
)
{
throw
runtime_error
(
"DLMalloc global state copy failed."
);
}
#endif
// Copy redis globals into fork process
SetupGlobals
(
g_pQForkControl
->
globalData
.
globalData
,
g_pQForkControl
->
globalData
.
globalDataSize
,
g_pQForkControl
->
globalData
.
dictHashSeed
);
...
...
@@ -479,6 +509,7 @@ StartupStatus QForkStartup() {
Globals
::
pageSize
=
perfinfo
.
PageSize
;
if
(
g_isForkedProcess
)
{
g_UseSystemHeap
=
TRUE
;
return
QForkChildInit
(
QForkControlMemoryMapHandle
,
PPID
)
?
StartupStatus
::
ssCHILD_EXIT
:
StartupStatus
::
ssFAILED
;
}
else
{
return
QForkParentInit
()
?
StartupStatus
::
ssCONTINUE_AS_PARENT
:
StartupStatus
::
ssFAILED
;
...
...
@@ -536,6 +567,7 @@ void CopyForkOperationData(OperationType type, LPVOID globalData, int sizeOfGlob
g_pQForkControl
->
globalData
.
globalDataSize
=
sizeOfGlobalData
;
g_pQForkControl
->
globalData
.
dictHashSeed
=
dictHashSeed
;
#ifdef USE_DLMALLOC
GetDLMallocGlobalState
(
&
g_pQForkControl
->
DLMallocGlobalStateSize
,
NULL
);
if
(
g_pQForkControl
->
DLMallocGlobalStateSize
>
sizeof
(
g_pQForkControl
->
DLMallocGlobalState
))
{
throw
runtime_error
(
"DLMalloc global state too large."
);
...
...
@@ -543,6 +575,7 @@ void CopyForkOperationData(OperationType type, LPVOID globalData, int sizeOfGlob
if
(
GetDLMallocGlobalState
(
&
g_pQForkControl
->
DLMallocGlobalStateSize
,
g_pQForkControl
->
DLMallocGlobalState
)
!=
0
)
{
throw
runtime_error
(
"DLMalloc global state copy failed."
);
}
#endif
// Protect the qfork control map from propagating local changes
DWORD
oldProtect
=
0
;
...
...
@@ -652,7 +685,11 @@ pid_t BeginForkOperation_Aof(
}
void
BeginForkOperation_Socket_Duplicate
(
DWORD
dwProcessId
)
{
#ifdef USE_DLMALLOC
WSAPROTOCOL_INFO
*
protocolInfo
=
(
WSAPROTOCOL_INFO
*
)
dlmalloc
(
sizeof
(
WSAPROTOCOL_INFO
)
*
g_pQForkControl
->
globalData
.
numfds
);
#elif USE_JEMALLOC
WSAPROTOCOL_INFO
*
protocolInfo
=
(
WSAPROTOCOL_INFO
*
)
je_malloc
(
sizeof
(
WSAPROTOCOL_INFO
)
*
g_pQForkControl
->
globalData
.
numfds
);
#endif
g_pQForkControl
->
globalData
.
protocolInfo
=
protocolInfo
;
for
(
int
i
=
0
;
i
<
g_pQForkControl
->
globalData
.
numfds
;
i
++
)
{
FDAPI_WSADuplicateSocket
(
g_pQForkControl
->
globalData
.
fds
[
i
],
dwProcessId
,
&
protocolInfo
[
i
]);
...
...
@@ -879,9 +916,10 @@ HANDLE CreateBlockMap(int blockIndex) {
return
NULL
;
}
#ifdef USE_DLMALLOC
/* NOTE: The allocateHigh parameter is ignored in this implementation */
LPVOID
AllocHeapBlock
(
size_t
size
,
BOOL
allocateHigh
)
{
if
(
g_
isForkedProcess
)
{
if
(
g_
UseSystemHeap
)
{
return
VirtualAlloc
(
NULL
,
size
,
MEM_RESERVE
|
MEM_COMMIT
,
PAGE_READWRITE
);
}
...
...
@@ -944,8 +982,77 @@ LPVOID AllocHeapBlock(size_t size, BOOL allocateHigh) {
return
retPtr
;
}
#elif USE_JEMALLOC
LPVOID
AllocHeapBlock
(
LPVOID
addr
,
size_t
size
,
BOOL
zero
)
{
if
(
g_UseSystemHeap
)
{
return
VirtualAlloc
(
addr
,
size
,
MEM_RESERVE
|
MEM_COMMIT
,
PAGE_READWRITE
);
}
if
(
size
%
cAllocationGranularity
!=
0
)
{
errno
=
EINVAL
;
return
NULL
;
}
int
contiguousBlocksToAllocate
=
(
int
)
(
size
/
cAllocationGranularity
);
int
startSearch
=
g_pQForkControl
->
blockSearchStart
;
int
endSearch
=
g_pQForkControl
->
maxAvailableBlocks
-
contiguousBlocksToAllocate
;
int
contiguousBlocksFound
=
0
;
int
allocationStartIndex
=
0
;
for
(
int
startIdx
=
startSearch
;
startIdx
<
endSearch
;
startIdx
++
)
{
for
(
int
i
=
0
;
i
<
contiguousBlocksToAllocate
;
i
++
)
{
if
(
g_pQForkControl
->
heapBlockList
[
startIdx
+
i
].
state
==
BlockState
::
bsUNMAPPED
||
g_pQForkControl
->
heapBlockList
[
startIdx
+
i
].
state
==
BlockState
::
bsMAPPED_FREE
)
{
contiguousBlocksFound
++
;
}
else
{
contiguousBlocksFound
=
0
;
startIdx
+=
i
;
// restart searching from there
break
;
}
}
if
(
contiguousBlocksFound
==
contiguousBlocksToAllocate
)
{
allocationStartIndex
=
startIdx
;
break
;
}
}
if
(
contiguousBlocksFound
!=
contiguousBlocksToAllocate
)
{
errno
=
ENOMEM
;
return
NULL
;
}
ASSERT
(
allocationStartIndex
+
contiguousBlocksToAllocate
<
g_pQForkControl
->
maxAvailableBlocks
);
for
(
int
i
=
0
;
i
<
contiguousBlocksToAllocate
;
i
++
)
{
int
index
=
allocationStartIndex
+
i
;
if
(
g_pQForkControl
->
heapBlockList
[
index
].
state
==
BlockState
::
bsUNMAPPED
)
{
g_pQForkControl
->
heapBlockList
[
index
].
heapMap
=
CreateBlockMap
(
index
);
g_pQForkControl
->
numMappedBlocks
+=
1
;
}
else
{
// The current block state is bsMAPPED_FREE, therefore it needs to be
// zeroed (bsUNMAPPED blocks don't need to be zeroed since newly mapped
// blocked have zeroed memory by default)
if
(
zero
)
{
LPVOID
ptr
=
reinterpret_cast
<
byte
*>
(
g_pQForkControl
->
heapStart
)
+
(
cAllocationGranularity
*
index
);
ZeroMemory
(
ptr
,
cAllocationGranularity
);
}
}
g_pQForkControl
->
heapBlockList
[
index
].
state
=
BlockState
::
bsMAPPED_IN_USE
;
}
LPVOID
retPtr
=
reinterpret_cast
<
byte
*>
(
g_pQForkControl
->
heapStart
)
+
(
cAllocationGranularity
*
allocationStartIndex
);
if
(
allocationStartIndex
==
g_pQForkControl
->
blockSearchStart
)
{
g_pQForkControl
->
blockSearchStart
=
allocationStartIndex
+
contiguousBlocksToAllocate
;
}
return
retPtr
;
}
#endif
BOOL
FreeHeapBlock
(
LPVOID
addr
,
size_t
size
)
{
if
(
g_
isForkedProcess
)
{
if
(
g_
UseSystemHeap
)
{
return
VirtualFree
(
addr
,
0
,
MEM_RELEASE
);
}
...
...
@@ -980,6 +1087,16 @@ BOOL FreeHeapBlock(LPVOID addr, size_t size) {
return
TRUE
;
}
BOOL
PurgePages
(
LPVOID
addr
,
size_t
length
)
{
if
(
g_UseSystemHeap
)
{
VirtualAlloc
(
addr
,
length
,
MEM_RESET
,
PAGE_READWRITE
);
return
TRUE
;
}
VirtualAlloc
(
addr
,
length
,
MEM_RESET
,
PAGE_READWRITE
);
return
TRUE
;
}
void
SetupLogging
()
{
bool
serviceRun
=
g_argMap
.
find
(
cServiceRun
)
!=
g_argMap
.
end
();
string
syslogEnabledValue
=
(
g_argMap
.
find
(
cSyslogEnabled
)
!=
g_argMap
.
end
()
?
g_argMap
[
cSyslogEnabled
].
at
(
0
).
at
(
0
)
:
cNo
);
...
...
@@ -1001,7 +1118,7 @@ extern "C"
if
(
g_argMap
.
find
(
cPersistenceAvailable
)
!=
g_argMap
.
end
())
{
return
(
g_argMap
[
cPersistenceAvailable
].
at
(
0
).
at
(
0
)
!=
cNo
);
}
else
{
return
true
;
return
TRUE
;
}
}
...
...
@@ -1052,12 +1169,17 @@ extern "C"
return
0
;
}
DLMallocInit
();
BOOL
persistenceAvailable
=
IsPersistenceAvailable
();
g_SentinelMode
=
checkForSentinelMode
(
argc
,
argv
);
int
sentinelMode
=
checkForSentinelMode
(
argc
,
argv
);
if
(
g_SentinelMode
==
TRUE
||
persistenceAvailable
==
FALSE
)
{
g_UseSystemHeap
=
TRUE
;
}
// Setup memory allocation scheme for persistence mode
if
(
IsPersistenceAvailable
()
==
TRUE
&&
sentinelMode
==
0
)
{
#ifdef USE_DLMALLOC
DLMallocInit
();
// Setup memory allocation scheme
if
(
g_UseSystemHeap
==
FALSE
)
{
g_malloc
=
dlmalloc
;
g_calloc
=
dlcalloc
;
g_realloc
=
dlrealloc
;
...
...
@@ -1070,8 +1192,10 @@ extern "C"
g_free
=
free
;
g_msize
=
_msize
;
}
if
(
IsPersistenceAvailable
()
==
TRUE
&&
sentinelMode
==
0
)
{
#elif USE_JEMALLOC
je_init
();
#endif
if
(
persistenceAvailable
==
TRUE
&&
g_SentinelMode
==
FALSE
)
{
StartupStatus
status
=
QForkStartup
();
if
(
status
==
ssCONTINUE_AS_PARENT
)
{
int
retval
=
redis_main
(
argc
,
argv
);
...
...
src/Win32_Interop/Win32_QFork.h
浏览文件 @
1ff98040
...
...
@@ -80,17 +80,20 @@ OperationStatus GetForkOperationStatus();
BOOL
EndForkOperation
(
int
*
pExitCode
);
BOOL
AbortForkOperation
();
// For DLMalloc use only
LPVOID
AllocHeapBlock
(
size_t
size
,
BOOL
allocateHigh
);
#ifdef USE_DLMALLOC
LPVOID
AllocHeapBlock
(
size_t
size
,
BOOL
allocateHigh
);
// for no persistence optimization/feature when using dlmalloc
extern
void
*
(
*
g_malloc
)(
size_t
);
extern
void
*
(
*
g_calloc
)(
size_t
,
size_t
);
extern
void
*
(
*
g_realloc
)(
void
*
,
size_t
);
extern
void
(
*
g_free
)(
void
*
);
extern
size_t
(
*
g_msize
)(
void
*
);
#elif USE_JEMALLOC
LPVOID
AllocHeapBlock
(
LPVOID
addr
,
size_t
size
,
BOOL
zero
);
BOOL
PurgePages
(
LPVOID
addr
,
size_t
length
);
#endif
BOOL
FreeHeapBlock
(
LPVOID
addr
,
size_t
size
);
// for no persistence optimization/feature
extern
void
*
(
*
g_malloc
)(
size_t
);
extern
void
*
(
*
g_calloc
)(
size_t
,
size_t
);
extern
void
*
(
*
g_realloc
)(
void
*
,
size_t
);
extern
void
(
*
g_free
)(
void
*
);
extern
size_t
(
*
g_msize
)(
void
*
);
#ifndef NO_QFORKIMPL
#ifdef QFORK_MAIN_IMPL
int
redis_main
(
int
argc
,
char
**
argv
);
...
...
src/Win32_Interop/Win32_dlmalloc.c
浏览文件 @
1ff98040
...
...
@@ -542,6 +542,7 @@ MAX_RELEASE_CHECK_RATE default: 4095 unless not HAVE_MMAP
improvement at the expense of carrying around more memory.
*/
#ifdef USE_DLMALLOC
#include "win32_types.h"
/* Version identifier to allow people to support multiple versions */
...
...
@@ -1693,7 +1694,9 @@ static int dev_zero_fd = -1; /* Cached file descriptor for /dev/zero. */
#else
/* WIN32 */
#ifdef USE_DLMALLOC
#define USE_COW
#endif
/* Win32 MMAP via VirtualAlloc */
static
FORCEINLINE
void
*
win32mmap
(
size_t
size
)
{
...
...
@@ -6029,6 +6032,8 @@ int SetDLMallocGlobalState(size_t bufferSize, LPVOID buffer) {
}
}
#endif
/* USE_DLMALLOC */
/* -------------------- Alternative MORECORE functions ------------------- */
/*
...
...
src/Win32_Interop/Win32_dlmalloc.h
浏览文件 @
1ff98040
...
...
@@ -41,6 +41,7 @@
* If MSPACES is defined, declarations for mspace versions are included.
*/
#ifdef USE_DLMALLOC
#ifndef MALLOC_280_H
#define MALLOC_280_H
...
...
@@ -651,3 +652,4 @@ void mspace_inspect_all(mspace msp,
#endif
#endif
/* MALLOC_280_H */
#endif
/* USE_DLMALLOC */
\ No newline at end of file
src/networking.c
浏览文件 @
1ff98040
...
...
@@ -1801,7 +1801,7 @@ int checkClientOutputBufferLimits(redisClient *c) {
* called from contexts where the client can't be freed safely, i.e. from the
* lower level functions pushing data inside the client output buffers. */
void
asyncCloseClientOnOutputBufferLimitReached
(
redisClient
*
c
)
{
redisAssert
(
c
->
reply_bytes
<
PORT_ULONG_MAX
-
(
1024
*
64
));
POSIX_ONLY
(
redisAssert
(
c
->
reply_bytes
<
PORT_ULONG_MAX
-
(
1024
*
64
));)
if
(
c
->
reply_bytes
==
0
||
c
->
flags
&
REDIS_CLOSE_ASAP
)
return
;
if
(
checkClientOutputBufferLimits
(
c
))
{
sds
client
=
catClientInfoString
(
sdsempty
(),
c
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录