Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
HEPnOS
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sds
HEP
HEPnOS
Commits
1a3f5f7f
Commit
1a3f5f7f
authored
Sep 03, 2019
by
Matthieu Dorier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implemented parallel flush
parent
d7048475
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
4 deletions
+44
-4
include/hepnos/Exception.hpp
include/hepnos/Exception.hpp
+3
-0
src/private/WriteBatchImpl.hpp
src/private/WriteBatchImpl.hpp
+41
-4
No files found.
include/hepnos/Exception.hpp
View file @
1a3f5f7f
...
@@ -17,7 +17,10 @@ class Exception : public std::exception
...
@@ -17,7 +17,10 @@ class Exception : public std::exception
public:
public:
Exception
()
=
default
;
Exception
(
const
std
::
string
&
msg
)
:
m_msg
(
msg
){}
Exception
(
const
std
::
string
&
msg
)
:
m_msg
(
msg
){}
Exception
(
const
Exception
&
)
=
default
;
Exception
&
operator
=
(
const
Exception
&
)
=
default
;
virtual
const
char
*
what
()
const
noexcept
override
virtual
const
char
*
what
()
const
noexcept
override
{
{
...
...
src/private/WriteBatchImpl.hpp
View file @
1a3f5f7f
...
@@ -17,6 +17,29 @@ namespace hepnos {
...
@@ -17,6 +17,29 @@ namespace hepnos {
class
WriteBatch
::
Impl
{
class
WriteBatch
::
Impl
{
struct
writer_thread_args
{
unsigned
long
db_idx
=
0
;
std
::
pair
<
std
::
vector
<
std
::
string
>
,
std
::
vector
<
std
::
string
>>*
keyvals
=
nullptr
;
Impl
*
batch
=
nullptr
;
Exception
ex
;
bool
ok
=
true
;
};
static
void
writer_thread
(
void
*
x
)
{
writer_thread_args
*
args
=
static_cast
<
writer_thread_args
*>
(
x
);
auto
batch
=
args
->
batch
;
auto
db_idx
=
args
->
db_idx
;
auto
keyvals
=
args
->
keyvals
;
const
auto
&
keys
=
keyvals
->
first
;
const
auto
&
vals
=
keyvals
->
second
;
try
{
batch
->
m_datastore
->
m_impl
->
storeMultiple
(
db_idx
,
keys
,
vals
);
}
catch
(
Exception
&
ex
)
{
args
->
ok
=
false
;
args
->
ex
=
ex
;
}
}
public:
public:
DataStore
*
m_datastore
;
DataStore
*
m_datastore
;
...
@@ -46,12 +69,26 @@ class WriteBatch::Impl {
...
@@ -46,12 +69,26 @@ class WriteBatch::Impl {
}
}
void
flush
()
{
void
flush
()
{
for
(
const
auto
&
e
:
m_entries
)
{
ABT_xstream
es
=
ABT_XSTREAM_NULL
;
ABT_xstream_self
(
&
es
);
auto
num_threads
=
m_entries
.
size
();
std
::
vector
<
ABT_thread
>
threads
(
num_threads
);
std
::
vector
<
writer_thread_args
>
args
(
num_threads
);
unsigned
i
=
0
;
for
(
auto
&
e
:
m_entries
)
{
auto
db_idx
=
e
.
first
;
auto
db_idx
=
e
.
first
;
const
auto
&
keys
=
e
.
second
.
first
;
args
[
i
].
db_idx
=
e
.
first
;
const
auto
&
vals
=
e
.
second
.
second
;
args
[
i
].
batch
=
this
;
m_datastore
->
m_impl
->
storeMultiple
(
db_idx
,
keys
,
vals
);
args
[
i
].
keyvals
=
&
e
.
second
;
ABT_thread_create_on_xstream
(
es
,
&
writer_thread
,
&
args
[
i
],
ABT_THREAD_ATTR_NULL
,
&
threads
[
i
]);
i
+=
1
;
}
ABT_thread_join_many
(
num_threads
,
threads
.
data
());
ABT_thread_free_many
(
num_threads
,
threads
.
data
());
for
(
auto
&
a
:
args
)
{
if
(
not
a
.
ok
)
throw
a
.
ex
;
}
}
m_entries
.
clear
();
}
}
~
Impl
()
{
~
Impl
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment