Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
KOS
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Martin Karsten
KOS
Commits
da83c7a7
Commit
da83c7a7
authored
6 years ago
by
Martin Karsten
Browse files
Options
Downloads
Patches
Plain Diff
- change pollfibre to try nonblocking poll before blocking
- clerical updates in BaseProcessor
parent
f564e23a
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/libfibre/Poller.cc
+16
-8
16 additions, 8 deletions
src/libfibre/Poller.cc
src/runtime/BaseProcessor.cc
+4
-2
4 additions, 2 deletions
src/runtime/BaseProcessor.cc
src/runtime/BaseProcessor.h
+1
-1
1 addition, 1 deletion
src/runtime/BaseProcessor.h
with
21 additions
and
11 deletions
src/libfibre/Poller.cc
+
16
−
8
View file @
da83c7a7
...
@@ -66,12 +66,16 @@ inline void BasePoller::pollLoop(T& This, bool pollerFibre) {
...
@@ -66,12 +66,16 @@ inline void BasePoller::pollLoop(T& This, bool pollerFibre) {
}
}
inline
int
PollerThread
::
blockingPoll
()
{
inline
int
PollerThread
::
blockingPoll
()
{
int
evcnt
;
for
(;;)
{
#if __FreeBSD__
#if __FreeBSD__
int
evcnt
=
kevent
(
pollFD
,
nullptr
,
0
,
events
,
maxPoll
,
nullptr
);
// blocking
evcnt
=
kevent
(
pollFD
,
nullptr
,
0
,
events
,
maxPoll
,
nullptr
);
// blocking
#else // __linux__ below
#else // __linux__ below
int
evcnt
=
epoll_wait
(
pollFD
,
events
,
maxPoll
,
-
1
);
// blocking
evcnt
=
epoll_wait
(
pollFD
,
events
,
maxPoll
,
-
1
);
// blocking
#endif
#endif
if
(
evcnt
<
0
)
{
GENASSERT1
(
errno
==
EINTR
,
errno
);
}
// gracefully handle EINTR
if
(
evcnt
>
0
)
break
;
if
(
evcnt
<
0
)
{
GENASSERT1
(
errno
==
EINTR
,
errno
);
}
// gracefully handle EINTR
}
if
(
paused
)
pauseSem
.
P
();
if
(
paused
)
pauseSem
.
P
();
return
evcnt
;
return
evcnt
;
}
}
...
@@ -116,14 +120,18 @@ void Poller::stop() {
...
@@ -116,14 +120,18 @@ void Poller::stop() {
}
}
inline
int
Poller
::
blockingPoll
()
{
inline
int
Poller
::
blockingPoll
()
{
_lfEventEngine
->
blockPollFD
(
pollFD
);
int
evcnt
;
for
(;;)
{
#if __FreeBSD__
#if __FreeBSD__
static
const
timespec
ts
=
Time
::
zero
();
static
const
timespec
ts
=
Time
::
zero
();
int
evcnt
=
kevent
(
pollFD
,
nullptr
,
0
,
events
,
maxPoll
,
&
ts
);
evcnt
=
kevent
(
pollFD
,
nullptr
,
0
,
events
,
maxPoll
,
&
ts
);
#else // __linux__ below
#else // __linux__ below
int
evcnt
=
epoll_wait
(
pollFD
,
events
,
maxPoll
,
0
);
evcnt
=
epoll_wait
(
pollFD
,
events
,
maxPoll
,
0
);
#endif
#endif
if
(
evcnt
<
0
)
{
GENASSERT1
(
errno
==
EINTR
,
errno
);
}
// gracefully handle EINTR
if
(
evcnt
>
0
)
break
;
if
(
evcnt
<
0
)
{
GENASSERT1
(
errno
==
EINTR
,
errno
);
}
// gracefully handle EINTR
_lfEventEngine
->
blockPollFD
(
pollFD
);
}
if
(
paused
)
pauseSem
.
P
();
if
(
paused
)
pauseSem
.
P
();
return
evcnt
;
return
evcnt
;
}
}
...
...
This diff is collapsed.
Click to expand it.
src/runtime/BaseProcessor.cc
+
4
−
2
View file @
da83c7a7
...
@@ -44,11 +44,13 @@ bool BaseProcessor::findWork() {
...
@@ -44,11 +44,13 @@ bool BaseProcessor::findWork() {
#endif
#endif
for
(
size_t
spin
=
0
;
spin
<
spinMax
;
spin
+=
1
)
{
for
(
size_t
spin
=
0
;
spin
<
spinMax
;
spin
+=
1
)
{
if
(
StackContext
::
idleYield
(
_friend
<
BaseProcessor
>
()))
return
true
;
if
(
StackContext
::
idleYield
(
_friend
<
BaseProcessor
>
()))
return
true
;
if
(
terminate
)
return
true
;
Pause
();
}
}
return
false
;
return
false
;
}
}
inline
bool
BaseProcessor
::
try
Dequeue
(
StackContext
*&
s
)
{
inline
bool
BaseProcessor
::
try
Local
(
StackContext
*&
s
)
{
#if TESTING_WORK_STEALING
#if TESTING_WORK_STEALING
s
=
readyQueue
.
dequeueSafe
();
s
=
readyQueue
.
dequeueSafe
();
#else
#else
...
@@ -100,7 +102,7 @@ inline bool BaseProcessor::tryBorrow(StackContext*& s) {
...
@@ -100,7 +102,7 @@ inline bool BaseProcessor::tryBorrow(StackContext*& s) {
StackContext
*
BaseProcessor
::
schedule
(
_friend
<
StackContext
>
)
{
StackContext
*
BaseProcessor
::
schedule
(
_friend
<
StackContext
>
)
{
StackContext
*
nextStack
;
StackContext
*
nextStack
;
if
(
try
Dequeue
(
nextStack
))
return
nextStack
;
if
(
try
Local
(
nextStack
))
return
nextStack
;
if
(
terminate
)
return
idleStack
;
if
(
terminate
)
return
idleStack
;
#if TESTING_POLLER_FIBRES
#if TESTING_POLLER_FIBRES
if
(
tryBorrow
(
nextStack
))
return
nextStack
;
if
(
tryBorrow
(
nextStack
))
return
nextStack
;
...
...
This diff is collapsed.
Click to expand it.
src/runtime/BaseProcessor.h
+
1
−
1
View file @
da83c7a7
...
@@ -192,7 +192,7 @@ typedef IntrusiveList<BaseProcessor,0,1> ProcessorList;
...
@@ -192,7 +192,7 @@ typedef IntrusiveList<BaseProcessor,0,1> ProcessorList;
#endif
#endif
class
BaseProcessor
:
public
ProcessorList
::
Link
,
public
VirtualProcessor
{
class
BaseProcessor
:
public
ProcessorList
::
Link
,
public
VirtualProcessor
{
inline
bool
try
Dequeue
(
StackContext
*&
s
);
inline
bool
try
Local
(
StackContext
*&
s
);
inline
bool
tryStage
(
StackContext
*&
s
);
inline
bool
tryStage
(
StackContext
*&
s
);
inline
bool
trySteal
(
StackContext
*&
s
);
inline
bool
trySteal
(
StackContext
*&
s
);
inline
bool
tryBorrow
(
StackContext
*&
s
);
inline
bool
tryBorrow
(
StackContext
*&
s
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment