Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
B
brpc
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
brpc
Commits
961492db
Commit
961492db
authored
Jul 31, 2017
by
gejun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
patch public/bvar@r34901
Change-Id: Ifb0584b6321ed8e762187560391172e967cd945f
parent
2230cc17
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
5 deletions
+28
-5
percentile.h
bvar/detail/percentile.h
+5
-0
sampler.cpp
bvar/detail/sampler.cpp
+17
-4
patch_from_svn
tools/patch_from_svn
+6
-1
No files found.
bvar/detail/percentile.h
View file @
961492db
...
...
@@ -130,6 +130,11 @@ public:
void
merge_with_expectation
(
PercentileInterval
<
size2
>&
mutable_rhs
,
size_t
n
)
{
CHECK
(
n
<=
mutable_rhs
.
_num_samples
);
_num_added
+=
mutable_rhs
.
_num_added
;
if
(
_num_samples
+
n
<=
SAMPLE_SIZE
&&
n
==
mutable_rhs
.
_num_samples
)
{
memcpy
(
_samples
+
_num_samples
,
mutable_rhs
.
_samples
,
sizeof
(
_samples
[
0
])
*
n
);
_num_samples
+=
n
;
return
;
}
for
(
size_t
i
=
0
;
i
<
n
;
++
i
)
{
size_t
index
=
base
::
fast_rand_less_than
(
mutable_rhs
.
_num_samples
-
i
);
if
(
_num_samples
<
SAMPLE_SIZE
)
{
...
...
bvar/detail/sampler.cpp
View file @
961492db
...
...
@@ -6,6 +6,8 @@
#include "base/memory/singleton_on_pthread_once.h"
#include "bvar/reducer.h"
#include "bvar/detail/sampler.h"
#include "bvar/passive_status.h"
#include "bvar/window.h"
namespace
bvar
{
namespace
detail
{
...
...
@@ -39,7 +41,7 @@ struct CombineSampler {
// deletion is taken place in the thread as well.
class
SamplerCollector
:
public
bvar
::
Reducer
<
Sampler
*
,
CombineSampler
>
{
public
:
SamplerCollector
()
:
_created
(
false
),
_stop
(
false
)
{
SamplerCollector
()
:
_created
(
false
),
_stop
(
false
)
,
_cumulated_time_us
(
0
)
{
int
rc
=
pthread_create
(
&
_tid
,
NULL
,
sampling_thread
,
this
);
if
(
rc
!=
0
)
{
LOG
(
FATAL
)
<<
"Fail to create sampling_thread, "
<<
berror
(
rc
);
...
...
@@ -56,6 +58,10 @@ public:
}
}
static
double
get_cumulated_time
(
void
*
arg
)
{
return
((
SamplerCollector
*
)
arg
)
->
_cumulated_time_us
/
1000.0
/
1000.0
;
}
private
:
void
run
();
...
...
@@ -67,6 +73,7 @@ private:
private
:
bool
_created
;
bool
_stop
;
int64_t
_cumulated_time_us
;
pthread_t
_tid
;
};
...
...
@@ -74,8 +81,11 @@ void SamplerCollector::run() {
VLOG
(
99
)
<<
"SamplerCollector starts to run"
;
base
::
LinkNode
<
Sampler
>
root
;
int
consecutive_nosleep
=
0
;
PassiveStatus
<
double
>
cumulated_time
(
get_cumulated_time
,
this
);
bvar
::
PerSecond
<
bvar
::
PassiveStatus
<
double
>
>
usage
(
"bvar_sampler_collector_usage"
,
&
cumulated_time
,
10
);
while
(
!
_stop
)
{
const
int64_t
abstime
=
base
::
gettimeofday_us
()
+
1000000L
;
int64_t
abstime
=
base
::
gettimeofday_us
()
;
Sampler
*
s
=
this
->
reset
();
if
(
s
)
{
s
->
InsertBeforeAsList
(
&
root
);
...
...
@@ -99,11 +109,14 @@ void SamplerCollector::run() {
}
p
=
saved_next
;
}
int64_t
now
=
0
;
bool
slept
=
false
;
while
(
abstime
>
(
now
=
base
::
gettimeofday_us
()))
{
int64_t
now
=
base
::
gettimeofday_us
();
_cumulated_time_us
+=
now
-
abstime
;
abstime
+=
1000000L
;
while
(
abstime
>
now
)
{
::
usleep
(
abstime
-
now
);
slept
=
true
;
now
=
base
::
gettimeofday_us
();
}
if
(
slept
)
{
consecutive_nosleep
=
0
;
...
...
tools/patch_from_svn
View file @
961492db
...
...
@@ -4,7 +4,12 @@ if [ -z "$1" ]; then
echo
"The patch should be generated by 'svn diff -c <REV>'"
exit
1
fi
cat
$1
|
sed
-e
's/src\/baidu\/rpc\//brpc\//g'
>
$1
.brpc_os
cat
$1
|sed
-e
's/src\/baidu\/rpc\//brpc\//g'
\
-e
's/<\(bvar\/[^>]*\)>/"\1"/g'
\
-e
's/<\(base\/[^>]*\)>/"\1"/g'
\
-e
's/<\(bthread\/[^>]*\)>/"\1"/g'
\
-e
's/<\(mcpack2pb\/[^>]*\)>/"\1"/g'
\
>
$1
.brpc_os
EXTRA_ARGS
=
if
[
-z
"
$DO_RUN
"
]
;
then
EXTRA_ARGS
=
"--dry-run
$EXTRA_ARGS
"
...
...
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