Skip to content
GitLab
菜单
为什么选择 GitLab
定价
联系销售
探索
为什么选择 GitLab
定价
联系销售
探索
登录
获取免费试用
主导航
搜索或转到…
项目
Z
zstd
管理
动态
成员
标记
计划
议题
议题看板
里程碑
Wiki
代码
合并请求
仓库
分支
提交
标签
仓库图
比较修订版本
代码片段
构建
流水线
作业
流水线计划
产物
部署
发布
Package registry
Container registry
模型注册表
运维
环境
Terraform 模块
监控
事件
服务台
分析
价值流分析
贡献者分析
CI/CD 分析
仓库分析
模型实验
帮助
帮助
支持
GitLab 文档
比较 GitLab 各版本
社区论坛
为极狐GitLab 提交贡献
提交反馈
隐私声明
快捷键
?
新增功能
4
代码片段
群组
项目
显示更多面包屑
Xayah
zstd
提交
6455ec48
提交
6455ec48
编辑于
7 years ago
作者:
Paul Cruz
浏览文件
操作
下载
补丁
差异文件
taking the maximum of the completion level reads in order to determine which one was waiting more
上级
05fe8dd4
No related branches found
No related tags found
无相关合并请求
变更
1
隐藏空白变更内容
行内
左右并排
显示
1 个更改的文件
contrib/adaptive-compression/adapt.c
+16
-9
16 个添加, 9 个删除
contrib/adaptive-compression/adapt.c
有
16 个添加
和
9 个删除
contrib/adaptive-compression/adapt.c
+
16
−
9
浏览文件 @
6455ec48
...
...
@@ -354,23 +354,29 @@ static void adaptCompressionLevel(adaptCCtx* ctx)
if
(
1
-
createWaitCompressionCompletion
>
threshold
&&
1
-
writeWaitCompressionCompletion
>
threshold
)
{
/* both create and write threads waiting on compression */
/* use writeWaitCompressionCompletion */
unsigned
const
change
=
(
unsigned
)((
1
-
writeWaitCompressionCompletion
)
*
MAX_COMPRESSION_LEVEL_CHANGE
);
double
const
completion
=
MAX
(
createWaitCompressionCompletion
,
writeWaitCompressionCompletion
);
unsigned
const
change
=
(
unsigned
)((
1
-
completion
)
*
MAX_COMPRESSION_LEVEL_CHANGE
);
unsigned
const
boundChange
=
MIN
(
change
,
ctx
->
compressionLevel
-
1
);
ctx
->
compressionLevel
-=
boundChange
;
DEBUG
(
2
,
"create and write threads waiting, tried to decrease compression level by %u
\n
"
,
boundChange
);
}
else
if
(
1
-
createWaitWriteCompletion
>
threshold
&&
1
-
compressWaitWriteCompletion
>
threshold
)
{
/* both create and compression thread waiting on write */
/* use createWaitWriteCompletion */
unsigned
const
change
=
(
unsigned
)((
1
-
createWaitWriteCompletion
)
*
MAX_COMPRESSION_LEVEL_CHANGE
);
double
const
completion
=
MAX
(
createWaitWriteCompletion
,
compressWaitWriteCompletion
);
unsigned
const
change
=
(
unsigned
)((
1
-
completion
)
*
MAX_COMPRESSION_LEVEL_CHANGE
);
unsigned
const
boundChange
=
MIN
(
change
,
ZSTD_maxCLevel
()
-
ctx
->
compressionLevel
);
ctx
->
compressionLevel
+=
boundChange
;
DEBUG
(
2
,
"create and compression threads waiting, tried to increase compression level by %u
\n
"
,
boundChange
);
}
else
if
(
1
-
writeWaitCreateCompletion
>
threshold
&&
1
-
compressWaitCreateCompletion
>
threshold
)
{
/* both compression and write waiting on create */
/* use compressWaitCreateCompletion */
unsigned
const
change
=
(
unsigned
)((
1
-
compressWaitCreateCompletion
)
*
MAX_COMPRESSION_LEVEL_CHANGE
);
double
const
completion
=
MAX
(
writeWaitCreateCompletion
,
compressWaitCreateCompletion
);
unsigned
const
change
=
(
unsigned
)((
1
-
completion
)
*
MAX_COMPRESSION_LEVEL_CHANGE
);
unsigned
const
boundChange
=
MIN
(
change
,
ZSTD_maxCLevel
()
-
ctx
->
compressionLevel
);
ctx
->
compressionLevel
+=
boundChange
;
DEBUG
(
2
,
"compression and write threads waiting, tried to increase compression level by %u
\n
"
,
boundChange
);
}
if
(
g_forceCompressionLevel
)
{
...
...
@@ -404,8 +410,8 @@ static void* compressionThread(void* arg)
ctx
->
compressWaitWriteCompletion
=
ctx
->
writeCompletion
;
DEBUG
(
3
,
"compression thread waiting : compressWaitCreateCompletion %f : compressWaitWriteCompletion %f
\n
"
,
ctx
->
compressWaitCreateCompletion
,
ctx
->
compressWaitWriteCompletion
);
DEBUG
(
3
,
"create completion: %f
\n
"
,
ctx
->
createCompletion
);
DEBUG
(
2
,
"compression thread waiting for nextJob: %u, compressWaitCreateCompletion %f, compressWaitWriteCompletion %f
\n
"
,
currJob
,
ctx
->
compressWaitCreateCompletion
,
ctx
->
compressWaitWriteCompletion
);
pthread_mutex_unlock
(
&
ctx
->
completion_mutex
.
pMutex
);
DEBUG
(
2
,
"waiting on job ready, nextJob: %u
\n
"
,
currJob
);
pthread_cond_wait
(
&
ctx
->
jobReady_cond
.
pCond
,
&
ctx
->
jobReady_mutex
.
pMutex
);
}
pthread_mutex_unlock
(
&
ctx
->
jobReady_mutex
.
pMutex
);
...
...
@@ -422,6 +428,7 @@ static void* compressionThread(void* arg)
/* adapt compression level */
if
(
currJob
)
adaptCompressionLevel
(
ctx
);
DEBUG
(
2
,
"job %u compressed with level %u
\n
"
,
currJob
,
ctx
->
compressionLevel
);
/* compress the data */
{
size_t
const
compressionBlockSize
=
1
<<
17
;
/* 128 KB */
...
...
@@ -487,7 +494,7 @@ static void* compressionThread(void* arg)
/* update completion */
pthread_mutex_lock
(
&
ctx
->
completion_mutex
.
pMutex
);
ctx
->
compressionCompletion
=
1
-
(
double
)
remaining
/
job
->
src
.
size
;
DEBUG
(
3
,
"compression completion %f
\n
"
,
ctx
->
compressionCompletion
);
DEBUG
(
2
,
"compression completion %f
\n
"
,
ctx
->
compressionCompletion
);
pthread_mutex_unlock
(
&
ctx
->
completion_mutex
.
pMutex
);
}
}
while
(
remaining
!=
0
);
...
...
@@ -545,8 +552,8 @@ static void* outputThread(void* arg)
ctx
->
writeWaitCompressionCompletion
=
ctx
->
compressionCompletion
;
ctx
->
writeWaitCreateCompletion
=
ctx
->
createCompletion
;
DEBUG
(
3
,
"write thread waiting : writeWaitCreateCompletion %f : writeWaitCompressionCompletion %f
\n
"
,
ctx
->
writeWaitCreateCompletion
,
ctx
->
writeWaitCompressionCompletion
);
DEBUG
(
2
,
"writer thread waiting for nextJob: %u, writeWaitCompressionCompletion %f, writeWaitCreateCompletion %f
\n
"
,
currJob
,
ctx
->
writeWaitCompressionCompletion
,
ctx
->
writeWaitCreateCompletion
);
pthread_mutex_unlock
(
&
ctx
->
completion_mutex
.
pMutex
);
DEBUG
(
2
,
"waiting on job compressed, nextJob: %u
\n
"
,
currJob
);
pthread_cond_wait
(
&
ctx
->
jobCompressed_cond
.
pCond
,
&
ctx
->
jobCompressed_mutex
.
pMutex
);
}
pthread_mutex_unlock
(
&
ctx
->
jobCompressed_mutex
.
pMutex
);
...
...
@@ -579,7 +586,7 @@ static void* outputThread(void* arg)
/* update completion variable for writing */
pthread_mutex_lock
(
&
ctx
->
completion_mutex
.
pMutex
);
ctx
->
writeCompletion
=
1
-
(
double
)
remaining
/
compressedSize
;
DEBUG
(
3
,
"write completion %f
\n
"
,
ctx
->
writeCompletion
);
DEBUG
(
2
,
"write completion %f
\n
"
,
ctx
->
writeCompletion
);
pthread_mutex_unlock
(
&
ctx
->
completion_mutex
.
pMutex
);
if
(
remaining
==
0
)
break
;
...
...
@@ -630,8 +637,8 @@ static int createCompressionJob(adaptCCtx* ctx, size_t srcSize, int last)
ctx
->
createWaitWriteCompletion
=
ctx
->
writeCompletion
;
DEBUG
(
3
,
"creation thread waiting : createWaitCompressionCompletion %f : createWaitWriteCompletion %f
\n
"
,
ctx
->
createWaitCompressionCompletion
,
ctx
->
createWaitWriteCompletion
);
DEBUG
(
3
,
"writeCompletion: %f
\n
"
,
ctx
->
writeCompletion
);
DEBUG
(
2
,
"create thread waiting for nextJob: %u, createWaitCompressionCompletion %f, createWaitWriteCompletion %f
\n
"
,
nextJob
,
ctx
->
createWaitCompressionCompletion
,
ctx
->
createWaitWriteCompletion
);
pthread_mutex_unlock
(
&
ctx
->
completion_mutex
.
pMutex
);
DEBUG
(
2
,
"waiting on job Write, nextJob: %u
\n
"
,
nextJob
);
pthread_cond_wait
(
&
ctx
->
jobWrite_cond
.
pCond
,
&
ctx
->
jobWrite_mutex
.
pMutex
);
}
pthread_mutex_unlock
(
&
ctx
->
jobWrite_mutex
.
pMutex
);
...
...
@@ -721,7 +728,7 @@ static int performCompression(adaptCCtx* ctx, FILE* const srcFile, outputThreadA
remaining
-=
ret
;
pthread_mutex_lock
(
&
ctx
->
completion_mutex
.
pMutex
);
ctx
->
createCompletion
=
1
-
(
double
)
remaining
/
((
size_t
)
FILE_CHUNK_SIZE
);
DEBUG
(
3
,
"create completion: %f
\n
"
,
ctx
->
createCompletion
);
DEBUG
(
2
,
"create completion: %f
\n
"
,
ctx
->
createCompletion
);
pthread_mutex_unlock
(
&
ctx
->
completion_mutex
.
pMutex
);
}
if
(
remaining
!=
0
&&
!
feof
(
srcFile
))
{
...
...
此差异已折叠。
点击以展开。
预览
0%
加载中
请重试
或
添加新附件
.
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
保存评论
取消
想要评论请
注册
或
登录