Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Grpc
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
Container Registry
Model registry
Operate
Environments
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tci-gateway-module
Grpc
Commits
5649b448
Commit
5649b448
authored
9 years ago
by
Craig Tiller
Browse files
Options
Downloads
Patches
Plain Diff
clang-format
parent
2a45a566
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/core/profiling/basic_timers.c
+10
-15
10 additions, 15 deletions
src/core/profiling/basic_timers.c
src/core/profiling/timers.h
+15
-12
15 additions, 12 deletions
src/core/profiling/timers.h
src/core/profiling/timers_preciseclock.h
+12
-8
12 additions, 8 deletions
src/core/profiling/timers_preciseclock.h
with
37 additions
and
35 deletions
src/core/profiling/basic_timers.c
+
10
−
15
View file @
5649b448
...
@@ -45,11 +45,7 @@
...
@@ -45,11 +45,7 @@
#include
<grpc/support/thd.h>
#include
<grpc/support/thd.h>
#include
<stdio.h>
#include
<stdio.h>
typedef
enum
{
typedef
enum
{
BEGIN
=
'{'
,
END
=
'}'
,
MARK
=
'.'
}
marker_type
;
BEGIN
=
'{'
,
END
=
'}'
,
MARK
=
'.'
}
marker_type
;
typedef
struct
grpc_timer_entry
{
typedef
struct
grpc_timer_entry
{
grpc_precise_clock
tm
;
grpc_precise_clock
tm
;
...
@@ -60,7 +56,7 @@ typedef struct grpc_timer_entry {
...
@@ -60,7 +56,7 @@ typedef struct grpc_timer_entry {
int
line
;
int
line
;
}
grpc_timer_entry
;
}
grpc_timer_entry
;
#define MAX_COUNT (1024
*
1024
/
sizeof(grpc_timer_entry))
#define MAX_COUNT (1024
*
1024
/
sizeof(grpc_timer_entry))
static
__thread
grpc_timer_entry
log
[
MAX_COUNT
];
static
__thread
grpc_timer_entry
log
[
MAX_COUNT
];
static
__thread
int
count
;
static
__thread
int
count
;
...
@@ -69,8 +65,10 @@ static void log_report() {
...
@@ -69,8 +65,10 @@ static void log_report() {
int
i
;
int
i
;
for
(
i
=
0
;
i
<
count
;
i
++
)
{
for
(
i
=
0
;
i
<
count
;
i
++
)
{
grpc_timer_entry
*
entry
=
&
(
log
[
i
]);
grpc_timer_entry
*
entry
=
&
(
log
[
i
]);
printf
(
"GRPC_LAT_PROF "
GRPC_PRECISE_CLOCK_FORMAT
" %p %c %d %p %s %d
\n
"
,
GRPC_PRECISE_CLOCK_PRINTF_ARGS
(
&
entry
->
tm
),
(
void
*
)(
gpr_intptr
)
gpr_thd_currentid
(),
entry
->
type
,
entry
->
tag
,
printf
(
"GRPC_LAT_PROF "
GRPC_PRECISE_CLOCK_FORMAT
" %p %c %d %p %s %d
\n
"
,
entry
->
id
,
entry
->
file
,
entry
->
line
);
GRPC_PRECISE_CLOCK_PRINTF_ARGS
(
&
entry
->
tm
),
(
void
*
)(
gpr_intptr
)
gpr_thd_currentid
(),
entry
->
type
,
entry
->
tag
,
entry
->
id
,
entry
->
file
,
entry
->
line
);
}
}
/* Now clear out the log */
/* Now clear out the log */
...
@@ -103,25 +101,22 @@ void grpc_timer_add_mark(int tag, void* id, const char* file, int line) {
...
@@ -103,25 +101,22 @@ void grpc_timer_add_mark(int tag, void* id, const char* file, int line) {
}
}
}
}
void
grpc_timer_begin
(
int
tag
,
void
*
id
,
const
char
*
file
,
int
line
)
{
void
grpc_timer_begin
(
int
tag
,
void
*
id
,
const
char
*
file
,
int
line
)
{
if
(
tag
<
GRPC_PTAG_IGNORE_THRESHOLD
)
{
if
(
tag
<
GRPC_PTAG_IGNORE_THRESHOLD
)
{
grpc_timers_log_add
(
tag
,
BEGIN
,
id
,
file
,
line
);
grpc_timers_log_add
(
tag
,
BEGIN
,
id
,
file
,
line
);
}
}
}
}
void
grpc_timer_end
(
int
tag
,
void
*
id
,
const
char
*
file
,
int
line
)
{
void
grpc_timer_end
(
int
tag
,
void
*
id
,
const
char
*
file
,
int
line
)
{
if
(
tag
<
GRPC_PTAG_IGNORE_THRESHOLD
)
{
if
(
tag
<
GRPC_PTAG_IGNORE_THRESHOLD
)
{
grpc_timers_log_add
(
tag
,
END
,
id
,
file
,
line
);
grpc_timers_log_add
(
tag
,
END
,
id
,
file
,
line
);
}
}
}
}
/* Basic profiler specific API functions. */
/* Basic profiler specific API functions. */
void
grpc_timers_global_init
(
void
)
{
void
grpc_timers_global_init
(
void
)
{}
}
void
grpc_timers_global_destroy
(
void
)
{
}
void
grpc_timers_global_destroy
(
void
)
{}
#else
/* !GRPC_BASIC_PROFILER */
#else
/* !GRPC_BASIC_PROFILER */
void
grpc_timers_global_init
(
void
)
{}
void
grpc_timers_global_init
(
void
)
{}
...
...
This diff is collapsed.
Click to expand it.
src/core/profiling/timers.h
+
15
−
12
View file @
5649b448
...
@@ -41,9 +41,9 @@ extern "C" {
...
@@ -41,9 +41,9 @@ extern "C" {
void
grpc_timers_global_init
(
void
);
void
grpc_timers_global_init
(
void
);
void
grpc_timers_global_destroy
(
void
);
void
grpc_timers_global_destroy
(
void
);
void
grpc_timer_add_mark
(
int
tag
,
void
*
id
,
const
char
*
file
,
int
line
);
void
grpc_timer_add_mark
(
int
tag
,
void
*
id
,
const
char
*
file
,
int
line
);
void
grpc_timer_begin
(
int
tag
,
void
*
id
,
const
char
*
file
,
int
line
);
void
grpc_timer_begin
(
int
tag
,
void
*
id
,
const
char
*
file
,
int
line
);
void
grpc_timer_end
(
int
tag
,
void
*
id
,
const
char
*
file
,
int
line
);
void
grpc_timer_end
(
int
tag
,
void
*
id
,
const
char
*
file
,
int
line
);
enum
grpc_profiling_tags
{
enum
grpc_profiling_tags
{
/* Any GRPC_PTAG_* >= than the threshold won't generate any profiling mark. */
/* Any GRPC_PTAG_* >= than the threshold won't generate any profiling mark. */
...
@@ -74,13 +74,16 @@ enum grpc_profiling_tags {
...
@@ -74,13 +74,16 @@ enum grpc_profiling_tags {
#if !(defined(GRPC_STAP_PROFILER) + defined(GRPC_BASIC_PROFILER))
#if !(defined(GRPC_STAP_PROFILER) + defined(GRPC_BASIC_PROFILER))
/* No profiling. No-op all the things. */
/* No profiling. No-op all the things. */
#define GRPC_TIMER_MARK(tag, id) \
#define GRPC_TIMER_MARK(tag, id) \
do {} while(0)
do { \
} while (0)
#define GRPC_TIMER_BEGIN(tag, id) \
#define GRPC_TIMER_BEGIN(tag, id) \
do {} while(0)
do { \
} while (0)
#define GRPC_TIMER_END(tag, id) \
#define GRPC_TIMER_END(tag, id) \
do {} while(0)
do { \
} while (0)
#else
/* at least one profiler requested... */
#else
/* at least one profiler requested... */
/* ... hopefully only one. */
/* ... hopefully only one. */
...
@@ -94,14 +97,14 @@ enum grpc_profiling_tags {
...
@@ -94,14 +97,14 @@ enum grpc_profiling_tags {
grpc_timer_add_mark(tag, ((void *)(gpr_intptr)(id)), __FILE__, __LINE__); \
grpc_timer_add_mark(tag, ((void *)(gpr_intptr)(id)), __FILE__, __LINE__); \
}
}
#define GRPC_TIMER_BEGIN(tag, id)
\
#define GRPC_TIMER_BEGIN(tag, id) \
if (tag < GRPC_PTAG_IGNORE_THRESHOLD) {
\
if (tag < GRPC_PTAG_IGNORE_THRESHOLD) { \
grpc_timer_begin(tag, ((void *)(gpr_intptr)(id)), __FILE__, __LINE__);
\
grpc_timer_begin(tag, ((void *)(gpr_intptr)(id)), __FILE__, __LINE__); \
}
}
#define GRPC_TIMER_END(tag, id)
\
#define GRPC_TIMER_END(tag, id) \
if (tag < GRPC_PTAG_IGNORE_THRESHOLD) {
\
if (tag < GRPC_PTAG_IGNORE_THRESHOLD) { \
grpc_timer_end(tag, ((void *)(gpr_intptr)(id)), __FILE__, __LINE__);
\
grpc_timer_end(tag, ((void *)(gpr_intptr)(id)), __FILE__, __LINE__); \
}
}
#ifdef GRPC_STAP_PROFILER
#ifdef GRPC_STAP_PROFILER
...
...
This diff is collapsed.
Click to expand it.
src/core/profiling/timers_preciseclock.h
+
12
−
8
View file @
5649b448
...
@@ -43,7 +43,7 @@ typedef long long int grpc_precise_clock;
...
@@ -43,7 +43,7 @@ typedef long long int grpc_precise_clock;
#if defined(__i386__)
#if defined(__i386__)
static
void
grpc_precise_clock_now
(
grpc_precise_clock
*
clk
)
{
static
void
grpc_precise_clock_now
(
grpc_precise_clock
*
clk
)
{
grpc_precise_clock
ret
;
grpc_precise_clock
ret
;
__asm__
volatile
(
"rdtsc"
:
"=A"
(
ret
)
);
__asm__
volatile
(
"rdtsc"
:
"=A"
(
ret
));
*
clk
=
ret
;
*
clk
=
ret
;
}
}
...
@@ -51,7 +51,7 @@ static void grpc_precise_clock_now(grpc_precise_clock *clk) {
...
@@ -51,7 +51,7 @@ static void grpc_precise_clock_now(grpc_precise_clock *clk) {
#elif defined(__x86_64__) || defined(__amd64__)
#elif defined(__x86_64__) || defined(__amd64__)
static
void
grpc_precise_clock_now
(
grpc_precise_clock
*
clk
)
{
static
void
grpc_precise_clock_now
(
grpc_precise_clock
*
clk
)
{
unsigned
long
long
low
,
high
;
unsigned
long
long
low
,
high
;
__asm__
volatile
(
"rdtsc"
:
"=a"
(
low
),
"=d"
(
high
));
__asm__
volatile
(
"rdtsc"
:
"=a"
(
low
),
"=d"
(
high
));
*
clk
=
(
high
<<
32
)
|
low
;
*
clk
=
(
high
<<
32
)
|
low
;
}
}
#endif
#endif
...
@@ -61,18 +61,21 @@ static void grpc_precise_clock_init() {
...
@@ -61,18 +61,21 @@ static void grpc_precise_clock_init() {
time_t
start
=
time
(
NULL
);
time_t
start
=
time
(
NULL
);
grpc_precise_clock
start_time
;
grpc_precise_clock
start_time
;
grpc_precise_clock
end_time
;
grpc_precise_clock
end_time
;
while
(
time
(
NULL
)
==
start
);
while
(
time
(
NULL
)
==
start
)
;
grpc_precise_clock_now
(
&
start_time
);
grpc_precise_clock_now
(
&
start_time
);
while
(
time
(
NULL
)
==
start
+
1
);
while
(
time
(
NULL
)
==
start
+
1
)
;
grpc_precise_clock_now
(
&
end_time
);
grpc_precise_clock_now
(
&
end_time
);
cycles_per_second
=
end_time
-
start_time
;
cycles_per_second
=
end_time
-
start_time
;
}
}
static
double
grpc_precise_clock_scaling_factor
()
{
static
double
grpc_precise_clock_scaling_factor
()
{
gpr_once_init
(
&
precise_clock_init
,
grpc_precise_clock_init
);
gpr_once_init
(
&
precise_clock_init
,
grpc_precise_clock_init
);
return
1e6
/
cycles_per_second
;
return
1e6
/
cycles_per_second
;
}
}
#define GRPC_PRECISE_CLOCK_FORMAT "%f"
#define GRPC_PRECISE_CLOCK_FORMAT "%f"
#define GRPC_PRECISE_CLOCK_PRINTF_ARGS(clk) (*(clk) * grpc_precise_clock_scaling_factor())
#define GRPC_PRECISE_CLOCK_PRINTF_ARGS(clk) \
(*(clk)*grpc_precise_clock_scaling_factor())
#else
#else
typedef
struct
grpc_precise_clock
grpc_precise_clock
;
typedef
struct
grpc_precise_clock
grpc_precise_clock
;
struct
grpc_precise_clock
{
struct
grpc_precise_clock
{
...
@@ -82,7 +85,8 @@ static void grpc_precise_clock_now(grpc_precise_clock* clk) {
...
@@ -82,7 +85,8 @@ static void grpc_precise_clock_now(grpc_precise_clock* clk) {
clk
->
clock
=
gpr_now
();
clk
->
clock
=
gpr_now
();
}
}
#define GRPC_PRECISE_CLOCK_FORMAT "%ld.%09d"
#define GRPC_PRECISE_CLOCK_FORMAT "%ld.%09d"
#define GRPC_PRECISE_CLOCK_PRINTF_ARGS(clk) (clk)->clock.tv_sec, (clk)->clock.tv_nsec
#define GRPC_PRECISE_CLOCK_PRINTF_ARGS(clk) \
(clk)->clock.tv_sec, (clk)->clock.tv_nsec
static
void
grpc_precise_clock_print
(
const
grpc_precise_clock
*
clk
,
FILE
*
fp
)
{
static
void
grpc_precise_clock_print
(
const
grpc_precise_clock
*
clk
,
FILE
*
fp
)
{
fprintf
(
fp
,
"%ld.%09d"
,
clk
->
clock
.
tv_sec
,
clk
->
clock
.
tv_nsec
);
fprintf
(
fp
,
"%ld.%09d"
,
clk
->
clock
.
tv_sec
,
clk
->
clock
.
tv_nsec
);
}
}
...
...
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