Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
hpdos
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
SYNERG
hpdos
Commits
be7dea1a
Commit
be7dea1a
authored
Jun 07, 2022
by
Paras Garg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added common cqevents list to wait for replication
parent
9454fb43
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
34 deletions
+52
-34
code/cppfol/header/Executor.hpp
code/cppfol/header/Executor.hpp
+2
-0
code/cppfol/header/TaskThread.hpp
code/cppfol/header/TaskThread.hpp
+8
-7
code/cppfol/src/Executor.cpp
code/cppfol/src/Executor.cpp
+1
-1
code/cppfol/src/TaskThread.cpp
code/cppfol/src/TaskThread.cpp
+41
-26
No files found.
code/cppfol/header/Executor.hpp
View file @
be7dea1a
...
@@ -5,12 +5,14 @@
...
@@ -5,12 +5,14 @@
#include "RdmaEndpointGroup.hpp"
#include "RdmaEndpointGroup.hpp"
#include "TaskThread.hpp"
#include "TaskThread.hpp"
#include "Logger.hpp"
#include "Logger.hpp"
#include "CqEventData.hpp"
class
Executor
class
Executor
{
{
int
_size
{
0
};
int
_size
{
0
};
std
::
vector
<
TaskThread
*>
_taskThreads
{
NULL
};
std
::
vector
<
TaskThread
*>
_taskThreads
{
NULL
};
ConcurrentQueue
*
_taskQueue
{
NULL
};
ConcurrentQueue
*
_taskQueue
{
NULL
};
std
::
unordered_map
<
uint32_t
,
std
::
shared_ptr
<
CQEventData
>>
cqEvents
;
public:
public:
Executor
(
int
size
);
Executor
(
int
size
);
...
...
code/cppfol/header/TaskThread.hpp
View file @
be7dea1a
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
#include <iostream>
#include <iostream>
#include <queue>
#include <queue>
#include <pthread.h>
#include <pthread.h>
#include<memory>
#include
<memory>
#include "Runnable.hpp"
#include "Runnable.hpp"
#include "CqEventData.hpp"
#include "CqEventData.hpp"
...
@@ -13,7 +13,6 @@
...
@@ -13,7 +13,6 @@
#include "ConcurrentQueue.hpp"
#include "ConcurrentQueue.hpp"
#include "RdmaRepEndpoint.hpp"
#include "RdmaRepEndpoint.hpp"
#include "RdmaSalEndpoint.hpp"
#include "RdmaSalEndpoint.hpp"
#include "CqEventData.hpp"
class
TaskThread
class
TaskThread
{
{
...
@@ -26,20 +25,22 @@ private:
...
@@ -26,20 +25,22 @@ private:
std
::
unordered_map
<
uint32_t
,
RdmaRepEndpoint
*>
*
_clientRepMap
;
std
::
unordered_map
<
uint32_t
,
RdmaRepEndpoint
*>
*
_clientRepMap
;
std
::
unordered_map
<
uint32_t
,
RdmaRepEndpoint
*>
*
_serverRepMap
;
std
::
unordered_map
<
uint32_t
,
RdmaRepEndpoint
*>
*
_serverRepMap
;
std
::
unordered_map
<
uint32_t
,
RdmaSalEndpoint
*>
*
_salMap
;
std
::
unordered_map
<
uint32_t
,
RdmaSalEndpoint
*>
*
_salMap
;
std
::
unordered_map
<
uint32_t
,
std
::
shared_ptr
<
CQEventData
>>
cqEvents
;
std
::
unordered_map
<
uint32_t
,
std
::
shared_ptr
<
CQEventData
>>
&
_
cqEvents
;
public:
public:
TaskThread
(
int
id
,
int
cpu
,
ConcurrentQueue
*
,
TaskThread
(
int
id
,
int
cpu
,
ConcurrentQueue
*
,
std
::
unordered_map
<
uint32_t
,
RdmaRepEndpoint
*>
*
clientRepMap
,
std
::
unordered_map
<
uint32_t
,
RdmaRepEndpoint
*>
*
clientRepMap
,
std
::
unordered_map
<
uint32_t
,
RdmaRepEndpoint
*>
*
serverRepMap
,
std
::
unordered_map
<
uint32_t
,
RdmaRepEndpoint
*>
*
serverRepMap
,
std
::
unordered_map
<
uint32_t
,
RdmaSalEndpoint
*>
*
salMap
);
std
::
unordered_map
<
uint32_t
,
RdmaSalEndpoint
*>
*
salMap
,
std
::
unordered_map
<
uint32_t
,
std
::
shared_ptr
<
CQEventData
>>
&
cqEvents
);
void
replicateSalRequest
(
char
*
salRequest
,
uint32_t
size
);
void
replicateSalRequest
(
char
*
salRequest
,
uint32_t
size
);
void
sendInvalidation
(
char
*
salRequest
);
static
void
*
run
(
void
*
object
);
static
void
*
run
(
void
*
object
);
void
stop
();
void
stop
();
void
processEvent
(
RdmaSalEndpoint
*
ep
,
struct
ibv_wc
*
data
);
void
processEvent
(
RdmaSalEndpoint
*
ep
,
struct
ibv_wc
*
data
);
void
processRepEvent
(
RdmaRepEndpoint
*
ep
,
struct
ibv_wc
*
data
);
void
processRepEvent
(
RdmaRepEndpoint
*
ep
,
struct
ibv_wc
*
data
);
void
processReplicationDone
(
uint32_t
reqid
);
void
processReplicationDone
(
uint32_t
reqid
,
MessageType
type
,
bool
localWrite
);
~
TaskThread
();
~
TaskThread
();
};
};
...
...
code/cppfol/src/Executor.cpp
View file @
be7dea1a
...
@@ -12,7 +12,7 @@ void Executor::createThreads(std::unordered_map<uint32_t, RdmaRepEndpoint *> *cl
...
@@ -12,7 +12,7 @@ void Executor::createThreads(std::unordered_map<uint32_t, RdmaRepEndpoint *> *cl
{
{
for
(
int
i
=
0
;
i
<
_size
;
i
++
)
for
(
int
i
=
0
;
i
<
_size
;
i
++
)
{
{
TaskThread
*
thread
=
new
TaskThread
(
i
,
i
,
_taskQueue
,
clientRepMap
,
serverRepMap
,
salMap
);
TaskThread
*
thread
=
new
TaskThread
(
i
,
i
,
_taskQueue
,
clientRepMap
,
serverRepMap
,
salMap
,
cqEvents
);
_taskThreads
.
push_back
(
thread
);
_taskThreads
.
push_back
(
thread
);
}
}
}
}
...
...
code/cppfol/src/TaskThread.cpp
View file @
be7dea1a
...
@@ -3,8 +3,9 @@
...
@@ -3,8 +3,9 @@
TaskThread
::
TaskThread
(
int
id
,
int
cpu
,
ConcurrentQueue
*
taskqueue
,
TaskThread
::
TaskThread
(
int
id
,
int
cpu
,
ConcurrentQueue
*
taskqueue
,
std
::
unordered_map
<
uint32_t
,
RdmaRepEndpoint
*>
*
clientRepMap
,
std
::
unordered_map
<
uint32_t
,
RdmaRepEndpoint
*>
*
clientRepMap
,
std
::
unordered_map
<
uint32_t
,
RdmaRepEndpoint
*>
*
serverRepMap
,
std
::
unordered_map
<
uint32_t
,
RdmaRepEndpoint
*>
*
serverRepMap
,
std
::
unordered_map
<
uint32_t
,
RdmaSalEndpoint
*>
*
salMap
)
std
::
unordered_map
<
uint32_t
,
RdmaSalEndpoint
*>
*
salMap
,
:
_id
(
id
),
_clientRepMap
(
clientRepMap
),
_serverRepMap
(
serverRepMap
),
_salMap
(
salMap
)
std
::
unordered_map
<
uint32_t
,
std
::
shared_ptr
<
CQEventData
>>
&
cqEvents
)
:
_id
(
id
),
_clientRepMap
(
clientRepMap
),
_serverRepMap
(
serverRepMap
),
_salMap
(
salMap
),
_cqEvents
(
cqEvents
)
{
{
_taskQueue
=
taskqueue
;
_taskQueue
=
taskqueue
;
if
(
pthread_create
(
&
thread
,
NULL
,
&
TaskThread
::
run
,
this
))
if
(
pthread_create
(
&
thread
,
NULL
,
&
TaskThread
::
run
,
this
))
...
@@ -105,7 +106,7 @@ inline void *TaskThread::run(void *object)
...
@@ -105,7 +106,7 @@ inline void *TaskThread::run(void *object)
void
TaskThread
::
processEvent
(
RdmaSalEndpoint
*
ep
,
struct
ibv_wc
*
data
)
void
TaskThread
::
processEvent
(
RdmaSalEndpoint
*
ep
,
struct
ibv_wc
*
data
)
{
{
std
::
cout
<<
"processing sal event"
<<
data
->
opcode
<<
"
\n
"
;
std
::
cout
<<
"processing sal event"
<<
data
->
opcode
<<
"
\n
"
;
/* sal Request*/
/* sal Request*/
switch
(
data
->
opcode
)
switch
(
data
->
opcode
)
{
{
...
@@ -120,7 +121,7 @@ void TaskThread::processEvent(RdmaSalEndpoint *ep, struct ibv_wc *data)
...
@@ -120,7 +121,7 @@ void TaskThread::processEvent(RdmaSalEndpoint *ep, struct ibv_wc *data)
rdma_post_recv
(
ep
->
_cm_id
,
(
void
*
)
data
->
wr_id
,
(
void
*
)
data
->
wr_id
,
rdma_post_recv
(
ep
->
_cm_id
,
(
void
*
)
data
->
wr_id
,
(
void
*
)
data
->
wr_id
,
ep
->
_recvMsgSize
,
ep
->
_recvMr
);
ep
->
_recvMsgSize
,
ep
->
_recvMr
);
struct
MessageHeader
*
req
=
(
struct
MessageHeader
*
)
buffer
;
struct
MessageHeader
*
req
=
(
struct
MessageHeader
*
)
buffer
;
std
::
cout
<<
"recv"
<<
req
->
type
<<
"
\n
"
;
std
::
cout
<<
"recv"
<<
req
->
type
<<
"
\n
"
;
std
::
shared_ptr
<
CQEventData
>
cqevent
=
std
::
make_shared
<
CQEventData
>
(
_serverRepMap
->
size
()
+
_clientRepMap
->
size
(),
ep
);
std
::
shared_ptr
<
CQEventData
>
cqevent
=
std
::
make_shared
<
CQEventData
>
(
_serverRepMap
->
size
()
+
_clientRepMap
->
size
(),
ep
);
uint32_t
id
=
req
->
id
;
uint32_t
id
=
req
->
id
;
/*
/*
...
@@ -133,15 +134,22 @@ void TaskThread::processEvent(RdmaSalEndpoint *ep, struct ibv_wc *data)
...
@@ -133,15 +134,22 @@ void TaskThread::processEvent(RdmaSalEndpoint *ep, struct ibv_wc *data)
ep
->
processGet
(
req
);
ep
->
processGet
(
req
);
break
;
break
;
case
MessageType
:
:
DELETE
:
case
MessageType
:
:
DELETE
:
cqEvents
.
emplace
(
id
,
cqevent
)
;
_cqEvents
[
id
]
=
cqevent
;
replicateSalRequest
(
buffer
,
data
->
byte_len
);
replicateSalRequest
(
buffer
,
data
->
byte_len
);
sendInvalidation
(
buffer
);
s
=
ep
->
_db
->
Delete
(
rocksdb
::
WriteOptions
(),
{(
char
*
)
req
+
MessageHeaderSize
,
req
->
keySize
});
s
=
ep
->
_db
->
Delete
(
rocksdb
::
WriteOptions
(),
{(
char
*
)
req
+
MessageHeaderSize
,
req
->
keySize
});
processReplicationDone
(
req
->
id
,
MessageType
::
FAILURE
,
true
);
break
;
break
;
case
MessageType
:
:
PUT
:
case
MessageType
:
:
PUT
:
cqEvents
.
emplace
(
id
,
cqevent
);
std
::
cout
<<
"id "
<<
id
<<
" "
<<
_cqEvents
.
size
()
<<
'\n'
;
_cqEvents
[
id
]
=
cqevent
;
std
::
cout
<<
"size "
<<
_cqEvents
.
size
()
<<
"
\n
"
;
replicateSalRequest
(
buffer
,
data
->
byte_len
);
replicateSalRequest
(
buffer
,
data
->
byte_len
);
sendInvalidation
(
buffer
);
s
=
ep
->
_db
->
Put
(
rocksdb
::
WriteOptions
(),
{(
char
*
)
req
+
MessageHeaderSize
,
req
->
keySize
},
s
=
ep
->
_db
->
Put
(
rocksdb
::
WriteOptions
(),
{(
char
*
)
req
+
MessageHeaderSize
,
req
->
keySize
},
{(
char
*
)
req
+
MessageHeaderSize
+
req
->
keySize
,
req
->
valueSize
});;
{(
char
*
)
req
+
MessageHeaderSize
+
req
->
keySize
,
req
->
valueSize
});
;
processReplicationDone
(
req
->
id
,
MessageType
::
FAILURE
,
true
);
break
;
break
;
default:
default:
std
::
ostringstream
ss
;
std
::
ostringstream
ss
;
...
@@ -158,11 +166,13 @@ void TaskThread::processEvent(RdmaSalEndpoint *ep, struct ibv_wc *data)
...
@@ -158,11 +166,13 @@ void TaskThread::processEvent(RdmaSalEndpoint *ep, struct ibv_wc *data)
CPPLog
::
LOG_INFO
(
ss
);
CPPLog
::
LOG_INFO
(
ss
);
break
;
break
;
}
}
std
::
cout
<<
"size "
<<
" "
<<
_cqEvents
.
size
()
<<
'\n'
;
}
}
void
TaskThread
::
processRepEvent
(
RdmaRepEndpoint
*
ep
,
struct
ibv_wc
*
data
)
void
TaskThread
::
processRepEvent
(
RdmaRepEndpoint
*
ep
,
struct
ibv_wc
*
data
)
{
{
std
::
cout
<<
"processing rep event"
<<
data
->
opcode
<<
"
\n
"
;
std
::
cout
<<
"processing rep event"
<<
data
->
opcode
<<
"
\n
"
;
switch
(
data
->
opcode
)
switch
(
data
->
opcode
)
{
{
case
IBV_WC_SEND
:
case
IBV_WC_SEND
:
...
@@ -176,7 +186,7 @@ void TaskThread::processRepEvent(RdmaRepEndpoint *ep, struct ibv_wc *data)
...
@@ -176,7 +186,7 @@ void TaskThread::processRepEvent(RdmaRepEndpoint *ep, struct ibv_wc *data)
rdma_post_recv
(
ep
->
_cm_id
,
(
void
*
)
data
->
wr_id
,
(
void
*
)
data
->
wr_id
,
rdma_post_recv
(
ep
->
_cm_id
,
(
void
*
)
data
->
wr_id
,
(
void
*
)
data
->
wr_id
,
ep
->
_recvMsgSize
,
ep
->
_recvMr
);
ep
->
_recvMsgSize
,
ep
->
_recvMr
);
struct
MessageHeader
*
req
=
(
struct
MessageHeader
*
)
buffer
;
struct
MessageHeader
*
req
=
(
struct
MessageHeader
*
)
buffer
;
std
::
cout
<<
"recv"
<<
req
->
type
<<
"
\n
"
;
std
::
cout
<<
"recv"
<<
req
->
type
<<
"
\n
"
;
switch
(
req
->
type
)
switch
(
req
->
type
)
{
{
case
MessageType
:
:
GET
:
case
MessageType
:
:
GET
:
...
@@ -189,10 +199,10 @@ void TaskThread::processRepEvent(RdmaRepEndpoint *ep, struct ibv_wc *data)
...
@@ -189,10 +199,10 @@ void TaskThread::processRepEvent(RdmaRepEndpoint *ep, struct ibv_wc *data)
ep
->
processPut
(
req
);
ep
->
processPut
(
req
);
break
;
break
;
case
MessageType
:
:
SUCCESS
:
case
MessageType
:
:
SUCCESS
:
processReplicationDone
(
req
->
id
);
processReplicationDone
(
req
->
id
,
MessageType
::
FAILURE
,
false
);
break
;
break
;
case
MessageType
:
:
FAILURE
:
case
MessageType
:
:
FAILURE
:
processReplicationDone
(
req
->
id
);
processReplicationDone
(
req
->
id
,
MessageType
::
FAILURE
,
false
);
break
;
break
;
default:
default:
std
::
ostringstream
ss
;
std
::
ostringstream
ss
;
...
@@ -211,20 +221,26 @@ void TaskThread::processRepEvent(RdmaRepEndpoint *ep, struct ibv_wc *data)
...
@@ -211,20 +221,26 @@ void TaskThread::processRepEvent(RdmaRepEndpoint *ep, struct ibv_wc *data)
}
}
}
}
void
TaskThread
::
processReplicationDone
(
uint32_t
id
)
void
TaskThread
::
processReplicationDone
(
uint32_t
id
,
MessageType
type
,
bool
localWrite
)
{
{
auto
it
=
cqEvents
.
find
(
id
);
auto
it
=
_cqEvents
.
find
(
id
);
if
(
it
==
cqEvents
.
end
())
// std::cout<<"size " <<_cqEvents.size()<<"\n";
if
(
it
==
_cqEvents
.
end
())
{
{
CPPLog
::
LOG_ERROR
(
"Cqevent not found"
);
std
::
ostringstream
ss
;
ss
<<
"Cqevent not found "
<<
id
;
CPPLog
::
LOG_ERROR
(
ss
);
return
;
return
;
}
}
std
::
cout
<<
"rep done
\n
"
;
// std::cout<<"rep done\n";
if
(
!
localWrite
)
++
(
it
->
second
->
_repDone
);
++
(
it
->
second
->
_repDone
);
if
(
it
->
second
->
_repDone
<
it
->
second
->
_repRequired
)
if
(
it
->
second
->
_repDone
<
it
->
second
->
_repRequired
)
{
// std::cout<<"event 2\n";
return
;
return
;
RdmaSalEndpoint
*
ep
=
it
->
second
->
_ep
;
}
RdmaSalEndpoint
*
ep
=
it
->
second
->
_ep
;
char
*
sendBuf
=
nullptr
;
char
*
sendBuf
=
nullptr
;
std
::
unique_lock
<
std
::
mutex
>
lock
(
ep
->
_sendBuffersM
);
std
::
unique_lock
<
std
::
mutex
>
lock
(
ep
->
_sendBuffersM
);
if
(
ep
->
_sendBuffers
.
size
()
==
0
)
if
(
ep
->
_sendBuffers
.
size
()
==
0
)
...
@@ -236,11 +252,8 @@ void TaskThread::processReplicationDone(uint32_t id)
...
@@ -236,11 +252,8 @@ void TaskThread::processReplicationDone(uint32_t id)
ep
->
_sendBuffers
.
pop
();
ep
->
_sendBuffers
.
pop
();
lock
.
unlock
();
lock
.
unlock
();
MessageHeader
*
response
=
(
MessageHeader
*
)
sendBuf
;
MessageHeader
*
response
=
(
MessageHeader
*
)
sendBuf
;
/*This id done to avoid else case*/
response
->
id
=
id
;
//response->type = MessageType::FAILURE;
response
->
type
=
type
;
//response->id = id;
//if (s.ok())
response
->
type
=
MessageType
::
SUCCESS
;
int
ret
=
rdma_post_send
(
ep
->
_cm_id
,
sendBuf
,
sendBuf
,
MessageHeaderSize
,
ep
->
_sendMr
,
0
);
int
ret
=
rdma_post_send
(
ep
->
_cm_id
,
sendBuf
,
sendBuf
,
MessageHeaderSize
,
ep
->
_sendMr
,
0
);
if
(
ret
==
-
1
)
if
(
ret
==
-
1
)
{
{
...
@@ -248,7 +261,6 @@ void TaskThread::processReplicationDone(uint32_t id)
...
@@ -248,7 +261,6 @@ void TaskThread::processReplicationDone(uint32_t id)
ss
<<
"rdma_post_send error occured errno "
<<
errno
<<
strerror
(
errno
);
ss
<<
"rdma_post_send error occured errno "
<<
errno
<<
strerror
(
errno
);
CPPLog
::
LOG_ERROR
(
ss
);
CPPLog
::
LOG_ERROR
(
ss
);
}
}
}
}
void
TaskThread
::
replicateSalRequest
(
char
*
req
,
uint32_t
size
)
void
TaskThread
::
replicateSalRequest
(
char
*
req
,
uint32_t
size
)
...
@@ -266,6 +278,9 @@ void TaskThread::replicateSalRequest(char *req, uint32_t size)
...
@@ -266,6 +278,9 @@ void TaskThread::replicateSalRequest(char *req, uint32_t size)
serverRepIt
->
second
->
sendMessage
(
req
,
size
);
serverRepIt
->
second
->
sendMessage
(
req
,
size
);
}
}
}
void
TaskThread
::
sendInvalidation
(
char
*
req
)
{
MessageHeader
*
salReq
=
(
MessageHeader
*
)
req
;
MessageHeader
*
salReq
=
(
MessageHeader
*
)
req
;
char
*
buffer
=
new
char
[
MessageHeaderSize
+
salReq
->
keySize
];
char
*
buffer
=
new
char
[
MessageHeaderSize
+
salReq
->
keySize
];
MessageHeader
*
invRequest
=
(
MessageHeader
*
)(
buffer
);
MessageHeader
*
invRequest
=
(
MessageHeader
*
)(
buffer
);
...
...
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