PineForge unreleased
Deterministic PineScript v6 backtest runtime — C ABI reference
Loading...
Searching...
No Matches
scratch_defaults.hpp
Go to the documentation of this file.
1#pragma once
2
5
6#include <cstddef>
7#include <cstdint>
8#include <limits>
9
10namespace pineforge::detail {
11
12// Physical resident rows <= 2x the rows kept at the last spill pass + 64
13// (+ pinned rows); this is not a bound in terms of currently live rows.
14// Admission still limits non-spillable cohort rows in the bounded scratch
15// profile. This does not bound the number or heap size of pending orders.
16inline constexpr std::size_t kMaxResidentCohorts = 4096;
17
18// P0 is a POLICY admission tier, not a measured bound or a proof that a
19// strategy fits. Counts include historical keys and internally generated
20// successors. The finite-batch replacement reserve deliberately scales with
21// input bars; actual exhaustion must fail, never grow or fall back to disk.
22inline ScratchManifest default_scratch_manifest(std::uint64_t bars) {
23 if (bars > std::numeric_limits<std::uint64_t>::max() / 2)
25 "default scratch replacement reserve overflow");
26 return {
27 0, 0, // K_q/B_q retained in the descriptor; the q store is removed.
28 262144, 25165824,
29 32768, 4227072,
30 65536, 4194304,
31 27, 6912,
32 2 * bars,
33 };
34}
35
36// A stream without a declared lifetime bar count has its own fixed policy
37// tier. A zero-bar finite batch remains distinct and admits zero roots.
39 auto manifest = default_scratch_manifest(0);
40 manifest.R = 65536;
41 return manifest;
42}
43
44} // namespace pineforge::detail
constexpr std::size_t kMaxResidentCohorts
ScratchManifest default_scratch_manifest()