Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
a7090f4f
C
ClickHouse
项目概览
2dot5
/
ClickHouse
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
ClickHouse
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a7090f4f
编写于
10月 17, 2018
作者:
A
Alexey Milovidov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Improved server startup time #2278
上级
aa227795
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
23 addition
and
53 deletion
+23
-53
dbms/src/Databases/DatabaseOrdinary.cpp
dbms/src/Databases/DatabaseOrdinary.cpp
+23
-53
未找到文件。
dbms/src/Databases/DatabaseOrdinary.cpp
浏览文件 @
a7090f4f
...
...
@@ -42,7 +42,6 @@ namespace ErrorCodes
static
constexpr
size_t
PRINT_MESSAGE_EACH_N_TABLES
=
256
;
static
constexpr
size_t
PRINT_MESSAGE_EACH_N_SECONDS
=
5
;
static
constexpr
size_t
METADATA_FILE_BUFFER_SIZE
=
32768
;
static
constexpr
size_t
TABLES_PARALLEL_LOAD_BUNCH_SIZE
=
100
;
namespace
detail
{
...
...
@@ -163,38 +162,25 @@ void DatabaseOrdinary::loadTables(
std
::
atomic
<
size_t
>
tables_processed
{
0
};
Poco
::
Event
all_tables_processed
;
auto
task_function
=
[
&
](
FileNames
::
const_iterator
begin
,
FileNames
::
const_iterator
end
)
auto
task_function
=
[
&
](
const
String
&
table
)
{
for
(
auto
it
=
begin
;
it
!=
end
;
++
it
)
/// Messages, so that it's not boring to wait for the server to load for a long time.
if
((
tables_processed
+
1
)
%
PRINT_MESSAGE_EACH_N_TABLES
==
0
||
watch
.
compareAndRestart
(
PRINT_MESSAGE_EACH_N_SECONDS
))
{
const
String
&
table
=
*
it
;
/// Messages, so that it's not boring to wait for the server to load for a long time.
if
((
tables_processed
+
1
)
%
PRINT_MESSAGE_EACH_N_TABLES
==
0
||
watch
.
compareAndRestart
(
PRINT_MESSAGE_EACH_N_SECONDS
))
{
LOG_INFO
(
log
,
std
::
fixed
<<
std
::
setprecision
(
2
)
<<
tables_processed
*
100.0
/
total_tables
<<
"%"
);
watch
.
restart
();
}
LOG_INFO
(
log
,
std
::
fixed
<<
std
::
setprecision
(
2
)
<<
tables_processed
*
100.0
/
total_tables
<<
"%"
);
watch
.
restart
();
}
loadTable
(
context
,
metadata_path
,
*
this
,
name
,
data_path
,
table
,
has_force_restore_data_flag
);
loadTable
(
context
,
metadata_path
,
*
this
,
name
,
data_path
,
table
,
has_force_restore_data_flag
);
if
(
++
tables_processed
==
total_tables
)
all_tables_processed
.
set
();
}
if
(
++
tables_processed
==
total_tables
)
all_tables_processed
.
set
();
};
const
size_t
bunch_size
=
TABLES_PARALLEL_LOAD_BUNCH_SIZE
;
size_t
num_bunches
=
(
total_tables
+
bunch_size
-
1
)
/
bunch_size
;
for
(
size_t
i
=
0
;
i
<
num_bunches
;
++
i
)
for
(
const
auto
&
filename
:
file_names
)
{
auto
begin
=
file_names
.
begin
()
+
i
*
bunch_size
;
auto
end
=
(
i
+
1
==
num_bunches
)
?
file_names
.
end
()
:
(
file_names
.
begin
()
+
(
i
+
1
)
*
bunch_size
);
auto
task
=
std
::
bind
(
task_function
,
begin
,
end
);
auto
task
=
std
::
bind
(
task_function
,
filename
);
if
(
thread_pool
)
thread_pool
->
schedule
(
task
);
...
...
@@ -219,45 +205,29 @@ void DatabaseOrdinary::startupTables(ThreadPool * thread_pool)
size_t
total_tables
=
tables
.
size
();
Poco
::
Event
all_tables_processed
;
auto
task_function
=
[
&
](
Tables
::
iterator
begin
,
Tables
::
iterator
end
)
auto
task_function
=
[
&
](
const
StoragePtr
&
table
)
{
for
(
auto
it
=
begin
;
it
!=
end
;
++
it
)
if
((
tables_processed
+
1
)
%
PRINT_MESSAGE_EACH_N_TABLES
==
0
||
watch
.
compareAndRestart
(
PRINT_MESSAGE_EACH_N_SECONDS
))
{
if
((
tables_processed
+
1
)
%
PRINT_MESSAGE_EACH_N_TABLES
==
0
||
watch
.
compareAndRestart
(
PRINT_MESSAGE_EACH_N_SECONDS
))
{
LOG_INFO
(
log
,
std
::
fixed
<<
std
::
setprecision
(
2
)
<<
tables_processed
*
100.0
/
total_tables
<<
"%"
);
watch
.
restart
();
}
LOG_INFO
(
log
,
std
::
fixed
<<
std
::
setprecision
(
2
)
<<
tables_processed
*
100.0
/
total_tables
<<
"%"
);
watch
.
restart
();
}
it
->
second
->
startup
();
table
->
startup
();
if
(
++
tables_processed
==
total_tables
)
all_tables_processed
.
set
();
}
if
(
++
tables_processed
==
total_tables
)
all_tables_processed
.
set
();
};
const
size_t
bunch_size
=
TABLES_PARALLEL_LOAD_BUNCH_SIZE
;
size_t
num_bunches
=
(
total_tables
+
bunch_size
-
1
)
/
bunch_size
;
auto
begin
=
tables
.
begin
();
for
(
size_t
i
=
0
;
i
<
num_bunches
;
++
i
)
for
(
const
auto
&
name_storage
:
tables
)
{
auto
end
=
begin
;
if
(
i
+
1
==
num_bunches
)
end
=
tables
.
end
();
else
std
::
advance
(
end
,
bunch_size
);
auto
task
=
std
::
bind
(
task_function
,
begin
,
end
);
auto
task
=
std
::
bind
(
task_function
,
name_storage
.
second
);
if
(
thread_pool
)
thread_pool
->
schedule
(
task
);
else
task
();
begin
=
end
;
}
if
(
thread_pool
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录