diff options
| author | eunhhu <[email protected]> | 2026-10-01 05:34:25 +0100 |
|---|---|---|
| committer | eunhhu <[email protected]> | 2026-10-01 05:34:25 +0100 |
| commit | be297ead16b41938e84bcc3f1be628bc8725f2f4 (patch) | |
| tree | 0f2e4a17b79781a751b2d8fe21e494384f1f0de6 /serve | |
| parent | d24881de03433c30ee619ee1eec3ae962ae3db19 (diff) | |
| download | pure-be297ead16b41938e84bcc3f1be628bc8725f2f4.tar.gz pure-be297ead16b41938e84bcc3f1be628bc8725f2f4.zip | |
Count work only under a budget, and say why a view failed only then (017)
The work budget added about 26 instructions to every row of a table a
host shows (bank, a table of 10,000 rows: +3.0% instructions an ask),
which 017's one-app criterion allows at 1%. A sample put most of it in
show_given asking every cell why it failed, and the rest in evaluate
and the row lookup writing that reason and the count for every cell.
Now nothing is counted without a budget (PureApp.work stays), the
reason is written only when a view, a cell or a row has no value, and
pure-serve asks it only of a cell without one. The table: +0.94%; the
other bank queries within 0.4%. The tests that read the count set a
budget that is never reached.
Diffstat (limited to 'serve')
| -rw-r--r-- | serve/serve.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/serve/serve.c b/serve/serve.c index 5ba137f..b7a122e 100644 --- a/serve/serve.c +++ b/serve/serve.c @@ -1425,28 +1425,27 @@ static PureResult show_given(PureApp *app, const Route *route, size_t available, for (unsigned k = 0; k < count; ++k) { put_bytes(&o, columns[k].key + !k, columns[k].length - !k); uint8_t kind = m->view_type[columns[k].view]; + bool valued; if (kind == PURE_VIEW_I64) { int64_t integer; - if (!pure_app_cell_i64(app, columns[k].view, row, &integer)) put_bytes(&o, "null", 4); - else put_integer(&o, integer); + if ((valued = pure_app_cell_i64(app, columns[k].view, row, &integer))) put_integer(&o, integer); } else if (kind == PURE_VIEW_NUM || kind == PURE_VIEW_BOOL) { - if (!pure_app_cell(app, columns[k].view, row, &value)) put_bytes(&o, "null", 4); - else if (kind == PURE_VIEW_BOOL) put_bytes(&o, value ? "true" : "false", value ? 4 : 5); + if (!(valued = pure_app_cell(app, columns[k].view, row, &value))) { + } else if (kind == PURE_VIEW_BOOL) put_bytes(&o, value ? "true" : "false", value ? 4 : 5); else put_number(&o, value); } else { size_t mark = o.size; put_bytes(&o, "\"", 1); - if (pure_app_cell_text(app, columns[k].view, row, put_json_span, &o) == PURE_OK) put_bytes(&o, "\"", 1); - else if (!o.failed) { - o.size = mark; - put_bytes(&o, "null", 4); - } + if ((valued = pure_app_cell_text(app, columns[k].view, row, put_json_span, &o) == PURE_OK)) put_bytes(&o, "\"", 1); + else o.size = o.failed ? o.size : mark; } + if (valued) continue; if (pure_app_view_fault(app) == PURE_FAULT_WORK) { /* a cell past the work budget fails the table */ status = PURE_LIMIT; end = row; break; } + put_bytes(&o, "null", 4); /* a cell without a value */ } put_bytes(&o, "}", 1); } |
