Line data Source code
1 : #include "../../util/pod/fd_pod_format.h"
2 :
3 : #include "../../disco/topo/fd_topo.h"
4 : #include "../../disco/store/fd_store.h"
5 : #include "../../flamenco/runtime/fd_bank.h"
6 : #include "../../flamenco/runtime/fd_runtime.h"
7 : #include "../../flamenco/runtime/fd_txncache_shmem.h"
8 :
9 27 : #define VAL(name) (__extension__({ \
10 27 : ulong __x = fd_pod_queryf_ulong( topo->props, ULONG_MAX, "obj.%lu.%s", obj->id, name ); \
11 27 : if( FD_UNLIKELY( __x==ULONG_MAX ) ) FD_LOG_ERR(( "obj.%lu.%s was not set", obj->id, name )); \
12 27 : __x; }))
13 :
14 : static ulong
15 : banks_footprint( fd_topo_t const * topo,
16 3 : fd_topo_obj_t const * obj ) {
17 3 : return fd_banks_footprint( VAL("max_live_slots"), VAL("max_fork_width") );
18 3 : }
19 :
20 : static ulong
21 : banks_align( fd_topo_t const * topo FD_FN_UNUSED,
22 3 : fd_topo_obj_t const * obj FD_FN_UNUSED ) {
23 3 : return fd_banks_align();
24 3 : }
25 :
26 : static void
27 : banks_new( fd_topo_t const * topo,
28 0 : fd_topo_obj_t const * obj ) {
29 0 : FD_TEST( fd_banks_new( fd_topo_obj_laddr( topo, obj->id ), VAL("max_live_slots"), VAL("max_fork_width") ) );
30 0 : }
31 :
32 : fd_topo_obj_callbacks_t fd_obj_cb_banks = {
33 : .name = "banks",
34 : .footprint = banks_footprint,
35 : .align = banks_align,
36 : .new = banks_new,
37 : };
38 :
39 : static ulong
40 : bh_cmp_footprint( fd_topo_t const * topo,
41 3 : fd_topo_obj_t const * obj ) {
42 3 : (void)topo; (void)obj;
43 3 : return fd_bank_hash_cmp_footprint();
44 3 : }
45 :
46 : static ulong
47 : bh_cmp_align( fd_topo_t const * topo,
48 3 : fd_topo_obj_t const * obj ) {
49 3 : (void)topo; (void)obj;
50 3 : return fd_bank_hash_cmp_align();
51 3 : }
52 :
53 : static void
54 : bh_cmp_new( fd_topo_t const * topo,
55 0 : fd_topo_obj_t const * obj ) {
56 0 : (void)topo; (void)obj;
57 0 : FD_TEST( fd_bank_hash_cmp_new( fd_topo_obj_laddr( topo, obj->id ) ) );
58 0 : }
59 :
60 : fd_topo_obj_callbacks_t fd_obj_cb_bank_hash_cmp = {
61 : .name = "bh_cmp",
62 : .footprint = bh_cmp_footprint,
63 : .align = bh_cmp_align,
64 : .new = bh_cmp_new,
65 : };
66 :
67 : static ulong
68 : funk_align( fd_topo_t const * topo,
69 3 : fd_topo_obj_t const * obj ) {
70 3 : (void)topo; (void)obj;
71 3 : return fd_funk_align();
72 3 : }
73 :
74 : static ulong
75 : funk_footprint( fd_topo_t const * topo,
76 3 : fd_topo_obj_t const * obj ) {
77 3 : (void)topo;
78 3 : return fd_funk_footprint( VAL("txn_max"), VAL("rec_max") );
79 3 : }
80 :
81 : static ulong
82 : funk_loose( fd_topo_t const * topo,
83 3 : fd_topo_obj_t const * obj ) {
84 3 : (void)topo;
85 3 : return VAL("heap_max");
86 3 : }
87 :
88 : static void
89 : funk_new( fd_topo_t const * topo,
90 0 : fd_topo_obj_t const * obj ) {
91 0 : ulong funk_seed = fd_pod_queryf_ulong( topo->props, 0UL, "obj.%lu.seed", obj->id );
92 0 : if( !funk_seed ) FD_TEST( fd_rng_secure( &funk_seed, sizeof(ulong) ) );
93 0 : FD_TEST( fd_funk_new( fd_topo_obj_laddr( topo, obj->id ), 2UL, funk_seed, VAL("txn_max"), VAL("rec_max") ) );
94 0 : }
95 :
96 : fd_topo_obj_callbacks_t fd_obj_cb_funk = {
97 : .name = "funk",
98 : .footprint = funk_footprint,
99 : .loose = funk_loose,
100 : .align = funk_align,
101 : .new = funk_new,
102 : };
103 :
104 : static ulong
105 : fec_sets_footprint( fd_topo_t const * topo,
106 3 : fd_topo_obj_t const * obj ) {
107 3 : return VAL("sz");
108 3 : }
109 :
110 : static ulong
111 : fec_sets_align( fd_topo_t const * topo FD_FN_UNUSED,
112 3 : fd_topo_obj_t const * obj FD_FN_UNUSED ) {
113 3 : return fd_dcache_align();
114 3 : }
115 :
116 : static void
117 : fec_sets_new( FD_PARAM_UNUSED fd_topo_t const * topo,
118 0 : FD_PARAM_UNUSED fd_topo_obj_t const * obj ) {
119 0 : FD_TEST( fd_topo_obj_laddr( topo, obj->id ) );
120 0 : }
121 :
122 : fd_topo_obj_callbacks_t fd_obj_cb_fec_sets = {
123 : .name = "fec_sets",
124 : .footprint = fec_sets_footprint,
125 : .align = fec_sets_align,
126 : .new = fec_sets_new,
127 : };
128 :
129 : static ulong
130 : store_footprint( fd_topo_t const * topo,
131 3 : fd_topo_obj_t const * obj ) {
132 3 : return fd_store_footprint( VAL("fec_max") );
133 3 : }
134 :
135 : static ulong
136 : store_align( fd_topo_t const * topo FD_FN_UNUSED,
137 3 : fd_topo_obj_t const * obj FD_FN_UNUSED ) {
138 3 : return fd_store_align();
139 3 : }
140 :
141 : static void
142 : store_new( fd_topo_t const * topo,
143 0 : fd_topo_obj_t const * obj ) {
144 0 : FD_TEST( fd_store_new( fd_topo_obj_laddr( topo, obj->id ), VAL("fec_max"), VAL("part_cnt") ) );
145 0 : }
146 :
147 : fd_topo_obj_callbacks_t fd_obj_cb_store = {
148 : .name = "store",
149 : .footprint = store_footprint,
150 : .align = store_align,
151 : .new = store_new,
152 : };
153 :
154 : static ulong
155 : txncache_footprint( fd_topo_t const * topo,
156 3 : fd_topo_obj_t const * obj ) {
157 3 : return fd_txncache_shmem_footprint( VAL("max_live_slots"), VAL("max_txn_per_slot") );
158 3 : }
159 :
160 : static ulong
161 : txncache_align( fd_topo_t const * topo FD_FN_UNUSED,
162 3 : fd_topo_obj_t const * obj FD_FN_UNUSED ) {
163 3 : return fd_txncache_shmem_align();
164 3 : }
165 :
166 : static void
167 : txncache_new( fd_topo_t const * topo,
168 0 : fd_topo_obj_t const * obj ) {
169 0 : FD_TEST( fd_txncache_shmem_new( fd_topo_obj_laddr( topo, obj->id ), VAL("max_live_slots"), VAL("max_txn_per_slot") ) );
170 0 : }
171 :
172 : fd_topo_obj_callbacks_t fd_obj_cb_txncache = {
173 : .name = "txncache",
174 : .footprint = txncache_footprint,
175 : .align = txncache_align,
176 : .new = txncache_new,
177 : };
178 :
179 : static ulong
180 : exec_spad_footprint( fd_topo_t const * topo FD_FN_UNUSED,
181 24 : fd_topo_obj_t const * obj FD_FN_UNUSED ) {
182 24 : return fd_spad_footprint( FD_EXEC_TXN_CTX_FOOTPRINT + FD_RUNTIME_TRANSACTION_EXECUTION_FOOTPRINT_DEFAULT );
183 24 : }
184 :
185 : static ulong
186 : exec_spad_align( fd_topo_t const * topo FD_FN_UNUSED,
187 24 : fd_topo_obj_t const * obj FD_FN_UNUSED ) {
188 24 : return fd_spad_align();
189 24 : }
190 :
191 : static void
192 : exec_spad_new( fd_topo_t const * topo,
193 0 : fd_topo_obj_t const * obj ) {
194 0 : FD_TEST( fd_spad_new( fd_topo_obj_laddr( topo, obj->id ), FD_RUNTIME_TRANSACTION_EXECUTION_FOOTPRINT_DEFAULT ) );
195 0 : }
196 :
197 : fd_topo_obj_callbacks_t fd_obj_cb_exec_spad = {
198 : .name = "exec_spad",
199 : .footprint = exec_spad_footprint,
200 : .align = exec_spad_align,
201 : .new = exec_spad_new,
202 : };
203 :
204 : #undef VAL
|