Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
VisualDL
提交
64b0f375
V
VisualDL
项目概览
PaddlePaddle
/
VisualDL
1 年多 前同步成功
通知
88
Star
4655
Fork
642
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
10
列表
看板
标记
里程碑
合并请求
2
Wiki
5
Wiki
分析
仓库
DevOps
项目成员
Pages
V
VisualDL
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
10
Issue
10
列表
看板
标记
里程碑
合并请求
2
合并请求
2
Pages
分析
分析
仓库分析
DevOps
Wiki
5
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
64b0f375
编写于
11月 28, 2017
作者:
S
superjom
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rename InformationMaintainer to IM
上级
00156734
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
34 addition
and
22 deletion
+34
-22
visualdl/backend/logic/im.cc
visualdl/backend/logic/im.cc
+5
-7
visualdl/backend/logic/im.h
visualdl/backend/logic/im.h
+5
-5
visualdl/backend/logic/im_test.cc
visualdl/backend/logic/im_test.cc
+1
-1
visualdl/backend/logic/sdk.cc
visualdl/backend/logic/sdk.cc
+1
-3
visualdl/backend/logic/sdk.h
visualdl/backend/logic/sdk.h
+4
-6
visualdl/backend/storage/storage.cc
visualdl/backend/storage/storage.cc
+18
-0
未找到文件。
visualdl/backend/logic/im.cc
浏览文件 @
64b0f375
...
...
@@ -25,20 +25,18 @@ int ReserviorSample(int num_samples, int num_records) {
return
-
1
;
}
void
I
nformationMaintainer
::
SetPersistDest
(
const
std
::
string
&
path
)
{
void
I
M
::
SetPersistDest
(
const
std
::
string
&
path
)
{
CHECK
(
storage_
->
mutable_data
()
->
dir
().
empty
())
<<
"duplicate set storage's path"
;
storage_
->
mutable_data
()
->
set_dir
(
path
);
}
storage
::
Tablet
*
InformationMaintainer
::
AddTablet
(
const
std
::
string
&
tag
,
int
num_samples
)
{
storage
::
Tablet
*
IM
::
AddTablet
(
const
std
::
string
&
tag
,
int
num_samples
)
{
auto
tablet
=
storage_
->
NewTablet
(
tag
,
num_samples
);
return
tablet
;
}
void
InformationMaintainer
::
AddRecord
(
const
std
::
string
&
tag
,
const
storage
::
Record
&
data
)
{
void
IM
::
AddRecord
(
const
std
::
string
&
tag
,
const
storage
::
Record
&
data
)
{
auto
*
tablet
=
storage_
->
tablet
(
tag
);
CHECK
(
tablet
)
<<
"no tablet called "
<<
tag
;
...
...
@@ -65,14 +63,14 @@ void InformationMaintainer::AddRecord(const std::string &tag,
tablet
->
set_total_records
(
num_records
+
1
);
}
void
I
nformationMaintainer
::
Clear
()
{
void
I
M
::
Clear
()
{
auto
*
data
=
storage
().
mutable_data
();
data
->
clear_tablets
();
data
->
clear_dir
();
data
->
clear_timestamp
();
}
void
I
nformationMaintainer
::
PersistToDisk
()
{
void
I
M
::
PersistToDisk
()
{
CHECK
(
!
storage_
->
data
().
dir
().
empty
())
<<
"path of storage should be set"
;
// TODO make dir first
// MakeDir(storage_.data().dir());
...
...
visualdl/backend/logic/im.h
浏览文件 @
64b0f375
...
...
@@ -10,7 +10,7 @@
namespace
visualdl
{
/*
* I
nformationMaintainer
(IM) maintain the Storage singleton in memory,
* I
M
(IM) maintain the Storage singleton in memory,
* pre-compute some the statistical information to help visualizaton.
*
* There should be two processes and each have an IM, one is the web server
...
...
@@ -24,9 +24,9 @@ namespace visualdl {
* The SDK's IM will maintain the changes and periodically write to disk, and
* the web server's IM will periodically read latest storage from disk.
*/
class
I
nformationMaintainer
final
{
class
I
M
final
{
public:
I
nformationMaintainer
(
StorageBase
::
Type
type
=
StorageBase
::
Type
::
kMemory
)
{
I
M
(
StorageBase
::
Type
type
=
StorageBase
::
Type
::
kMemory
)
{
switch
(
type
)
{
case
StorageBase
::
Type
::
kMemory
:
storage_
.
reset
(
new
MemoryStorage
);
...
...
@@ -36,8 +36,8 @@ public:
}
}
static
I
nformationMaintainer
&
Global
()
{
static
I
nformationMaintainer
*
x
=
new
InformationMaintainer
();
static
I
M
&
Global
()
{
static
I
M
*
x
=
new
IM
();
return
*
x
;
}
...
...
visualdl/backend/logic/im_test.cc
浏览文件 @
64b0f375
...
...
@@ -8,7 +8,7 @@ class ImTester : public ::testing::Test {
protected:
void
SetUp
()
override
{}
I
nformationMaintainer
&
im
=
InformationMaintainer
::
Global
();
I
M
&
im
=
IM
::
Global
();
};
TEST_F
(
ImTester
,
AddTablet
)
{
...
...
visualdl/backend/logic/sdk.cc
浏览文件 @
64b0f375
...
...
@@ -60,9 +60,7 @@ std::string TabletHelper::human_readable_buffer() const {
return
buffer
;
}
void
ImHelper
::
PersistToDisk
()
const
{
InformationMaintainer
::
Global
().
PersistToDisk
();
}
void
ImHelper
::
PersistToDisk
()
const
{
IM
::
Global
().
PersistToDisk
();
}
// implementations for components
namespace
components
{
...
...
visualdl/backend/logic/sdk.h
浏览文件 @
64b0f375
...
...
@@ -94,18 +94,16 @@ public:
ImHelper
()
{}
StorageHelper
storage
()
{
return
StorageHelper
(
InformationMaintainer
::
Global
().
storage
().
mutable_data
());
return
StorageHelper
(
IM
::
Global
().
storage
().
mutable_data
());
}
TabletHelper
tablet
(
const
std
::
string
&
tag
)
{
return
TabletHelper
(
I
nformationMaintainer
::
Global
().
storage
().
tablet
(
tag
));
return
TabletHelper
(
I
M
::
Global
().
storage
().
tablet
(
tag
));
}
TabletHelper
AddTablet
(
const
std
::
string
&
tag
,
int
num_samples
)
{
return
TabletHelper
(
InformationMaintainer
::
Global
().
AddTablet
(
tag
,
num_samples
));
return
TabletHelper
(
IM
::
Global
().
AddTablet
(
tag
,
num_samples
));
}
void
ClearTablets
()
{
I
nformationMaintainer
::
Global
().
storage
().
mutable_data
()
->
clear_tablets
();
I
M
::
Global
().
storage
().
mutable_data
()
->
clear_tablets
();
}
void
PersistToDisk
()
const
;
...
...
visualdl/backend/storage/storage.cc
浏览文件 @
64b0f375
#include <glog/logging.h>
#include <visualdl/backend/utils/concurrency.h>
#include <fstream>
#include "visualdl/backend/storage/storage.h"
...
...
@@ -72,4 +73,21 @@ void MemoryStorage::LoadFromDisk(const std::string &dir) {
}
}
void
MemoryStorage
::
StartReadService
()
{
cc
::
PeriodExector
::
task_t
task
=
[
this
]
{
LOG
(
INFO
)
<<
"loading from "
<<
storage_
.
dir
();
LoadFromDisk
(
storage_
.
dir
());
return
true
;
};
cc
::
PeriodExector
::
Global
()(
std
::
move
(
task
),
2512
);
}
void
MemoryStorage
::
StartWriteSerice
()
{
cc
::
PeriodExector
::
task_t
task
=
[
this
]
{
LOG
(
INFO
)
<<
"writing to "
<<
storage_
.
dir
();
PersistToDisk
();
return
true
;
};
cc
::
PeriodExector
::
Global
()(
std
::
move
(
task
),
2000
);
}
}
// namespace visualdl
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录