aboutsummaryrefslogtreecommitdiffstats
path: root/core/module.h
diff options
context:
space:
mode:
authoreunhhu <[email protected]>2026-09-30 03:09:18 +0100
committereunhhu <[email protected]>2026-09-30 03:09:18 +0100
commita5ecc5f1ae83a6ad6d5522f826a1c6d2707264bc (patch)
tree1ddba7f4beef6955327e35cc4ee196206ca91146 /core/module.h
parenta6df26a8499522033277ce4f3cd76eee155169ee (diff)
downloadpure-a5ecc5f1ae83a6ad6d5522f826a1c6d2707264bc.tar.gz
pure-a5ecc5f1ae83a6ad6d5522f826a1c6d2707264bc.zip
Count only the states the memory budget counts
An event under a budget counted its states twice, before and after, walking every state. For the smallest event (a number added, no store) that cost 21 ns in an app of one state and 125 ns in one of 32 (+17 %, +38 %). The app now keeps a bit for each list (not a message's rows) and text when it opens its module, and walks those alone: +10 ns and +29 ns (+8 %, +9 %), and nothing without a budget. A served write costs tens of microseconds, so its throughput does not see it.
Diffstat (limited to 'core/module.h')
-rw-r--r--core/module.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/core/module.h b/core/module.h
index c11c682..69acd67 100644
--- a/core/module.h
+++ b/core/module.h
@@ -157,6 +157,8 @@ typedef struct { uint8_t form, relation; uint16_t field; uint32_t test; PureBloc
enum { PURE_MODULE_RANGES = 64 };
typedef struct { uint8_t lower_relation, upper_relation; PureBlock lower, upper; } PureRange;
+_Static_assert(PURE_MODULE_STATES <= 32, "a state is a bit of PureApp.counted");
+
typedef struct {
uint16_t states, inputs, views, handlers, fields, collections, constants, records, record_fields;
uint32_t code_count;
@@ -313,6 +315,7 @@ typedef struct {
PureFault fault;
uint32_t fault_pc;
size_t memory; /* the budget of what the states hold (0: none): pure_app_memory */
+ uint32_t counted; /* the states it counts, a bit each: lists (not a message's rows) and texts */
uint64_t ticks, events;
/* The time events see as now, in milliseconds since 1970 (UTC). The host
* sets it, so a script can replay any time; views never see it. */