Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Дилян Палаузов
OpenLDAP
Commits
6d95cc39
Commit
6d95cc39
authored
Mar 10, 2021
by
Ondřej Kuzník
Browse files
ITS#9599 Online latency tracking
parent
8219a3a4
Changes
1
Hide whitespace changes
Inline
Side-by-side
servers/lloadd/tier_bestof.c
View file @
6d95cc39
...
...
@@ -57,8 +57,27 @@ bestof_cmp( const void *left, const void *right )
{
const
LloadBackend
*
l
=
left
;
const
LloadBackend
*
r
=
right
;
struct
timeval
now
;
uintptr_t
count
,
diff
;
float
a
=
l
->
b_fitness
,
b
=
r
->
b_fitness
,
factor
=
1
;
gettimeofday
(
&
now
,
NULL
);
/* We assume this is less than a second after the last update */
factor
=
1
/
(
pow
(
(
1
/
factor
)
+
1
,
now
.
tv_usec
/
1000000
.
0
)
-
1
);
count
=
__atomic_load_n
(
&
l
->
b_operation_count
,
__ATOMIC_RELAXED
);
diff
=
__atomic_load_n
(
&
l
->
b_operation_time
,
__ATOMIC_RELAXED
);
if
(
count
)
{
a
=
(
a
*
factor
+
(
float
)
diff
*
l
->
b_weight
/
count
)
/
(
factor
+
1
);
}
count
=
__atomic_load_n
(
&
r
->
b_operation_count
,
__ATOMIC_RELAXED
);
diff
=
__atomic_load_n
(
&
r
->
b_operation_time
,
__ATOMIC_RELAXED
);
if
(
count
)
{
b
=
(
b
*
factor
+
(
float
)
diff
*
r
->
b_weight
/
count
)
/
(
factor
+
1
);
}
return
l
->
b_fitness
-
r
->
b_fitness
;
return
(
a
-
b
<
0
)
?
-
1
:
(
a
-
b
==
0
)
?
0
:
1
;
}
LloadTier
*
...
...
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