Skip to content

Commit

Permalink
Add new message to support native profiling of threads and resource u…
Browse files Browse the repository at this point in the history
…sage
  • Loading branch information
woodfell committed Jun 15, 2024
1 parent 4bfa982 commit 3a37ad2
Show file tree
Hide file tree
Showing 4 changed files with 276 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
---
description: Unit tests for swiftnav.sbp.profiling MSgProfilingResourceCounter
generated_on: 2024-02-01 00:00:00.00 # manually generated
package: sbp.profiling
tests:


- msg:
c_decoded_fields:
n_buckets:
handle_as: vararray-len
relates_to: buckets
value: 6
fields:
seq_no: 1
seq_len: 3
buckets:
- name: "Fusion engine\0\0\0\0\0\0\0\0"
thread: 1
mutex: 2
cv: 2
io: 0
heap_bytes_alloc: 927480
heap_bytes_free: 0
io_write: 0
io_read: 0
- name: "NTRIP client\0\0\0\0\0\0\0\0\0"
thread: 1
mutex: 1
cv: 1
io: 1
heap_bytes_alloc: 84454
heap_bytes_free: 0
io_write: 879
io_read: 19520
- name: "SSR2OSR\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
thread: 1
mutex: 1
cv: 1
io: 0
heap_bytes_alloc: 4328776
heap_bytes_free: 0
io_write: 0
io_read: 0
- name: "Periodic\0\0\0\0\0\0\0\0\0\0\0\0\0"
thread: 1
mutex: 2
cv: 1
io: 0
heap_bytes_alloc: 247112
heap_bytes_free: 0
io_write: 0
io_read: 0
- name: "IMU\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
thread: 1
mutex: 1
cv: 1
io: 1
heap_bytes_alloc: 18305
heap_bytes_free: 0
io_write: 0
io_read: 26207
- name: "sbp\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
thread: 5
mutex: 2
cv: 2
io: 2
heap_bytes_alloc: 43507
heap_bytes_free: 0
io_write: 235451
io_read: 498
module: sbp.profiling
name: MsgProfilingResourceCounter
msg_type: '0xcf03'
raw_json: >
{"crc": 39349, "preamble": 85, "sender": 4096, "length": 248, "msg_type": 52995,
"seq_no": 1, "seq_len": 3, "buckets": [
{"name": "Fusion engine\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000", "thread": 1, "mutex": 2, "cv": 2, "io": 0, "heap_bytes_alloc": 927480, "heap_bytes_free": 0, "io_write": 0, "io_read": 0},
{"name": "NTRIP client\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000", "thread": 1, "mutex": 1, "cv": 1, "io": 1, "heap_bytes_alloc": 84454, "heap_bytes_free": 0, "io_write": 879, "io_read": 19520},
{"name": "SSR2OSR\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000", "thread": 1, "mutex": 1, "cv": 1, "io": 0, "heap_bytes_alloc": 4328776, "heap_bytes_free": 0, "io_write": 0, "io_read": 0},
{"name": "Periodic\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000", "thread": 1, "mutex": 2, "cv": 1, "io": 0, "heap_bytes_alloc": 247112, "heap_bytes_free": 0, "io_write": 0, "io_read": 0},
{"name": "IMU\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000", "thread": 1, "mutex": 1, "cv": 1, "io": 1, "heap_bytes_alloc": 18305, "heap_bytes_free": 0, "io_write": 0, "io_read": 26207},
{"name": "sbp\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000", "thread": 5, "mutex": 2, "cv": 2, "io": 2, "heap_bytes_alloc": 43507, "heap_bytes_free": 0, "io_write": 235451, "io_read": 498}],
"payload": "AQNGdXNpb24gZW5naW5lAAAAAAAAAAABAgIA+CYOAAAAAAAAAAAAAAAAAE5UUklQIGNsaWVudAAAAAAAAAAAAAEBAQHmSQEAAAAAAG8DAABATAAAU1NSMk9TUgAAAAAAAAAAAAAAAAAAAQEBAEgNQgAAAAAAAAAAAAAAAABQZXJpb2RpYwAAAAAAAAAAAAAAAAABAgEASMUDAAAAAAAAAAAAAAAAAElNVQAAAAAAAAAAAAAAAAAAAAAAAAEBAQGBRwAAAAAAAAAAAABfZgAAc2JwAAAAAAAAAAAAAAAAAAAAAAAABQICAvOpAAAAAAAAu5cDAPIBAAA="}
raw_packet: VQPPABD4AQNGdXNpb24gZW5naW5lAAAAAAAAAAABAgIA+CYOAAAAAAAAAAAAAAAAAE5UUklQIGNsaWVudAAAAAAAAAAAAAEBAQHmSQEAAAAAAG8DAABATAAAU1NSMk9TUgAAAAAAAAAAAAAAAAAAAQEBAEgNQgAAAAAAAAAAAAAAAABQZXJpb2RpYwAAAAAAAAAAAAAAAAABAgEASMUDAAAAAAAAAAAAAAAAAElNVQAAAAAAAAAAAAAAAAAAAAAAAAEBAQGBRwAAAAAAAAAAAABfZgAAc2JwAAAAAAAAAAAAAAAAAAAAAAAABQICAvOpAAAAAAAAu5cDAPIBAAC1mQ==
sbp:
crc: '0x99b5'
length: 248
msg_type: '0xcf03'
payload: AQNGdXNpb24gZW5naW5lAAAAAAAAAAABAgIA+CYOAAAAAAAAAAAAAAAAAE5UUklQIGNsaWVudAAAAAAAAAAAAAEBAQHmSQEAAAAAAG8DAABATAAAU1NSMk9TUgAAAAAAAAAAAAAAAAAAAQEBAEgNQgAAAAAAAAAAAAAAAABQZXJpb2RpYwAAAAAAAAAAAAAAAAABAgEASMUDAAAAAAAAAAAAAAAAAElNVQAAAAAAAAAAAAAAAAAAAAAAAAEBAQGBRwAAAAAAAAAAAABfZgAAc2JwAAAAAAAAAAAAAAAAAAAAAAAABQICAvOpAAAAAAAAu5cDAPIBAAA=
preamble: '0x55'
sender: '0x1000'
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
description: Unit tests for swiftnav.sbp.profiling MsgProfilingSystemInfo
generated_on: 2024-02-01 00:00:00.00 # manually generated
package: sbp.profiling
tests:


