Skip to content

Commit

Permalink
perf counter cleanup (mostly intervals)
Browse files Browse the repository at this point in the history
Some of these perf counters were useful during initial development, but realistically aren't needed anymore, some are redundant when we can now see the average interval from `work_queue status` and some of them simply aren't worth the cost at higher rates.
  • Loading branch information
dagar committed Oct 28, 2019
1 parent f7e6234 commit a59a0b6
Show file tree
Hide file tree
Showing 10 changed files with 11 additions and 73 deletions.
7 changes: 1 addition & 6 deletions src/drivers/dshot/dshot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@ class DShotOutput : public cdev::CDev, public ModuleBase<DShotOutput>, public Ou
bool _outputs_initialized{false};

perf_counter_t _cycle_perf;
perf_counter_t _cycle_interval_perf;

void capture_callback(uint32_t chan_index,
hrt_abstime edge_time, uint32_t edge_state, uint32_t overflow);
Expand All @@ -247,8 +246,7 @@ px4::atomic_bool DShotOutput::_request_telemetry_init{false};
DShotOutput::DShotOutput() :
CDev("/dev/dshot"),
OutputModuleInterface(MODULE_NAME, px4::wq_configurations::hp_default),
_cycle_perf(perf_alloc(PC_ELAPSED, "dshot: cycle")),
_cycle_interval_perf(perf_alloc(PC_INTERVAL, "dshot: cycle interval"))
_cycle_perf(perf_alloc(PC_ELAPSED, MODULE_NAME": cycle"))
{
_mixing_output.setAllDisarmedValues(DISARMED_VALUE);
_mixing_output.setAllMinValues(DISARMED_VALUE + 1);
Expand All @@ -265,7 +263,6 @@ DShotOutput::~DShotOutput()
unregister_class_devname(PWM_OUTPUT_BASE_DEVICE_PATH, _class_instance);

perf_free(_cycle_perf);
perf_free(_cycle_interval_perf);
delete _telemetry;
}

Expand Down Expand Up @@ -756,7 +753,6 @@ DShotOutput::Run()
}

perf_begin(_cycle_perf);
perf_count(_cycle_interval_perf);

_mixing_output.update();

Expand Down Expand Up @@ -1667,7 +1663,6 @@ int DShotOutput::print_status()
PX4_INFO("Outputs initialized: %s", _outputs_initialized ? "yes" : "no");
PX4_INFO("Outputs on: %s", _outputs_on ? "yes" : "no");
perf_print_counter(_cycle_perf);
perf_print_counter(_cycle_interval_perf);
_mixing_output.printStatus();
if (_telemetry) {
PX4_INFO("telemetry on: %s", _telemetry_device);
Expand Down
7 changes: 1 addition & 6 deletions src/drivers/px4fmu/fmu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ class PX4FMU : public cdev::CDev, public ModuleBase<PX4FMU>, public OutputModule
unsigned _num_disarmed_set{0};

perf_counter_t _cycle_perf;
perf_counter_t _cycle_interval_perf;

void capture_callback(uint32_t chan_index,
hrt_abstime edge_time, uint32_t edge_state, uint32_t overflow);
Expand All @@ -212,8 +211,7 @@ class PX4FMU : public cdev::CDev, public ModuleBase<PX4FMU>, public OutputModule
PX4FMU::PX4FMU() :
CDev(PX4FMU_DEVICE_PATH),
OutputModuleInterface(MODULE_NAME, px4::wq_configurations::hp_default),
_cycle_perf(perf_alloc(PC_ELAPSED, "px4fmu: cycle")),
_cycle_interval_perf(perf_alloc(PC_INTERVAL, "px4fmu: cycle interval"))
_cycle_perf(perf_alloc(PC_ELAPSED, MODULE_NAME": cycle"))
{
_mixing_output.setAllMinValues(PWM_DEFAULT_MIN);
_mixing_output.setAllMaxValues(PWM_DEFAULT_MAX);
Expand All @@ -229,7 +227,6 @@ PX4FMU::~PX4FMU()
unregister_class_devname(PWM_OUTPUT_BASE_DEVICE_PATH, _class_instance);

perf_free(_cycle_perf);
perf_free(_cycle_interval_perf);
}

int
Expand Down Expand Up @@ -755,7 +752,6 @@ PX4FMU::Run()
}

perf_begin(_cycle_perf);
perf_count(_cycle_interval_perf);

_mixing_output.update();

Expand Down Expand Up @@ -2305,7 +2301,6 @@ int PX4FMU::print_status()
}

perf_print_counter(_cycle_perf);
perf_print_counter(_cycle_interval_perf);
_mixing_output.printStatus();

return 0;
Expand Down
2 changes: 1 addition & 1 deletion src/drivers/rc_input/RCInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ constexpr char const *RCInput::RC_SCAN_STRING[];

