aboutsummaryrefslogtreecommitdiffstats
path: root/core/module-save.h
diff options
context:
space:
mode:
authoreunhhu <[email protected]>2026-09-29 06:35:05 +0100
committereunhhu <[email protected]>2026-09-29 06:35:05 +0100
commitc8f0704b6f88f331be24a89df7d7cb6a4bf29164 (patch)
treeeb47503b5dd08e1d993b3c81eb06b37b608166d6 /core/module-save.h
parentc97e4e1a203d13852d5f7cd4a404f88b44f4064f (diff)
downloadpure-c8f0704b6f88f331be24a89df7d7cb6a4bf29164.tar.gz
pure-c8f0704b6f88f331be24a89df7d7cb6a4bf29164.zip
Keep the outbox as a list: a save logs only the sends and trims it made
The sends not yet trimmed were written whole into the links value at every save, as the numbers heard were: a sender whose receiver is away or slow saved all its waiting sends again with each new one. They are now a runtime list {output (its name), seq, payload}, in the order sent, stored as a list state is (image "0sent" and its changes in the log). A send is a change of the list with its event; a trim lets the sends go at once and a failed save brings them back; the host sees the saved ones (sent_saved). Outputs are named in the items, so a module replaced keeps them without moving anything; one that lacks or changed an output with sends left is refused as before. Links stored before (PLK1, PLK2) move their sends to the list at a start and are stored again without them (PLK3). A list field may now hold any bytes (kind 2), unchecked, besides a number and a UTF-8 text. Saving 5,000 sends of 16 KB one by one took 84.8 s and left a store of 400 MB; now 0.91 s and 144 MB. 20,000 of 61 bytes: 8.4 s, now 2.9 s.
Diffstat (limited to 'core/module-save.h')
-rw-r--r--core/module-save.h32
1 files changed, 17 insertions, 15 deletions
diff --git a/core/module-save.h b/core/module-save.h
index 32e68c7..1d6440d 100644
--- a/core/module-save.h
+++ b/core/module-save.h
@@ -24,27 +24,29 @@ PureResult pure_save_image(PureApp *, const PureModule *m, uint32_t state, const
void pure_save_close_start(PureApp *);
/* The log keeps only the entries some list's image does not hold yet. */
void pure_save_release(PureApp *);
-/* A snapshot's list (module.c): a state's, or the heard list's
- * (PURE_LIST_HEARD) in a snapshot made with it (pure_save_snapshot). */
+/* A snapshot's list (module.c): a state's, or a runtime list's (place
+ * PURE_LIST_HEARD on) in a snapshot made with it (pure_save_snapshot;
+ * UINT32_MAX: none). */
const PureList *pure_snapshot_list(const PureSnapshot *, uint32_t state);
-PureSnapshot *pure_save_snapshot(PureApp *, bool heard);
-/* The heard list of a starting app (module.h, PureApp): from its image with
- * its logged changes made again, or new (saved.rewrite: it needs an image,
- * which pure_save_heard_image writes). */
-PureResult pure_save_open_heard(PureApp *, PureList **out, PureSaved *saved);
-PureResult pure_save_heard_image(PureApp *);
-/* An empty heard list. */
-PureList *pure_heard_new(void);
+PureSnapshot *pure_save_snapshot(PureApp *, uint32_t runtime);
+/* A runtime list of a starting app (module.h, PureApp; place is
+ * PURE_LIST_HEARD or PURE_LIST_OUTBOX): from its image with its logged
+ * changes made again, or new (saved.rewrite: it needs an image, which
+ * pure_save_runtime_image writes). */
+PureResult pure_save_open_runtime(PureApp *, uint32_t place, PureList **out, PureSaved *saved);
+PureResult pure_save_runtime_image(PureApp *, uint32_t place);
+/* An empty runtime list. */
+PureList *pure_runtime_list_new(uint32_t place);
/* Open the stored numbers, cursors and indices, and put each stored one of the
* same name and kind that still fits into values, for the states of m that
* kept marks as new (-1); texts and lists are m's. */
PureResult pure_save_open_values(PureApp *, const PureModule *m, double *values, const int *kept,
PureDraft *const *texts, PureList *const *lists);
-/* The stored links of a starting app (module.h, PureApp); CONFLICT when an
- * output with sends left is missing or has other fields. Links stored before
- * the heard list kept the numbers heard: they go to it (moved: it needs an
- * image). */
-PureResult pure_save_open_links(PureApp *, const PureModule *m, bool *moved);
+/* The stored links of a starting app (module.h, PureApp), after its runtime
+ * lists; CONFLICT when an output with sends left in the outbox is missing or
+ * has other fields. Links stored before the runtime lists kept the numbers
+ * heard and the sends: they go to them (moved: they need images). */
+PureResult pure_save_open_links(PureApp *, const PureModule *m, bool *heard_moved, bool *sent_moved);
/* Publish the documents and every state changed since the last save
* (values are the states' numbers); revisions are the documents'. */
PureResult pure_save_commit(PureApp *, const double *values, void *const *documents, size_t document_count,