Berry add 'gc_heap' and 'gc_time' to 'tasmota.memory()' (#24054)
This commit is contained in:
parent
e42d061bdf
commit
4ccc9f69fd
@ -9,6 +9,7 @@ All notable changes to this project will be documented in this file.
|
|||||||
- Berry `cb.free_cb` for extension manager (#24014)
|
- Berry `cb.free_cb` for extension manager (#24014)
|
||||||
- Berry `light.get()` direct access to values (#24033)
|
- Berry `light.get()` direct access to values (#24033)
|
||||||
- HostedMCU file update using command `HostedLoad <version>|<filename>`
|
- HostedMCU file update using command `HostedLoad <version>|<filename>`
|
||||||
|
- Berry add `gc_heap` and `gc_time` to `tasmota.memory()`
|
||||||
|
|
||||||
### Breaking Changed
|
### Breaking Changed
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
6
tasmota/berry/extensions/Wifi_Heap_Sticker/autoexec.be
Normal file
6
tasmota/berry/extensions/Wifi_Heap_Sticker/autoexec.be
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
# rm Wifi_Heap_Sticker.tapp; zip -j -0 Wifi_Heap_Sticker.tapp Wifi_Heap_Sticker/autoexec.be Wifi_Heap_Sticker/wifi_heap_sticker.be Wifi_Heap_Sticker/manifest.json
|
||||||
|
do # embed in `do` so we don't add anything to global namespace
|
||||||
|
import introspect
|
||||||
|
var wifi_heap_sticker = introspect.module('wifi_heap_sticker', true) # load module but don't cache
|
||||||
|
tasmota.add_extension(wifi_heap_sticker)
|
||||||
|
end
|
||||||
@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "Wifi Memory Sticker",
|
"name": "Wifi Heap Sticker",
|
||||||
"version": "0x19090100",
|
"version": "0x190A0100",
|
||||||
"description": "Display top left sticker with Wifi strength and memory heap",
|
"description": "Display top left sticker with Wifi strength and memory heap",
|
||||||
"author": "Stephan Hadinger",
|
"author": "Stephan Hadinger",
|
||||||
"min_tasmota": "0x0F000100",
|
"min_tasmota": "0x0F010001",
|
||||||
"features": ""
|
"features": ""
|
||||||
}
|
}
|
||||||
@ -1,12 +1,12 @@
|
|||||||
#######################################################################
|
#######################################################################
|
||||||
# Wifi Memory Sticker
|
# Wifi Heap Sticker
|
||||||
#
|
#
|
||||||
# Sticker to show realtime wifi strengh and memory (top left of main page)
|
# Sticker to show realtime wifi strengh and memory (top left of main page)
|
||||||
|
|
||||||
#################################################################################
|
#################################################################################
|
||||||
# Wifi_Memory_Sticker
|
# Wifi_Heap_Sticker
|
||||||
#################################################################################
|
#################################################################################
|
||||||
class Wifi_Memory_Sticker
|
class Wifi_Heap_Sticker
|
||||||
|
|
||||||
static var HTTP_HEAD_STYLE_WIFI =
|
static var HTTP_HEAD_STYLE_WIFI =
|
||||||
"<style>"
|
"<style>"
|
||||||
@ -43,8 +43,14 @@ class Wifi_Memory_Sticker
|
|||||||
rssi >= -85 ? "active" : ""))
|
rssi >= -85 ? "active" : ""))
|
||||||
end
|
end
|
||||||
# display free heap
|
# display free heap
|
||||||
webserver.content_send(f"<span> {tasmota.memory('heap_free')}k</span>")
|
var gc_time = tasmota.memory('gc_time')
|
||||||
|
var gc_heap = tasmota.memory('gc_heap')
|
||||||
|
if (gc_time != nil) && (gc_heap != nil)
|
||||||
|
webserver.content_send(f"<span> {tasmota.memory('heap_free')}-{gc_heap}k [{gc_time}ms]</span>")
|
||||||
|
else
|
||||||
|
webserver.content_send(f"<span> {tasmota.memory('heap_free')}k</span>")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return Wifi_Memory_Sticker()
|
return Wifi_Heap_Sticker()
|
||||||
@ -1,6 +0,0 @@
|
|||||||
# rm Wifi_Memory_Sticker.tapp; zip -j -0 Wifi_Memory_Sticker.tapp Wifi_Memory_Sticker/autoexec.be Wifi_Memory_Sticker/wifi_memory_sticker.be Wifi_Memory_Sticker/manifest.json
|
|
||||||
do # embed in `do` so we don't add anything to global namespace
|
|
||||||
import introspect
|
|
||||||
var wifi_memory_sticker = introspect.module('wifi_memory_sticker', true) # load module but don't cache
|
|
||||||
tasmota.add_extension(wifi_memory_sticker)
|
|
||||||
end
|
|
||||||
@ -91,6 +91,8 @@ class BerrySupport {
|
|||||||
public:
|
public:
|
||||||
bvm *vm = nullptr; // berry vm
|
bvm *vm = nullptr; // berry vm
|
||||||
int32_t timeout = 0; // Berry heartbeat timeout, preventing code to run for too long. `0` means not enabled
|
int32_t timeout = 0; // Berry heartbeat timeout, preventing code to run for too long. `0` means not enabled
|
||||||
|
int32_t last_gc_tims_ms = -1; // Record the time taken by the last garbage collection in milliseconds, -1 means not yet collected
|
||||||
|
int32_t last_gc_heap_free = -1; // Record the free heap size after the last garbage collection, -1 means not yet collected
|
||||||
bool rules_busy = false; // are we already processing rules, avoid infinite loop
|
bool rules_busy = false; // are we already processing rules, avoid infinite loop
|
||||||
bool web_add_handler_done = false; // did we already sent `web_add_handler` event
|
bool web_add_handler_done = false; // did we already sent `web_add_handler` event
|
||||||
#ifdef USE_BERRY_LEDS_PANEL
|
#ifdef USE_BERRY_LEDS_PANEL
|
||||||
|
|||||||
@ -218,6 +218,13 @@ extern "C" {
|
|||||||
// give info about stack size
|
// give info about stack size
|
||||||
be_map_insert_int(vm, "stack_size", SET_ESP32_STACK_SIZE / 1024);
|
be_map_insert_int(vm, "stack_size", SET_ESP32_STACK_SIZE / 1024);
|
||||||
be_map_insert_real(vm, "stack_low", ((float)uxTaskGetStackHighWaterMark(nullptr)) / 1024);
|
be_map_insert_real(vm, "stack_low", ((float)uxTaskGetStackHighWaterMark(nullptr)) / 1024);
|
||||||
|
// values seen at last GC
|
||||||
|
if (berry.last_gc_tims_ms >= 0) {
|
||||||
|
be_map_insert_int(vm, "gc_time", berry.last_gc_tims_ms);
|
||||||
|
}
|
||||||
|
if (berry.last_gc_heap_free >= 0) {
|
||||||
|
be_map_insert_int(vm, "gc_heap", berry.last_gc_heap_free / 1024);
|
||||||
|
}
|
||||||
if (UsePSRAM()) {
|
if (UsePSRAM()) {
|
||||||
be_map_insert_int(vm, "psram", ESP.getPsramSize() / 1024);
|
be_map_insert_int(vm, "psram", ESP.getPsramSize() / 1024);
|
||||||
be_map_insert_int(vm, "psram_free", ESP.getFreePsram() / 1024);
|
be_map_insert_int(vm, "psram_free", ESP.getFreePsram() / 1024);
|
||||||
|
|||||||
@ -286,10 +286,15 @@ void BerryObservability(bvm *vm, int event...) {
|
|||||||
size_t slots_allocated_before_gc = va_arg(param, size_t);
|
size_t slots_allocated_before_gc = va_arg(param, size_t);
|
||||||
size_t slots_used_after_gc = va_arg(param, size_t);
|
size_t slots_used_after_gc = va_arg(param, size_t);
|
||||||
size_t slots_allocated_after_gc = va_arg(param, size_t);
|
size_t slots_allocated_after_gc = va_arg(param, size_t);
|
||||||
AddLog(LOG_LEVEL_DEBUG_MORE, D_LOG_BERRY "GC from %i to %i bytes, objects freed %i/%i (in %d ms) - slots from %i/%i to %i/%i",
|
if (HighestLogLevel() >= LOG_LEVEL_DEBUG_MORE) {
|
||||||
vm_usage, vm_usage2, vm_freed, vm_scanned, gc_elapsed,
|
AddLog(LOG_LEVEL_DEBUG_MORE, D_LOG_BERRY "GC from %i to %i bytes, objects freed %i/%i (in %d ms) - slots from %i/%i to %i/%i",
|
||||||
slots_used_before_gc, slots_allocated_before_gc,
|
vm_usage, vm_usage2, vm_freed, vm_scanned, gc_elapsed,
|
||||||
slots_used_after_gc, slots_allocated_after_gc);
|
slots_used_before_gc, slots_allocated_before_gc,
|
||||||
|
slots_used_after_gc, slots_allocated_after_gc);
|
||||||
|
}
|
||||||
|
// record last seen values
|
||||||
|
berry.last_gc_tims_ms = gc_elapsed;
|
||||||
|
berry.last_gc_heap_free = ESP_getFreeHeap();
|
||||||
|
|
||||||
#ifdef UBE_BERRY_DEBUG_GC
|
#ifdef UBE_BERRY_DEBUG_GC
|
||||||
// Add more in-deptch metrics
|
// Add more in-deptch metrics
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user