- msg:
fields:
total_cpu_time: 3418210
age: 10292338
n_threads: 27
heap_usage: 14861128
module: sbp.profiling
name: MsgProfilingSystemInfo

msg_type: '0xcf01'
raw_json: >
{"crc": 16892, "preamble": 85, "sender": 4096, "length": 21, "msg_type": 52993,
"total_cpu_time": 3418210, "age": 10292338, "n_threads": 27, "heap_usage": 14861128,
"payload": "Yig0AAAAAAByDJ0AAAAAABtIw+IA"}
raw_packet: VQHPABAVYig0AAAAAAByDJ0AAAAAABtIw+IA/EE=
sbp:
crc: '0x41fc'
length: 21
msg_type: '0xcf01'
payload: Yig0AAAAAAByDJ0AAAAAABtIw+IA
preamble: '0x55'
sender: '0x1000'
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
description: Unit tests for swiftnav.sbp.profiling MsgProfilingThreadInfo
generated_on: 2024-02-01 00:00:00.00 # manually generated
package: sbp.profiling
tests:


- msg:
c_decoded_fields:
name:
handle_as: encoded-string
text: Fusion engine
fn_prefix: sbp_msg_profiling_thread_info_name
encoded_len: 14
fields:
total_cpu_time: 678775
age: 10159470
state: 1
stack_size: 8388608
stack_usage: 275920
name: "Fusion engine\u0000"
module: sbp.profiling
name: MsgProfilingThreadInfo

