Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
aion
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Philip Trettner
aion
Commits
94ada7db
Commit
94ada7db
authored
Nov 15, 2018
by
Philip Trettner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added export support for speedscope
parent
7244d964
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
179 additions
and
0 deletions
+179
-0
src/aion/Tracer.hh
src/aion/Tracer.hh
+8
-0
src/aion/Tracer.output.cc
src/aion/Tracer.output.cc
+171
-0
No files found.
src/aion/Tracer.hh
View file @
94ada7db
...
...
@@ -126,6 +126,14 @@ void visit_thread(visitor& v);
void
write_json
(
std
::
string
const
&
filename
);
/// writes a csv where all trace points are summarized per-location
void
write_summary_csv
(
std
::
string
const
&
filename
);
/// generates a Brendan Gregg's collapsed stack format file
/// see https://github.com/BrendanGregg/flamegraph#2-fold-stacks
/// e.g. for use with https://github.com/jlfwong/speedscope
/// recommended file name is .folded
void
write_collapsed_stack
(
std
::
string
const
&
filename
);
/// Json file for use with https://github.com/jlfwong/speedscope
/// see https://github.com/jlfwong/speedscope/wiki/Importing-from-custom-sources
void
write_speedscope_json
(
std
::
string
const
&
filename
);
/// writes various output formats to a given directory
/// NOTE: does nothing if directory does not exist
void
write_dir
(
std
::
string
const
&
path
);
...
...
src/aion/Tracer.output.cc
View file @
94ada7db
#include "Tracer.hh"
#include <algorithm>
#include <iostream>
#include <map>
#include <unordered_map>
#include <vector>
#include <fstream>
...
...
@@ -16,6 +18,175 @@ void write_dir(const std::string &path)
write_summary_csv
(
path
+
"/trace.csv"
);
}
void
write_speedscope_json
(
std
::
string
const
&
filename
)
{
std
::
ofstream
out
(
filename
);
if
(
!
out
.
good
())
return
;
struct
event
{
char
type
;
int
frame
;
uint64_t
at
;
};
struct
stack_entry
{
int
frame
;
};
struct
visitor
:
tracing
::
visitor
{
uint64_t
min_cycles
=
std
::
numeric_limits
<
uint64_t
>::
max
();
uint64_t
max_cycles
=
0
;
uint32_t
last_cpu
=
0
;
std
::
unordered_map
<
location
*
,
int
>
frames
;
std
::
vector
<
location
*>
locations
;
std
::
vector
<
stack_entry
>
stack
;
std
::
vector
<
event
>
events
;
std
::
thread
::
id
thread
;
int
frame_of
(
location
*
loc
)
{
auto
it
=
frames
.
find
(
loc
);
if
(
it
!=
frames
.
end
())
return
it
->
second
;
auto
f
=
frames
.
size
();
frames
[
loc
]
=
f
;
locations
.
push_back
(
loc
);
return
f
;
}
virtual
void
on_thread
(
std
::
thread
::
id
thread
)
override
{
close_pending_actions
();
this
->
thread
=
thread
;
stack
.
clear
();
}
virtual
void
on_trace_start
(
tracing
::
location
*
loc
,
uint64_t
cycles
,
uint32_t
cpu
)
override
{
last_cpu
=
cpu
;
min_cycles
=
std
::
min
(
min_cycles
,
cycles
);
max_cycles
=
std
::
max
(
max_cycles
,
cycles
);
auto
f
=
frame_of
(
loc
);
events
.
push_back
({
'O'
,
f
,
cycles
});
stack
.
push_back
({
f
});
}
virtual
void
on_trace_end
(
uint64_t
cycles
,
uint32_t
cpu
)
override
{
last_cpu
=
cpu
;
min_cycles
=
std
::
min
(
min_cycles
,
cycles
);
max_cycles
=
std
::
max
(
max_cycles
,
cycles
);
auto
se
=
stack
.
back
();
stack
.
pop_back
();
events
.
push_back
({
'C'
,
se
.
frame
,
cycles
});
}
void
close_pending_actions
()
{
while
(
!
stack
.
empty
())
on_trace_end
(
max_cycles
,
last_cpu
);
}
};
visitor
v
;
tracing
::
visit_thread
(
v
);
v
.
close_pending_actions
();
out
<<
"{"
;
out
<<
"
\"
version
\"
:
\"
0.0.1
\"
,"
;
out
<<
"
\"
$schema
\"
:
\"
https://www.speedscope.app/file-format-schema.json
\"
,"
;
out
<<
"
\"
shared
\"
:{"
;
out
<<
"
\"
frames
\"
:["
;
for
(
auto
i
=
0u
;
i
<
v
.
locations
.
size
();
++
i
)
{
auto
loc
=
v
.
locations
[
i
];
if
(
i
>
0
)
out
<<
","
;
out
<<
"{"
;
out
<<
"
\"
name
\"
:
\"
"
<<
(
std
::
string
(
loc
->
name
).
empty
()
?
loc
->
function
:
loc
->
name
)
<<
"
\"
,"
;
out
<<
"
\"
file
\"
:
\"
"
<<
loc
->
file
<<
"
\"
,"
;
out
<<
"
\"
line
\"
:"
<<
loc
->
line
<<
""
;
out
<<
"}"
;
}
out
<<
"]"
;
out
<<
"},"
;
out
<<
"
\"
profiles
\"
:[{"
;
out
<<
"
\"
type
\"
:
\"
evented
\"
,"
;
out
<<
"
\"
name
\"
:
\"
Aion Trace
\"
,"
;
out
<<
"
\"
unit
\"
:
\"
none
\"
,"
;
out
<<
"
\"
startValue
\"
:0,"
;
out
<<
"
\"
endValue
\"
:"
<<
v
.
max_cycles
-
v
.
min_cycles
<<
","
;
out
<<
"
\"
events
\"
:["
;
auto
first
=
true
;
for
(
auto
const
&
e
:
v
.
events
)
{
if
(
!
first
)
out
<<
","
;
first
=
false
;
out
<<
"{"
;
out
<<
"
\"
type
\"
:
\"
"
<<
e
.
type
<<
"
\"
,"
;
out
<<
"
\"
frame
\"
:"
<<
e
.
frame
<<
","
;
out
<<
"
\"
at
\"
:"
<<
e
.
at
-
v
.
min_cycles
;
out
<<
"}"
;
}
out
<<
"]"
;
out
<<
"}]"
;
out
<<
"}"
;
}
void
write_collapsed_stack
(
std
::
string
const
&
filename
)
{
std
::
ofstream
out
(
filename
);
if
(
!
out
.
good
())
return
;
std
::
cerr
<<
"Not implemented"
<<
std
::
endl
;
/*
struct stack_entry
{
location *loc;
uint64_t cycles;
std::string prefix;
};
struct visitor : tracing::visitor
{
std::vector<stack_entry> stack;
std::thread::id thread;
virtual void on_thread(std::thread::id thread) override
{
this->thread = thread;
stack.clear();
// TODO: close pending actions
}
virtual void on_trace_start(tracing::location *loc, uint64_t cycles, uint32_t cpu) override
{
std::string name = loc->name;
std::string function = loc->function;
auto prefix = loc->name loc->function
//
stack.push_back({loc, cycles});
}
virtual void on_trace_end(uint64_t cycles, uint32_t cpu) override
{
auto se = stack.back();
stack.pop_back();
auto dt = cycles - se.cycles;
}
};
visitor v;
tracing::visit_thread(v);*/
}
void
write_json
(
const
std
::
string
&
filename
)
{
std
::
ofstream
out
(
filename
);
...
...
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