modus
Menu
On this page

The entry persistence_check

The source src/modules/tests/persistence_check built with the setting DRAWING_THROUGH_MODULE=true. The text after this paragraph is the comment of that source.

A test process that keeps its state when it stops and when the machine stops: a note and a count, in its private store. Only a machine test starts it: the tests of persistence, of a loss of power and of the limit of a store (tools/modustool/machine/persistence_scenario.odin, power_loss.odin). The notes application of the principal is the module notes.

Each change goes to the storage service when it happens: the process has no save action. The note is the object "note". The count is the object "count": three blocks that each hold the count in each of their 512 numbers, so that a part of one commit with a part of another would show.

Keys: a character adds to the note, Backspace removes the last one, Enter writes the note on the log. Tab counts 1000 more, one commit for each step.

Versions: each key is one commit, and the storage service keeps the state before it as a version, so the process has undo to any earlier version with no code of its own to keep them. Up shows the version before the one shown, Down the one after; Enter restores the version shown (a new commit: nothing is lost); Escape goes back to the current note. The bar under the note has one mark for each version.

What it is for. It is the smallest process that shows persistence as a property of the system and not of the process: no file, no path, no save action, and undo with no code of its own. Each key is one commit, so a test knows the generation of each state. The test of a loss of power stops the machine during the run of Tab, then checks at the next start that the three blocks of the count agree.

Start: start("persistence_check") in the console. The note holds 60 characters at most.

Grants, as the root service gives them:

  • Store: its private store in the storage service, with a limit of 4500 blocks: the versions of a run of 1000 commits of the count, then thinning at the limit. The root service starts the storage service first.

What a reader sees: the note, the count, the generation of the last commit and a bar with one mark for each version. The log has, at the start, one of:

  • persistence_check: a new store: no note, the count 0;
  • persistence_check: restored the note "..." and the count N, its 3 blocks agree;
  • persistence_check: WRONG: ... when an object is damaged or the 3 blocks do not agree;
  • persistence_check: no store when the process has no store: it then keeps nothing.

What it does not prove: one writer only. Two processes never share the note: each private store belongs to one process.

The design: and.

See: Notes in the repository, Storage: Versions, thinning and the limit, Storage: A loss of power

persistence_check module with an entry

Hash
e340d4374777d4cbfb5bfac1be4893a4ae41707a26275ff8c02457bd482fc376
Size
225192 bytes
Exports
0
Imports
1
Imported by
0
License
MIT

A test process that keeps its state when it stops and when the machine stops: a note and a count, in its private store

FactValue
KindModules with an entry
Sourcesrc/modules/tests/persistence_check
Boot imageyes: in the boot image, 225192 bytes in this build
Build settings
  • DRAWING_THROUGH_MODULE=true
Imports
Imported bynone

Neighbours

What it imports, at its left, and what imports it, at its right: the part of the module graph that touches it.

persistence_check drawing

Exports

ExportWhat it does
entry()The entry of persistence_check: it restores the note and the count from its store, then commits each key until the principal closes the window

entry

entry()

The entry of persistence_check: it restores the note and the count from its store, then commits each key until the principal closes the window.

With no window it stops with Failed. With no store it runs, and keeps nothing. With a store it reads the note, the count and the list of the versions of the note (restore, history_read), and writes the line of the start on the log.

Then one loop waits for keys and draws after each one:

  • a printable character or Backspace: one commit of the object "note";
  • Tab: 1000 commits of the object "count", one for each step, with a log line every 100 steps, then the time of the run and the time to list the versions of the count;
  • Enter: the note, its generation, its count of versions and the mean time of one commit, on the log;
  • Up, Down: show an older or a newer version of the note; Enter then restores it in one commit, and Escape goes back to the current note.
Form
The entry of the module: one parameter, an address, fixed by the contract.
Source
src/modules/tests/persistence_check/main.odin:453

Read from the source of the module, as the build reads it to describe the exports (tools/modustool/build/describe.odin).

What the root service gives it

WhatValueAs the root service says
GrantsThe test of persistence: its note, its count and their versions live in its private store: the versions of a run of 1000 commits of the count (4 blocks each), then thinning at the limit.
Other terms of its start grant setstore_blocks = 4500
Budget that it asks for
  • working memory pages 1683
  • pages of its threads 72
  • pages of the pictures of its window 1458
  • pages of the module and its imports from the files of the build
  • processes the least
  • threads the least
The least budget of 2048 pages, in which it ran before it stated its window, less that window at the scale 1 (365 pages): its module, its stack, its tables and its glyph memory. The tool counts the window at the window bound. See: Module contract: The budget that a module asks for

The start grant set is read from start_grant_sets in src/modules/system/root/start_grant_sets.odin. The stated budget is read from the constant MODULE_BUDGET of the source of the module (its line); the build adds the counted parts and writes the sum in the module (tools/modustool/build/budget_count.odin); the root service accepts it up to the largest budget of a process, and adds the limits of processor time and of log records (src/modules/system/root/budgets.odin).

history_read procedure of the package persistence_check

history_read :: proc "contextless" ()

A procedure with no comment in its source.

src/modules/tests/persistence_check/main.odin:120