RCInput::RCInput(bool run_as_task, char *device) :
_cycle_perf(perf_alloc(PC_ELAPSED, MODULE_NAME": cycle time")),
_publish_interval_perf(perf_alloc(PC_INTERVAL, MODULE_NAME": publish interval"))
_publish_interval_perf(perf_alloc(PC_INTERVAL, MODULE_NAME": publish interval"))
{
// rc input, published to ORB
_rc_in.input_source = input_rc_s::RC_INPUT_SOURCE_PX4FMU_PPM;
Expand Down
6 changes: 5 additions & 1 deletion src/lib/drivers/accelerometer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,8 @@
############################################################################

px4_add_library(drivers_accelerometer PX4Accelerometer.cpp)
target_link_libraries(drivers_accelerometer PRIVATE drivers__device)
target_link_libraries(drivers_accelerometer
PRIVATE
drivers__device
mathlib
)
13 changes: 0 additions & 13 deletions src/modules/ekf2/ekf2_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,6 @@ class Ekf2 final : public ModuleBase<Ekf2>, public ModuleParams, public px4::Wor
uint64_t _start_time_us = 0; ///< system time at EKF start (uSec)
int64_t _last_time_slip_us = 0; ///< Last time slip (uSec)

perf_counter_t _cycle_perf;
perf_counter_t _interval_perf;
perf_counter_t _ekf_update_perf;

// Initialise time stamps used to send sensor data to the EKF and for logging
Expand Down Expand Up @@ -549,8 +547,6 @@ Ekf2::Ekf2(bool replay_mode):
ModuleParams(nullptr),
WorkItem(MODULE_NAME, px4::wq_configurations::att_pos_ctrl),
_replay_mode(replay_mode),
_cycle_perf(perf_alloc_once(PC_ELAPSED, MODULE_NAME": cycle time")),
_interval_perf(perf_alloc_once(PC_INTERVAL, MODULE_NAME": interval")),
_ekf_update_perf(perf_alloc_once(PC_ELAPSED, MODULE_NAME": update")),
_params(_ekf.getParamHandle()),
_param_ekf2_min_obs_dt(_params->sensor_interval_min_ms),
Expand Down Expand Up @@ -656,8 +652,6 @@ Ekf2::Ekf2(bool replay_mode):

Ekf2::~Ekf2()
{
perf_free(_cycle_perf);
perf_free(_interval_perf);
perf_free(_ekf_update_perf);
}

Expand All @@ -679,8 +673,6 @@ int Ekf2::print_status()

PX4_INFO("time slip: %" PRId64 " us", _last_time_slip_us);

perf_print_counter(_cycle_perf);
perf_print_counter(_interval_perf);
perf_print_counter(_ekf_update_perf);

return 0;
Expand Down Expand Up @@ -728,9 +720,6 @@ void Ekf2::Run()
return;
}

perf_begin(_cycle_perf);
perf_count(_interval_perf);

sensor_combined_s sensors;

if (_sensors_sub.update(&sensors)) {
Expand Down Expand Up @@ -1751,8 +1740,6 @@ void Ekf2::Run()
// publish ekf2_timestamps
_ekf2_timestamps_pub.publish(ekf2_timestamps);
}

perf_end(_cycle_perf);
}

int Ekf2::getRangeSubIndex()
Expand Down
7 changes: 1 addition & 6 deletions src/modules/mc_pos_control/mc_pos_control_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ class MulticopterPositionControl : public ModuleBase<MulticopterPositionControl>
WeatherVane *_wv_controller{nullptr};

perf_counter_t _cycle_perf;
perf_counter_t _interval_perf;

