bend: handler returns formatted string + http-listener ships strings raw
The previous attempt to ship a pretty summary via an (summary "...") field inside the structured response broke on the asm (WAT) tier because read-from-string isn't a primitive there — the demo extraction fell through to the raw fallback and dumped the entire escaped S-expression. Two-part fix that works on all three tiers: http-listener (gpu-worker.lsp:1103-1116) — POST response builder now checks if the handle-request return value is a string and ships it as the raw HTTP body in that case. S-expression returns still go through write-to-string. One-line guard, no impact on ping/health/cuda-shake-fanout/cuda-sim-ops-bin which all keep returning structured S-exps. handle-cuda-secp256k1-bench — returns the formatted summary string directly instead of an (ok ... (summary ...)) wrapping. Drops the now-redundant structured fields; every number lives inside the human-readable text already. asm / c / python demo just calls (display (bend!-call "(cuda-secp256k1-bench N)")) and the formatted output panel renders identically on all tiers. Demo simplified accordingly: three (display (bend!-call …)) calls with newlines between, no read-from-string / assoc / pair? dance.
This commit is contained in:
parent
8edb752382
commit
036fab47fa
3 changed files with 31 additions and 40 deletions
|
|
@ -450,15 +450,12 @@
|
|||
(display count)
|
||||
(display " gpu-ms=") (display gpu-ms)
|
||||
(display " mkeys-s=") (display gpu-rate) (newline)
|
||||
(list 'ok
|
||||
(list 'n count)
|
||||
(list 'gen-ms gen-ms)
|
||||
(list 'gpu-ms gpu-ms)
|
||||
(list 'gpu-mkeys-per-sec gpu-rate)
|
||||
(list 'cpu-rate-mkeys-per-sec cpu-rate)
|
||||
(list 'cpu-est-sec cpu-est-sec)
|
||||
(list 'speedup-est speedup)
|
||||
(list 'summary summary)))))))))))))
|
||||
;; Return the formatted summary string directly
|
||||
;; (caught by http-listener's string? guard, sent
|
||||
;; raw — no S-exp escape soup in the playground
|
||||
;; output). The structured fields all live inside
|
||||
;; the human text.
|
||||
summary)))))))))))
|
||||
|
||||
;; Format a non-negative integer with thousand-separator commas.
|
||||
;; (with-commas 100000000) → "100,000,000".
|
||||
|
|
@ -1103,7 +1100,15 @@
|
|||
((string=? method "POST")
|
||||
(let* ((sexp (read-from-string body))
|
||||
(resp (handle-request sexp))
|
||||
(resp-text (write-to-string resp)))
|
||||
;; Pre-formatted text responses (e.g. the bench's
|
||||
;; pretty summary) come back as a string; send raw
|
||||
;; so the browser sees clean multi-line text
|
||||
;; instead of an escape-quoted "\"...\\n...\"".
|
||||
;; Structured S-exp responses still get
|
||||
;; write-to-string.
|
||||
(resp-text (cond
|
||||
((string? resp) resp)
|
||||
(else (write-to-string resp)))))
|
||||
(write-http-response client 200 resp-text
|
||||
"text/plain; charset=utf-8")
|
||||
(tcp-close client)))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue