#include <profile.hpp>
|
template<typename Backend > |
| profile_data (const std::string &file, Backend &bkend, const std::size_t buffer_size=65536, std::size_t hash_table_size=1024) |
|
| ~profile_data () |
|
void | write_header () |
|
void | write_trailer () |
|
void | flush () |
|
void | write (const char *data, std::size_t size) |
|
void | write (const item *item) |
|
item * | evict_oldest () |
|
void | move_to_head (list_header *new_head) |
|
void | insert_hash (item *new_item) |
|
void | flush_hash () |
|
void | handle_tick (void **data, int count) |
|
template<typename Context > |
void | init_backtrace (const Context &context) |
|
template<typename Backend > |
| profile_data (const std::string &file, Backend &bkend, const std::size_t buffer_size=65536, std::size_t hash_table_size=1024) |
|
| ~profile_data () |
|
void | write_header () |
|
void | write_trailer () |
|
void | flush () |
|
void | write (const char *data, std::size_t size) |
|
void | write (const item *item) |
|
item * | evict_oldest () |
|
void | move_to_head (list_header *new_head) |
|
void | insert_hash (item *new_item) |
|
void | flush_hash () |
|
void | handle_tick (void **data, int count) |
|
template<typename Context > |
void | init_backtrace (const Context &context) |
|
Definition at line 20 of file profile.hpp.
◆ profile_data() [1/2]
template<typename Backend >
sysio::vm::profile_data::profile_data |
( |
const std::string & | file, |
|
|
Backend & | bkend, |
|
|
const std::size_t | buffer_size = 65536, |
|
|
std::size_t | hash_table_size = 1024 ) |
|
inline |
Definition at line 24 of file profile.hpp.
24 :
29 {
31
35
38 item.mru.prev = prev;
39 item.mru.next = reinterpret_cast<list_header*>(&item + 1);
40 prev = &item.mru;
41 }
45
48
49 fd =
open(file.c_str(), O_WRONLY | O_CREAT | O_TRUNC, 0755);
51 }
const DebugInfo & get_debug() const
backend_t bkend(hello_wasm, ehm, &wa)
void init_backtrace(const Context &context)
const profile_instr_map & addr_map
std::vector< item > items_storage
std::vector< item * > table_storage
std::vector< char > outbuf_storage
◆ ~profile_data() [1/2]
sysio::vm::profile_data::~profile_data |
( |
| ) |
|
|
inline |
Definition at line 52 of file profile.hpp.
52 {
57 }
void close(T *e, websocketpp::connection_hdl hdl)
◆ profile_data() [2/2]
template<typename Backend >
sysio::vm::profile_data::profile_data |
( |
const std::string & | file, |
|
|
Backend & | bkend, |
|
|
const std::size_t | buffer_size = 65536, |
|
|
std::size_t | hash_table_size = 1024 ) |
|
inline |
Definition at line 24 of file profile.hpp.
24 :
29 {
31
35
38 item.mru.prev = prev;
39 item.mru.next = reinterpret_cast<list_header*>(&item + 1);
40 prev = &item.mru;
41 }
45
48
49 fd =
open(file.c_str(), O_WRONLY | O_CREAT | O_TRUNC, 0755);
51 }
◆ ~profile_data() [2/2]
sysio::vm::profile_data::~profile_data |
( |
| ) |
|
|
inline |
◆ evict_oldest() [1/2]
item * sysio::vm::profile_data::evict_oldest |
( |
| ) |
|
|
inline |
Definition at line 149 of file profile.hpp.
149 {
151 if(result->bucket != 0xFFFFFFFFu) {
153 for(item** entry = &table[result->bucket]; ; entry = &(*entry)->next) {
154 if(*entry == result) {
155 *entry = result->next;
156 break;
157 }
158 }
159 result->bucket = 0xFFFFFFFFu;
160 }
161 return result;
162 }
void write(const char *data, std::size_t size)
◆ evict_oldest() [2/2]
item * sysio::vm::profile_data::evict_oldest |
( |
| ) |
|
|
inline |
Definition at line 149 of file profile.hpp.
149 {
151 if(result->bucket != 0xFFFFFFFFu) {
153 for(item** entry = &table[result->bucket]; ; entry = &(*entry)->next) {
154 if(*entry == result) {
155 *entry = result->next;
156 break;
157 }
158 }
159 result->bucket = 0xFFFFFFFFu;
160 }
161 return result;
162 }
◆ flush() [1/2]
void sysio::vm::profile_data::flush |
( |
| ) |
|
|
inline |
Definition at line 72 of file profile.hpp.
72 {
73 for(std::size_t i = 0; i <
outpos;) {
75 if(res == -1) {
76
77 break;
78 } else {
79 i += res;
80 }
81 }
83 }
◆ flush() [2/2]
void sysio::vm::profile_data::flush |
( |
| ) |
|
|
inline |
Definition at line 72 of file profile.hpp.
72 {
73 for(std::size_t i = 0; i <
outpos;) {
75 if(res == -1) {
76
77 break;
78 } else {
79 i += res;
80 }
81 }
83 }
◆ flush_hash() [1/2]
void sysio::vm::profile_data::flush_hash |
( |
| ) |
|
|
inline |
Definition at line 191 of file profile.hpp.
191 {
193 for(item* entry = table[i]; entry; entry = entry->next) {
195 entry->bucket = 0xFFFFFFFF;
196 }
197 table[i] = nullptr;
198 }
199 }
◆ flush_hash() [2/2]
void sysio::vm::profile_data::flush_hash |
( |
| ) |
|
|
inline |
Definition at line 191 of file profile.hpp.
191 {
193 for(item* entry = table[i]; entry; entry = entry->next) {
195 entry->bucket = 0xFFFFFFFF;
196 }
197 table[i] = nullptr;
198 }
199 }
◆ handle_tick() [1/2]
void sysio::vm::profile_data::handle_tick |
( |
void ** | data, |
|
|
int | count ) |
|
inline |
Definition at line 202 of file profile.hpp.
202 {
204
205 std::size_t out = 0;
206
209 if(addr != 0xFFFFFFFFu) {
210 if(out > 0) {
211 ++addr;
212 }
213 entry->frames[out++] = addr;
214 }
215 }
216 if(out != 0) {
217 entry->len = out;
218 if(out % 2 == 0) {
219 entry->frames[out] = 0;
220 }
222 }
223 }
std::uint32_t translate(const void *pc) const
void insert_hash(item *new_item)
static constexpr std::size_t max_frames
◆ handle_tick() [2/2]
void sysio::vm::profile_data::handle_tick |
( |
void ** | data, |
|
|
int | count ) |
|
inline |
Definition at line 202 of file profile.hpp.
202 {
204
205 std::size_t out = 0;
206
209 if(addr != 0xFFFFFFFFu) {
210 if(out > 0) {
211 ++addr;
212 }
213 entry->frames[out++] = addr;
214 }
215 }
216 if(out != 0) {
217 entry->len = out;
218 if(out % 2 == 0) {
219 entry->frames[out] = 0;
220 }
222 }
223 }
◆ init_backtrace() [1/2]
template<typename Context >
void sysio::vm::profile_data::init_backtrace |
( |
const Context & | context | ) |
|
|
inline |
Definition at line 241 of file profile.hpp.
241 {
243 return static_cast<const Context*
>(ctx)->backtrace(data,
len, uc);
244 };
246 }
sysio::client::http::http_context context
int(* get_backtrace_fn)(const void *, void **, int, void *)
const void * exec_context
◆ init_backtrace() [2/2]
template<typename Context >
void sysio::vm::profile_data::init_backtrace |
( |
const Context & | context | ) |
|
|
inline |
Definition at line 241 of file profile.hpp.
241 {
243 return static_cast<const Context*
>(ctx)->backtrace(data,
len, uc);
244 };
246 }
◆ insert_hash() [1/2]
void sysio::vm::profile_data::insert_hash |
( |
item * | new_item | ) |
|
|
inline |
Definition at line 174 of file profile.hpp.
174 {
175 std::size_t hash = new_item->hash();
177 for(item* bucket_entry = table[idx]; bucket_entry; bucket_entry = bucket_entry->next) {
179 ++bucket_entry->count;
181 return;
182 }
183 }
184 new_item->next = table[idx];
185 new_item->bucket = idx;
186 new_item->count = 1;
187 table[idx] = new_item;
189 }
void move_to_head(list_header *new_head)
static bool traces_equal(const item *lhs, const item *rhs)
◆ insert_hash() [2/2]
void sysio::vm::profile_data::insert_hash |
( |
item * | new_item | ) |
|
|
inline |
Definition at line 174 of file profile.hpp.
174 {
175 std::size_t hash = new_item->hash();
177 for(item* bucket_entry = table[idx]; bucket_entry; bucket_entry = bucket_entry->next) {
179 ++bucket_entry->count;
181 return;
182 }
183 }
184 new_item->next = table[idx];
185 new_item->bucket = idx;
186 new_item->count = 1;
187 table[idx] = new_item;
189 }
◆ move_to_head() [1/2]
void sysio::vm::profile_data::move_to_head |
( |
list_header * | new_head | ) |
|
|
inline |
Definition at line 164 of file profile.hpp.
164 {
165 new_head->unlink();
170 }
◆ move_to_head() [2/2]
void sysio::vm::profile_data::move_to_head |
( |
list_header * | new_head | ) |
|
|
inline |
Definition at line 164 of file profile.hpp.
164 {
165 new_head->unlink();
170 }
◆ traces_equal() [1/2]
static bool sysio::vm::profile_data::traces_equal |
( |
const item * | lhs, |
|
|
const item * | rhs ) |
|
inlinestatic |
Definition at line 133 of file profile.hpp.
133 {
134 if(lhs->len != rhs->len) {
135 return false;
136 }
137 for(
uint32_t i = 0; i < lhs->len; ++i) {
138 if(lhs->frames[i] != rhs->frames[i]) {
139 return false;
140 }
141 }
142 return true;
143 }
◆ traces_equal() [2/2]
static bool sysio::vm::profile_data::traces_equal |
( |
const item * | lhs, |
|
|
const item * | rhs ) |
|
inlinestatic |
Definition at line 133 of file profile.hpp.
133 {
134 if(lhs->len != rhs->len) {
135 return false;
136 }
137 for(
uint32_t i = 0; i < lhs->len; ++i) {
138 if(lhs->frames[i] != rhs->frames[i]) {
139 return false;
140 }
141 }
142 return true;
143 }
◆ write() [1/4]
void sysio::vm::profile_data::write |
( |
const char * | data, |
|
|
std::size_t | size ) |
|
inline |
◆ write() [2/4]
void sysio::vm::profile_data::write |
( |
const char * | data, |
|
|
std::size_t | size ) |
|
inline |
◆ write() [3/4]
void sysio::vm::profile_data::write |
( |
const item * | item | ) |
|
|
inline |
Definition at line 145 of file profile.hpp.
145 {
146 write(
reinterpret_cast<const char*
>(&item->count), (2+item->len) *
sizeof(std::uint32_t));
147 }
◆ write() [4/4]
void sysio::vm::profile_data::write |
( |
const item * | item | ) |
|
|
inline |
Definition at line 145 of file profile.hpp.
145 {
146 write(
reinterpret_cast<const char*
>(&item->count), (2+item->len) *
sizeof(std::uint32_t));
147 }
◆ write_header() [1/2]
void sysio::vm::profile_data::write_header |
( |
| ) |
|
|
inline |
Definition at line 58 of file profile.hpp.
58 {
60 0,
61 3,
62 0,
64 0
65 };
66 write(
reinterpret_cast<const char*
>(header),
sizeof(header));
67 }
uint32_t profile_interval_us
◆ write_header() [2/2]
void sysio::vm::profile_data::write_header |
( |
| ) |
|
|
inline |
Definition at line 58 of file profile.hpp.
58 {
60 0,
61 3,
62 0,
64 0
65 };
66 write(
reinterpret_cast<const char*
>(header),
sizeof(header));
67 }
◆ write_trailer() [1/2]
void sysio::vm::profile_data::write_trailer |
( |
| ) |
|
|
inline |
Definition at line 68 of file profile.hpp.
68 {
70 write(
reinterpret_cast<const char*
>(trailer),
sizeof(trailer));
71 }
◆ write_trailer() [2/2]
void sysio::vm::profile_data::write_trailer |
( |
| ) |
|
|
inline |
Definition at line 68 of file profile.hpp.
68 {
70 write(
reinterpret_cast<const char*
>(trailer),
sizeof(trailer));
71 }
◆ addr_map
◆ exec_context
const void * sysio::vm::profile_data::exec_context |
◆ fd
int sysio::vm::profile_data::fd |
◆ get_backtrace_fn
int(* sysio::vm::profile_data::get_backtrace_fn)(const void *, void **, int, void *) |
◆ items_storage
std::vector< item > sysio::vm::profile_data::items_storage |
◆ max_frames
static constexpr std::size_t sysio::vm::profile_data::max_frames = 251 |
|
staticconstexpr |
◆ mru_list
◆ outbuf
char * sysio::vm::profile_data::outbuf |
◆ outbuf_storage
std::vector< char > sysio::vm::profile_data::outbuf_storage |
◆ outpos
std::size_t sysio::vm::profile_data::outpos |
◆ outsize
std::size_t sysio::vm::profile_data::outsize |
◆ table
item ** sysio::vm::profile_data::table |
◆ table_size
std::size_t sysio::vm::profile_data::table_size |
◆ table_storage
std::vector< item * > sysio::vm::profile_data::table_storage |
The documentation for this struct was generated from the following files: