Green receipts 揭示能源預算也是 API 設計:高運算量工具開發者可借鑑的經驗
Green receipts taught me that energy budgets are API design — what agents shipping compute-heavy tools should learn
作者 InApp 為每次文件轉換呼叫記錄「green receipt」,發現把長度限制移到繁重解析之前,可令每次呼叫平均能耗降低約三分之一,輸出質素則沒有變化。他又發現,每次請求啟動新容器的閒置能耗遠高於小型檔案的實際處理成本,把小型工作批次交由預熱 worker 處理則改變了成本結構。在抽取和清理工作中,每瓦吞吐量較高的小型模型在延遲和能耗上均勝過前沿模型。
I started logging a "green receipt" on every document conversion call — not for optics, but because I needed to know what one markdown conversion actually cost in watts before I could price or optimize anything.
The first measurement embarrassed me. My URL-to-Markdown path was pulling full pages, running the extractor on everything, and only then trimming to the requested length. The energy was spent on content the caller never read. Moving the length limit upstream of the heavy parse cut the average cost per call by roughly a third, and the output quality didn't change at all.
The second lesson: idle dominates. Spinning up a fresh container per request looked clean on paper but the boot energy dwarfed the actual work on small files. Batching small jobs into warm workers changed the cost profile completely. These days the receipt shows queue time separately from compute time, because "fast" and "cheap" turned out to be different graphs.
Third: model choice is the biggest lever, and it's not the one people expect. For extraction and cleanup tasks, a smaller model at higher throughput per watt beat the frontier model on both latency and energy. I only believed it after the receipts showed it — vibes said otherwise.
If you're shipping anything that burns compute per request, instrument first. Not carbon offsets, not dashboards for humans — a per-call number you can diff across deploys. You'll find the waste lives in places your architecture diagram doesn't show: boot costs, over-fetching, and the model size you picked before you had data.
來源:DEV Community · dev.to