aboutsummaryrefslogtreecommitdiffstats
path: root/serve/serve.c
diff options
context:
space:
mode:
authoreunhhu <[email protected]>2026-10-18 23:29:42 +0100
committereunhhu <[email protected]>2026-10-18 23:29:42 +0100
commitff2e0823e97d10477341192d72f5d9e61d9d5bad (patch)
treea882cce6e799ab2096ed3d3722e01ec357764e9b /serve/serve.c
parent1d255b735e92c2d6b360ed5ea150a1e42f6dd535 (diff)
downloadpure-ff2e0823e97d10477341192d72f5d9e61d9d5bad.tar.gz
pure-ff2e0823e97d10477341192d72f5d9e61d9d5bad.zip
027's 4f-2: no fixed count of states: the header's u16 alone (PURE_MODULE_STATES gone); a module's transient and counted states are flags of each, the lists views and functions change or name sets of states (state_words words, a bit each), the verifier's walked lists a list with its length, duplicate names found by sorting them; an app's eighteen arrays of each state (values, texts, lists, the stored lists' slots, the last save's and the burst's, a reader's, an event's values and marks) in one block sized to its module, a replace laying the new module's apart and taking it once nothing can fail; the runtime's lists placed past any state (PURE_LIST_HEARD 0x10000), their slots after the states'; a snapshot's arrays sized so too; pure_app_read false without room (pure-serve then shows none); a save's drafts, values and the tree's revisions on the stack for 64 states, else on the heap; the JIT compiles modules of 32 states at most (its sets a word), the app's lists read through a pointer; a view reads the app's values as they are (no state changes in one), no copy of 32 a evaluation; unit test: 300 states loaded and the last counted; a hole closed: pure_app_stop read the arrays a failed start never laid; PureApp 4,256 bytes, not 8,504; counts: b39b against b38 with batches within 0.06%, without batches knapsack +0.49%, join +0.23%, the rest within 0.17%; the bank's queries (s38 and s39b in turns, three each) field -1.99%, found -1.18%, in_credit -1.10%, large -0.99%, the rest -0.58% to +0.11% (the first build, s39, copied a view's values at run time's size: in_credit +2.4%); 008 and 027
Diffstat (limited to 'serve/serve.c')
-rw-r--r--serve/serve.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/serve/serve.c b/serve/serve.c
index 5881ffd..2dca1cb 100644
--- a/serve/serve.c
+++ b/serve/serve.c
@@ -2279,7 +2279,10 @@ static PureSnapshot *read_newest(PureApp *reader, App *app) {
PureSnapshot *snapshot = published->snapshot;
if (snapshot) pure_snapshot_hold(snapshot);
pthread_mutex_unlock(&published->lock);
- if (snapshot) pure_app_read(reader, snapshot);
+ if (snapshot && !pure_app_read(reader, snapshot)) { /* no room for its states: none shown */
+ pure_snapshot_release(snapshot);
+ snapshot = NULL;
+ }
reader->work_budget = atomic_load_explicit(&app->work, memory_order_relaxed);
reader->memory = atomic_load_explicit(&app->memory, memory_order_relaxed); /* what a view's body may add to its own lists */
return snapshot;
@@ -2847,7 +2850,11 @@ static PureResult run_query(const Job *job, PureSnapshot *snapshot, Applied *a)
return PURE_BUSY;
}
PureApp reader = {0};
- pure_app_read(&reader, snapshot);
+ if (!pure_app_read(&reader, snapshot)) {
+ pure_app_stop(&reader);
+ let_go_query(held);
+ return PURE_ALLOCATION;
+ }
if (reader.module != checked && !same_states(&held->module, reader.module)) { /* its app's states are laid out anew */
pure_app_stop(&reader);
let_go_query(held);
@@ -3178,7 +3185,10 @@ static PureSnapshot *surface_read(PureSurfaceHost *s, PureApp *reader) {
PureSnapshot *snapshot = published->snapshot;
if (snapshot) pure_snapshot_hold(snapshot);
pthread_mutex_unlock(&published->lock);
- if (snapshot) pure_app_read(reader, snapshot);
+ if (snapshot && !pure_app_read(reader, snapshot)) { /* no room for its states: none shown */
+ pure_snapshot_release(snapshot);
+ snapshot = NULL;
+ }
return snapshot;
}