/**
* Update our local parameter cache.
Expand Down Expand Up @@ -289,8 +288,7 @@ MulticopterPositionControl::MulticopterPositionControl() :
_vel_y_deriv(this, "VELD"),
_vel_z_deriv(this, "VELD"),
_control(this),
_cycle_perf(perf_alloc_once(PC_ELAPSED, MODULE_NAME": cycle time")),
_interval_perf(perf_alloc_once(PC_INTERVAL, MODULE_NAME": interval"))
_cycle_perf(perf_alloc_once(PC_ELAPSED, MODULE_NAME": cycle time"))
{
// fetch initial parameter values
parameters_update(true);
Expand All @@ -306,7 +304,6 @@ MulticopterPositionControl::~MulticopterPositionControl()
}

perf_free(_cycle_perf);
perf_free(_interval_perf);
}

bool
Expand Down Expand Up @@ -515,7 +512,6 @@ MulticopterPositionControl::print_status()
}

perf_print_counter(_cycle_perf);
perf_print_counter(_interval_perf);

return 0;
}
Expand All @@ -530,7 +526,6 @@ MulticopterPositionControl::Run()
}

perf_begin(_cycle_perf);
perf_count(_interval_perf);

if (_local_pos_sub.update(&_local_pos)) {

Expand Down
16 changes: 1 addition & 15 deletions src/modules/sensors/vehicle_acceleration/VehicleAcceleration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,13 @@ using namespace time_literals;

VehicleAcceleration::VehicleAcceleration() :
ModuleParams(nullptr),
WorkItem(MODULE_NAME, px4::wq_configurations::att_pos_ctrl),
_cycle_perf(perf_alloc(PC_ELAPSED, "vehicle_acceleration: cycle time")),
_sensor_latency_perf(perf_alloc(PC_ELAPSED, "vehicle_acceleration: sensor latency"))
WorkItem(MODULE_NAME, px4::wq_configurations::att_pos_ctrl)
{
}

VehicleAcceleration::~VehicleAcceleration()
{
Stop();

perf_free(_cycle_perf);
perf_free(_sensor_latency_perf);
}

bool
Expand Down Expand Up @@ -175,16 +170,12 @@ VehicleAcceleration::ParametersUpdate(bool force)
void
VehicleAcceleration::Run()
{
perf_begin(_cycle_perf);

// update corrections first to set _selected_sensor
SensorCorrectionsUpdate();

sensor_accel_s sensor_data;

if (_sensor_sub[_selected_sensor].update(&sensor_data)) {
perf_set_elapsed(_sensor_latency_perf, hrt_elapsed_time(&sensor_data.timestamp));

ParametersUpdate();
SensorBiasUpdate();

Expand All @@ -207,15 +198,10 @@ VehicleAcceleration::Run()

_vehicle_acceleration_pub.publish(out);
}

perf_end(_cycle_perf);
}

void
VehicleAcceleration::PrintStatus()
{
PX4_INFO("selected sensor: %d", _selected_sensor);

perf_print_counter(_cycle_perf);
perf_print_counter(_sensor_latency_perf);
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
#include <lib/conversion/rotation.h>
#include <lib/mathlib/math/Limits.hpp>
#include <lib/matrix/matrix/math.hpp>
#include <lib/perf/perf_counter.h>
#include <px4_config.h>
#include <px4_log.h>
#include <px4_module_params.h>
Expand Down Expand Up @@ -101,9 +100,6 @@ class VehicleAcceleration : public ModuleParams, public px4::WorkItem
matrix::Vector3f _scale;
matrix::Vector3f _bias;

perf_counter_t _cycle_perf;
perf_counter_t _sensor_latency_perf;

uint8_t _selected_sensor{0};

};
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,13 @@ using namespace time_literals;

VehicleAngularVelocity::VehicleAngularVelocity() :
ModuleParams(nullptr),
WorkItem(MODULE_NAME, px4::wq_configurations::rate_ctrl),
_cycle_perf(perf_alloc(PC_ELAPSED, "vehicle_angular_velocity: cycle time")),
_sensor_latency_perf(perf_alloc(PC_ELAPSED, "vehicle_angular_velocity: sensor latency"))
WorkItem(MODULE_NAME, px4::wq_configurations::rate_ctrl)
{
}

VehicleAngularVelocity::~VehicleAngularVelocity()
{
Stop();

perf_free(_cycle_perf);
perf_free(_sensor_latency_perf);
}

bool
Expand Down Expand Up @@ -214,8 +209,6 @@ VehicleAngularVelocity::ParametersUpdate(bool force)
void
VehicleAngularVelocity::Run()
{
perf_begin(_cycle_perf);

// update corrections first to set _selected_sensor
SensorCorrectionsUpdate();

Expand All @@ -224,8 +217,6 @@ VehicleAngularVelocity::Run()
sensor_gyro_control_s sensor_data;

if (_sensor_control_sub[_selected_sensor].update(&sensor_data)) {
perf_set_elapsed(_sensor_latency_perf, hrt_elapsed_time(&sensor_data.timestamp));

ParametersUpdate();
SensorBiasUpdate();

Expand All @@ -251,8 +242,6 @@ VehicleAngularVelocity::Run()
sensor_gyro_s sensor_data;

if (_sensor_sub[_selected_sensor].update(&sensor_data)) {
perf_set_elapsed(_sensor_latency_perf, hrt_elapsed_time(&sensor_data.timestamp));

ParametersUpdate();
SensorBiasUpdate();

Expand All @@ -276,8 +265,6 @@ VehicleAngularVelocity::Run()
_vehicle_angular_velocity_pub.publish(angular_velocity);
}
}

perf_end(_cycle_perf);
}

void
Expand All @@ -291,7 +278,4 @@ VehicleAngularVelocity::PrintStatus()
} else {
PX4_WARN("sensor_gyro_control unavailable for selected sensor: %d (%d)", _selected_sensor_device_id, _selected_sensor);
}

perf_print_counter(_cycle_perf);
perf_print_counter(_sensor_latency_perf);
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
#include <lib/conversion/rotation.h>
#include <lib/mathlib/math/Limits.hpp>
#include <lib/matrix/matrix/math.hpp>
#include <lib/perf/perf_counter.h>
#include <px4_config.h>
#include <px4_log.h>
#include <px4_module_params.h>
Expand Down Expand Up @@ -109,9 +108,6 @@ class VehicleAngularVelocity : public ModuleParams, public px4::WorkItem
matrix::Vector3f _scale;
matrix::Vector3f _bias;

perf_counter_t _cycle_perf;
perf_counter_t _sensor_latency_perf;

uint32_t _selected_sensor_device_id{0};
uint8_t _selected_sensor{0};
uint8_t _selected_sensor_control{0};
Expand Down

0 comments on commit a59a0b6

Please sign in to comment.