soma.cell

E0065: scale_memory

E0065 scale_memory — the scale section contradicts the memory section.

A compile-time error of soma check, the checker of the Soma programming language (soma explain E0065).

The rule

The memory: value of a scale section must be a size: a number with an optional unit such as 512Mi, 8Gi, 256K, 2G, or plain bytes. A value check cannot read means no memory budget is proven, and the binary says deploy would write the string out as it stands. Replace it with a size such as "512Mi". (The one-line description from soma explain speaks of a contradiction between sections; the message soma check actually prints for this code is about an unreadable size.)

A program that triggers it

wrong.cell

cell Sessions {
    memory {
        sessions: Map<String, String> [persistent]
    }
    scale {
        replicas: 3
        memory: "half a gig"
    }
    on open(token: String, user: String) {
        sessions.set(token, user)
        return token
    }
}

What soma check prints:

$ soma check wrong.cell
error: scale memory "half a gig" in cell 'Sessions' is not a size — no budget is proven and deploy writes it out as it stands. Write a number with an optional unit: 512Mi, 8Gi, 1Ti, 256K, 2G or plain bytes
  --> wrong.cell:5:5
  |
5 |     scale {
  |     ^
  = code: E0065
✗ 1 error(s), 0 warning(s).

The fix field of soma check --json: no budget is proven and deploy writes it out as it stands. Write a number with an optional unit: 512Mi, 8Gi, 1Ti, 256K, 2G or plain bytes

On line 7, memory: "half a gig" becomes memory: "512Mi".

wrong.cell → right.cell

--- wrong.cell
+++ right.cell
@@ -5,5 +5,5 @@
     scale {
         replicas: 3
-        memory: "half a gig"
+        memory: "512Mi"
     }
     on open(token: String, user: String) {

With the fix, soma check accepts the program:

$ soma check right.cell
✓ budget holds for cell 'Sessions' while its slots stay within their assumed sizes: peak ≤ 66.11 MiB ≤ declared 512.00 MiB
    breakdown: slots 42.11 MiB + max-handler 8.00 MiB + state 0 B + runtime 16.00 MiB
    assumed: each slot within [capacity(N)] / [max_key_bytes(N)] / [max_value_bytes(N)] (else 10 000 entries of 256-byte keys and 4 KiB values) — not enforced at run time
✓ All checks passed (1 note above).