msg_type: '0xcf02'
raw_json: >
{"crc": 43762, "preamble": 85, "sender": 4096, "length": 39, "msg_type": 52994,
"total_cpu_time": 678775, "age": 10159470, "state": 1, "stack_size": 8388608,
"stack_usage": 275920, "name": "Fusion engine\u0000",
"payload": "d1sKAAAAAABuBZsAAAAAAAEAAIAA0DUEAEZ1c2lvbiBlbmdpbmUA"}
raw_packet: VQLPABAnd1sKAAAAAABuBZsAAAAAAAEAAIAA0DUEAEZ1c2lvbiBlbmdpbmUA8qo=
sbp:
crc: '0xaaf2'
length: 39
msg_type: '0xcf02'
payload: d1sKAAAAAABuBZsAAAAAAAEAAIAA0DUEAEZ1c2lvbiBlbmdpbmUA
preamble: '0x55'
sender: '0x1000'
117 changes: 117 additions & 0 deletions spec/yaml/swiftnav/sbp/profiling.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,120 @@ definitions:
type: string
encoding: null_terminated
desc: Function name

- MSG_PROFILING_SYSTEM_INFO:
id: 0xCF01
short_desc: System Profiling Information
desc: >
Contains basic information about system resource usage.
System is defined in terms of the source of this message and may vary from
sender to sender. Refer to product documentation to understand the exact scope
and meaning of this message.
fields:
- total_cpu_time:
type: u64
desc: Total cpu time in microseconds consumed by this system
- age:
type: u64
desc: Age of the producing system in microseconds
- n_threads:
type: u8
desc: Number of threads being tracked by this system
- heap_usage:
type: u32
desc: Number of bytes allocated on the heap

- MSG_PROFILING_THREAD_INFO:
id: 0xCF02
short_desc: Thread Profiling Information
desc: >
Contains profiling information related to a single thread being tracked by
the producing system. Refer to product documentation to understand the exact scope
and meaning of this message.
fields:
- total_cpu_time:
type: u64
desc: Total cpu time in microseconds consumed by this thread
- age:
type: u64
desc: Age of the thread in microseconds
- state:
type: u8
desc: Thread state
fields:
- 0-1:
desc: Thread state
values:
- 0: External
- 1: Running
- 2: Stopped
- 3: Reserved
- stack_size:
type: u32
desc: Stack size in bytes
- stack_usage:
type: u32
desc: Stack highwater usage in bytes
- name:
type: string
encoding: null_terminated
desc: Thread name

- ResourceBucket:
short_desc: A bucket containing various resources
desc: >
Information about allocation of various resources grouped by buckets. Refer to product
documentation to understand the meaning and values in this message.
fields:
- name:
type: string
encoding: null_terminated
size: 21
desc: Bucket name
- thread:
type: u8
desc: Number of threads
- mutex:
type: u8
desc: Number of mutexes
- cv:
type: u8
desc: Number of condition variables
- io:
type: u8
desc: Number of IO handles
- heap_bytes_alloc:
type: u32
desc: Number of bytes allocated on the heap
- heap_bytes_free:
type: u32
desc: Number of bytes freed on the heap
- io_write:
type: u32
desc: Number of bytes written to IO handles
- io_read:
type: u32
desc: Number of bytes read from IO handles


- MSG_PROFILING_RESOURCE_COUNTER:
id: 0xCF03
short_desc: Information about resource buckets
desc: >
Information about resource buckets. Refer to product documentation to understand
the meaning and values in this message.
fields:
- seq_no:
type: u8
desc: Message number in complete sequence
- seq_len:
type: u8
desc: Length of message sequence
- buckets:
type: array
fill: ResourceBucket
desc: List of resource buckets




0 comments on commit 3a37ad2

Please sign in to comment.