Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
emper
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Florian Fischer
emper
Commits
2680c470
Commit
2680c470
authored
3 years ago
by
Florian Schmaus
Browse files
Options
Downloads
Patches
Plain Diff
[Blockable] Set affinity on block
parent
1cf9f0f5
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
.gitlab-ci.yml
+9
-0
9 additions, 0 deletions
.gitlab-ci.yml
emper/Blockable.hpp
+25
-0
25 additions, 0 deletions
emper/Blockable.hpp
emper/Emper.hpp
+9
-0
9 additions, 0 deletions
emper/Emper.hpp
emper/Fiber.hpp
+2
-0
2 additions, 0 deletions
emper/Fiber.hpp
meson_options.txt
+6
-0
6 additions, 0 deletions
meson_options.txt
with
51 additions
and
0 deletions
.gitlab-ci.yml
+
9
−
0
View file @
2680c470
...
...
@@ -163,6 +163,10 @@ clang-tidy:
variables
:
EMPER_WAKEUP_SEMAPHORE_IMPLEMENTATION
:
"
locked"
.set-affinity-on-block
:
variables
:
EMPER_SET_AFFINITY_ON_BLOCK
:
'
true'
test-gcc
:
extends
:
-
.test
...
...
@@ -258,3 +262,8 @@ test-locked-wakeup-semaphore:
extends
:
-
.test
-
.locked-wakeup-semaphore
test-set-affinity-on-block
:
extends
:
-
.test
-
.set-affinity-on-block
This diff is collapsed.
Click to expand it.
emper/Blockable.hpp
+
25
−
0
View file @
2680c470
...
...
@@ -24,8 +24,31 @@ class Blockable : public Logger<logSubsystem> {
workeraffinity_t
*
affinity
=
nullptr
;
// It would be OK to not initialize this member since it is only set
// and read after affinity has been set to a non nullptr
// value. However, if we do not set it, then clang-tidy complains
// about clang-analyzer-optin.cplusplus.UninitializedObject.
workeraffinity_t
affinity_buffer
=
Fiber
::
NOT_AFFINE
;
Blockable
(
Runtime
&
runtime
)
:
runtime
(
runtime
),
contextManager
(
runtime
.
getContextManager
())
{}
void
maybeSetAffinity
()
{
if
constexpr
(
!
emper
::
SET_AFFINITY_ON_BLOCK
)
return
;
// TODO: At some point we may want to have something like
// Runtime::isAffinityCapable() and return here if it is
// not. Although I am not sure if it is worth the overhead.
auto
*
currentFiber
=
Context
::
getCurrentFiber
();
auto
*
affinity
=
currentFiber
->
getAffinityBuffer
();
if
(
affinity
)
{
this
->
affinity
=
affinity
;
}
else
{
affinity_buffer
=
Runtime
::
getWorkerId
();
this
->
affinity
=
&
affinity_buffer
;
}
}
// Older clang-tidy versions show a
// performance-unnecessary-value-param, newer versions do not show
// this error if std::move() is used (as we do).
...
...
@@ -36,6 +59,8 @@ class Blockable : public Logger<logSubsystem> {
LOGD
(
"block() blockedContext is "
<<
Context
::
getCurrentContext
());
maybeSetAffinity
();
if
constexpr
(
emper
::
BLOCKED_CONTEXT_SET
)
{
blockedContexts
.
insert
(
Context
::
getCurrentContext
());
}
...
...
This diff is collapsed.
Click to expand it.
emper/Emper.hpp
+
9
−
0
View file @
2680c470
...
...
@@ -113,4 +113,13 @@ enum class IoCompleterBehavior {
static
const
enum
IoCompleterBehavior
IO_COMPLETER_BEHAVIOR
=
IoCompleterBehavior
::
EMPER_IO_COMPLETER_BEHAVIOR
;
static
const
bool
SET_AFFINITY_ON_BLOCK
=
#ifdef EMPER_SET_AFFINITY_ON_BLOCK
true
#else
false
#endif
;
}
// namespace emper
This diff is collapsed.
Click to expand it.
emper/Fiber.hpp
+
2
−
0
View file @
2680c470
...
...
@@ -95,6 +95,8 @@ class ALIGN_TO_CACHE_LINE Fiber : public Logger<LogSubsystem::F> {
return
--
referenceCounter
;
}
template
<
LogSubsystem
>
friend
class
Blockable
;
friend
class
adt
::
MpscQueue
<
Fiber
>
;
friend
class
Scheduler
;
friend
class
Dispatcher
;
...
...
This diff is collapsed.
Click to expand it.
meson_options.txt
+
6
−
0
View file @
2680c470
...
...
@@ -129,3 +129,9 @@ option(
choices
:
[
'schedule'
,
'maybe_wakeup'
],
value
:
'schedule'
,
)
option
(
'set_affinity_on_block'
,
type
:
'boolean'
,
value
:
false
,
description
:
'Set the affinity when blocking'
,
)
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