Skip to content

Commit

Permalink
optimze: reduced storage operations
Browse files Browse the repository at this point in the history
  • Loading branch information
LynnL4 committed Aug 10, 2024
1 parent b2daac2 commit 4e44ad5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
2 changes: 1 addition & 1 deletion porting/himax/we2/el_config_porting.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
#endif
#endif

#define CONFIG_EL_DEBUG 4 // use 0 to make firmware generator happy
#define CONFIG_EL_DEBUG 0 // use 0 to make firmware generator happy
#define CONFIG_EL_DEBUG_COLOR 0
#define CONFIG_EL_HAS_FREERTOS_SUPPORT 1
#define SSCMA_REPL_EXECUTOR_PRIO 2
Expand Down
24 changes: 14 additions & 10 deletions sscma/callback/invoke.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,11 +292,13 @@ class Invoke final : public std::enable_shared_from_this<Invoke> {
static_resource->executor->add_task(
[algorithm, cmd = std::move(argv[0]), value, ret, caller](const std::atomic<bool>&) mutable {
if (ret == EL_OK) [[likely]] {
algorithm->set_score_threshold(value);
ret = static_resource->storage->emplace(
el_make_storage_kv_from_type(algorithm->get_algorithm_config()))
? EL_OK
: EL_EIO;
if (algorithm->get_score_threshold() != value) [[likely]] {
algorithm->set_score_threshold(value);
ret = static_resource->storage->emplace(
el_make_storage_kv_from_type(algorithm->get_algorithm_config()))
? EL_OK
: EL_EIO;
}
}
auto ss{concat_strings("\r{\"type\": 0, \"name\": \"",
cmd,
Expand Down Expand Up @@ -341,11 +343,13 @@ class Invoke final : public std::enable_shared_from_this<Invoke> {
static_resource->executor->add_task(
[algorithm, cmd = std::move(argv[0]), value, ret, caller](const std::atomic<bool>&) mutable {
if (ret == EL_OK) [[likely]] {
algorithm->set_iou_threshold(value);
ret = static_resource->storage->emplace(
el_make_storage_kv_from_type(algorithm->get_algorithm_config()))
? EL_OK
: EL_EIO;
if (algorithm->get_iou_threshold() != value) [[likely]] {
algorithm->set_iou_threshold(value);
ret = static_resource->storage->emplace(
el_make_storage_kv_from_type(algorithm->get_algorithm_config()))
? EL_OK
: EL_EIO;
}
}
auto ss{concat_strings("\r{\"type\": 0, \"name\": \"",
cmd,
Expand Down
5 changes: 4 additions & 1 deletion sscma/callback/sensor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ void set_sensor(
ret = camera->init(opt_id); // TODO: custom resolution
if (ret != EL_OK) [[unlikely]]
goto SensorError;

#ifndef CONFIG_EL_BOARD_SENSECAP_WATCHER // watcher does not store sensor id
static_resource->storage->emplace(el_make_storage_kv(SSCMA_STORAGE_KEY_CONF_SENSOR_OPT, opt_id));
#endif
}

// set the sensor state to available
Expand All @@ -65,11 +66,13 @@ void set_sensor(
// if sensor id changed, update current sensor id
if (static_resource->current_sensor_id != sensor_id) {
static_resource->current_sensor_id = sensor_id;
#ifndef CONFIG_EL_BOARD_SENSECAP_WATCHER // watcher does not store sensor id
if (!called_by_event)
ret = static_resource->storage->emplace(
el_make_storage_kv(SSCMA_STORAGE_KEY_CONF_SENSOR_ID, static_resource->current_sensor_id))
? EL_OK
: EL_EIO;
#endif
}
} else
ret = EL_ENOTSUP;
Expand Down

0 comments on commit 4e44ad5

Please sign in to comment.