Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
a894288f
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,发现更多精彩内容 >>
提交
a894288f
编写于
8月 29, 2019
作者:
A
Alexey Milovidov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fallback from O_DIRECT.
上级
06ea75f9
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
42 addition
and
33 deletion
+42
-33
dbms/src/Common/ProfileEvents.cpp
dbms/src/Common/ProfileEvents.cpp
+2
-0
dbms/src/IO/createReadBufferFromFileBase.cpp
dbms/src/IO/createReadBufferFromFileBase.cpp
+20
-16
dbms/src/IO/createWriteBufferFromFileBase.cpp
dbms/src/IO/createWriteBufferFromFileBase.cpp
+20
-17
未找到文件。
dbms/src/Common/ProfileEvents.cpp
浏览文件 @
a894288f
...
...
@@ -36,8 +36,10 @@
M(MarkCacheMisses, "") \
M(CreatedReadBufferOrdinary, "") \
M(CreatedReadBufferAIO, "") \
M(CreatedReadBufferAIOFailed, "") \
M(CreatedWriteBufferOrdinary, "") \
M(CreatedWriteBufferAIO, "") \
M(CreatedWriteBufferAIOFailed, "") \
M(DiskReadElapsedMicroseconds, "Total time spent waiting for read syscall. This include reads from page cache.") \
M(DiskWriteElapsedMicroseconds, "Total time spent waiting for write syscall. This include writes to page cache.") \
M(NetworkReceiveElapsedMicroseconds, "") \
...
...
dbms/src/IO/createReadBufferFromFileBase.cpp
浏览文件 @
a894288f
...
...
@@ -10,34 +10,38 @@ namespace ProfileEvents
{
extern
const
Event
CreatedReadBufferOrdinary
;
extern
const
Event
CreatedReadBufferAIO
;
extern
const
Event
CreatedReadBufferAIOFailed
;
}
namespace
DB
{
#if !defined(__linux__)
namespace
ErrorCodes
{
extern
const
int
NOT_IMPLEMENTED
;
}
#endif
std
::
unique_ptr
<
ReadBufferFromFileBase
>
createReadBufferFromFileBase
(
const
std
::
string
&
filename_
,
size_t
estimated_size
,
size_t
aio_threshold
,
size_t
buffer_size_
,
int
flags_
,
char
*
existing_memory_
,
size_t
alignment
)
{
if
((
aio_threshold
==
0
)
||
(
estimated_size
<
aio_threshold
))
#if defined(__linux__) || defined(__FreeBSD__)
if
(
aio_threshold
&&
estimated_size
>=
aio_threshold
)
{
ProfileEvents
::
increment
(
ProfileEvents
::
CreatedReadBufferOrdinary
);
return
std
::
make_unique
<
ReadBufferFromFile
>
(
filename_
,
buffer_size_
,
flags_
,
existing_memory_
,
alignment
);
/// Attempt to open a file with O_DIRECT
try
{
auto
res
=
std
::
make_unique
<
ReadBufferAIO
>
(
filename_
,
buffer_size_
,
flags_
,
existing_memory_
);
ProfileEvents
::
increment
(
ProfileEvents
::
CreatedReadBufferAIO
);
return
res
;
}
catch
(
const
ErrnoException
&
)
{
/// Fallback to cached IO if O_DIRECT is not supported.
ProfileEvents
::
increment
(
ProfileEvents
::
CreatedReadBufferAIOFailed
);
}
}
else
{
#if defined(__linux__) || defined(__FreeBSD__)
ProfileEvents
::
increment
(
ProfileEvents
::
CreatedReadBufferAIO
);
return
std
::
make_unique
<
ReadBufferAIO
>
(
filename_
,
buffer_size_
,
flags_
,
existing_memory_
);
#else
throw
Exception
(
"AIO is implemented only on Linux and FreeBSD"
,
ErrorCodes
::
NOT_IMPLEMENTED
);
(
void
)
aio_threshold
;
(
void
)
estimated_size
;
#endif
}
ProfileEvents
::
increment
(
ProfileEvents
::
CreatedReadBufferOrdinary
);
return
std
::
make_unique
<
ReadBufferFromFile
>
(
filename_
,
buffer_size_
,
flags_
,
existing_memory_
,
alignment
);
}
}
dbms/src/IO/createWriteBufferFromFileBase.cpp
浏览文件 @
a894288f
...
...
@@ -10,36 +10,39 @@ namespace ProfileEvents
{
extern
const
Event
CreatedWriteBufferOrdinary
;
extern
const
Event
CreatedWriteBufferAIO
;
extern
const
Event
CreatedWriteBufferAIOFailed
;
}
namespace
DB
{
#if !defined(__linux__)
namespace
ErrorCodes
{
extern
const
int
NOT_IMPLEMENTED
;
}
#endif
std
::
unique_ptr
<
WriteBufferFromFileBase
>
createWriteBufferFromFileBase
(
const
std
::
string
&
filename_
,
size_t
estimated_size
,
size_t
aio_threshold
,
size_t
buffer_size_
,
int
flags_
,
mode_t
mode
,
char
*
existing_memory_
,
size_t
alignment
)
{
if
((
aio_threshold
==
0
)
||
(
estimated_size
<
aio_threshold
))
#if defined(__linux__) || defined(__FreeBSD__)
if
(
aio_threshold
&&
estimated_size
>=
aio_threshold
)
{
ProfileEvents
::
increment
(
ProfileEvents
::
CreatedWriteBufferOrdinary
);
return
std
::
make_unique
<
WriteBufferFromFile
>
(
filename_
,
buffer_size_
,
flags_
,
mode
,
existing_memory_
,
alignment
);
/// Attempt to open a file with O_DIRECT
try
{
auto
res
=
std
::
make_unique
<
WriteBufferAIO
>
(
filename_
,
buffer_size_
,
flags_
,
mode
,
existing_memory_
);
ProfileEvents
::
increment
(
ProfileEvents
::
CreatedWriteBufferAIO
);
return
res
;
}
catch
(
const
ErrnoException
&
)
{
/// Fallback to cached IO if O_DIRECT is not supported.
ProfileEvents
::
increment
(
ProfileEvents
::
CreatedWriteBufferAIOFailed
);
}
}
else
{
#if defined(__linux__) || defined(__FreeBSD__)
ProfileEvents
::
increment
(
ProfileEvents
::
CreatedWriteBufferAIO
);
return
std
::
make_unique
<
WriteBufferAIO
>
(
filename_
,
buffer_size_
,
flags_
,
mode
,
existing_memory_
);
#else
throw
Exception
(
"AIO is implemented only on Linux and FreeBSD"
,
ErrorCodes
::
NOT_IMPLEMENTED
);
(
void
)
aio_threshold
;
(
void
)
estimated_size
;
#endif
}
ProfileEvents
::
increment
(
ProfileEvents
::
CreatedWriteBufferOrdinary
);
return
std
::
make_unique
<
WriteBufferFromFile
>
(
filename_
,
buffer_size_
,
flags_
,
mode
,
existing_memory_
,
alignment
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录