Line data Source code
1 : #include "../../vinyl/fd_vinyl.h"
2 : #include "../../disco/topo/fd_topo.h"
3 : #include "../../discof/restore/utils/fd_vinyl_admin.h"
4 : #include "../../flamenco/accdb/fd_vinyl_req_pool.h"
5 : #include "../../util/pod/fd_pod_format.h"
6 :
7 0 : #define VAL(name) (__extension__({ \
8 0 : ulong __x = fd_pod_queryf_ulong( topo->props, ULONG_MAX, "obj.%lu.%s", obj->id, name ); \
9 0 : if( FD_UNLIKELY( __x==ULONG_MAX ) ) FD_LOG_ERR(( "obj.%lu.%s was not set", obj->id, name )); \
10 0 : __x; }))
11 :
12 :
13 : /* vinyl_meta: a shared memory separately chained hash map */
14 :
15 : static ulong
16 : vinyl_meta_align( fd_topo_t const * topo,
17 0 : fd_topo_obj_t const * obj ) {
18 0 : (void)topo; (void)obj;
19 0 : return fd_vinyl_meta_align();
20 0 : }
21 :
22 : static ulong
23 : vinyl_meta_footprint( fd_topo_t const * topo,
24 0 : fd_topo_obj_t const * obj ) {
25 0 : return fd_vinyl_meta_footprint( VAL("ele_max"), VAL("lock_cnt"), VAL("probe_max") );
26 0 : }
27 :
28 : static void
29 : vinyl_meta_new( fd_topo_t const * topo,
30 0 : fd_topo_obj_t const * obj ) {
31 0 : FD_TEST( fd_vinyl_meta_new( fd_topo_obj_laddr( topo, obj->id ), VAL("ele_max"), VAL("lock_cnt"), VAL("probe_max"), VAL("seed") ) );
32 0 : }
33 :
34 : fd_topo_obj_callbacks_t fd_obj_cb_vinyl_meta = {
35 : .name = "vinyl_meta",
36 : .footprint = vinyl_meta_footprint,
37 : .align = vinyl_meta_align,
38 : .new = vinyl_meta_new,
39 : };
40 :
41 : /* vinyl_meta_ele: hash map elements of vinyl_meta */
42 :
43 : static ulong
44 : vinyl_meta_ele_align( fd_topo_t const * topo,
45 0 : fd_topo_obj_t const * obj ) {
46 0 : (void)topo; (void)obj;
47 0 : return fd_ulong_max( alignof(fd_vinyl_meta_ele_t), 128UL );
48 0 : }
49 :
50 : static ulong
51 : vinyl_meta_ele_footprint( fd_topo_t const * topo,
52 0 : fd_topo_obj_t const * obj ) {
53 0 : return fd_ulong_align_up( sizeof(fd_vinyl_meta_ele_t) * VAL("cnt"), vinyl_meta_ele_align( topo, obj ) );
54 0 : }
55 :
56 : static void
57 : vinyl_meta_ele_new( fd_topo_t const * topo,
58 0 : fd_topo_obj_t const * obj ) {
59 : /* On Zen 4:
60 : - non-temporal wide stores are fastest
61 : - scattering 8 byte writes is slower
62 : - memset is slowest */
63 :
64 0 : # if FD_HAS_AVX512
65 0 : uchar * m0 = fd_topo_obj_laddr( topo, obj->id );
66 0 : uchar * m1 = m0 + vinyl_meta_ele_footprint( topo, obj );
67 0 : __m512i zero = _mm512_setzero_si512();
68 0 : for( uchar * m=m0; m<m1; m+=64 ) {
69 0 : _mm512_stream_si512( (__m512i *)m, zero );
70 0 : }
71 0 : _mm_sfence();
72 : # else
73 0 : fd_vinyl_meta_ele_t * ele = fd_topo_obj_laddr( topo, obj->id );
74 0 : ulong cnt = VAL("cnt");
75 0 : for( ulong i=0UL; i<cnt; i++ ) {
76 0 : ele[ i ].phdr.ctl = 0UL;
77 0 : }
78 0 : # endif
79 0 : }
80 :
81 : fd_topo_obj_callbacks_t fd_obj_cb_vinyl_meta_ele = {
82 : .name = "vinyl_meta_e",
83 : .footprint = vinyl_meta_ele_footprint,
84 : .align = vinyl_meta_ele_align,
85 : .new = vinyl_meta_ele_new,
86 : };
87 :
88 : /* vinyl_data: memory arena for data cache entries */
89 :
90 : static ulong
91 : vinyl_data_align( fd_topo_t const * topo,
92 0 : fd_topo_obj_t const * obj ) {
93 0 : (void)topo; (void)obj;
94 0 : return alignof(fd_vinyl_data_obj_t);
95 0 : }
96 :
97 : static ulong
98 : vinyl_data_footprint( fd_topo_t const * topo,
99 0 : fd_topo_obj_t const * obj ) {
100 0 : return fd_ulong_align_dn( VAL("data_sz"), alignof(fd_vinyl_data_obj_t) );
101 0 : }
102 :
103 : static void
104 : vinyl_data_new( fd_topo_t const * topo,
105 0 : fd_topo_obj_t const * obj ) {
106 0 : (void)topo; (void)obj;
107 : /* initialized by user */
108 0 : }
109 :
110 : fd_topo_obj_callbacks_t fd_obj_cb_vinyl_data = {
111 : .name = "vinyl_data",
112 : .footprint = vinyl_data_footprint,
113 : .align = vinyl_data_align,
114 : .new = vinyl_data_new,
115 : };
116 :
117 : /* vinyl_req_pool: request allocator */
118 :
119 : static ulong
120 : vinyl_req_pool_align( fd_topo_t const * topo,
121 0 : fd_topo_obj_t const * obj ) {
122 0 : (void)topo; (void)obj;
123 0 : return fd_vinyl_req_pool_align();
124 0 : }
125 :
126 : static ulong
127 : vinyl_req_pool_footprint( fd_topo_t const * topo,
128 0 : fd_topo_obj_t const * obj ) {
129 0 : return fd_vinyl_req_pool_footprint( VAL("batch_max"), VAL("batch_key_max") );
130 0 : }
131 :
132 : static void
133 : vinyl_req_pool_new( fd_topo_t const * topo,
134 0 : fd_topo_obj_t const * obj ) {
135 0 : FD_TEST( fd_vinyl_req_pool_new( fd_topo_obj_laddr( topo, obj->id ), VAL("batch_max"), VAL("batch_key_max") ) );
136 0 : }
137 :
138 : fd_topo_obj_callbacks_t fd_obj_cb_vinyl_req_pool = {
139 : .name = "vinyl_rpool",
140 : .footprint = vinyl_req_pool_footprint,
141 : .align = vinyl_req_pool_align,
142 : .new = vinyl_req_pool_new,
143 : };
144 :
145 : /* vinyl_rq: request queue */
146 :
147 : static ulong
148 : vinyl_rq_align( fd_topo_t const * topo,
149 0 : fd_topo_obj_t const * obj ) {
150 0 : (void)topo; (void)obj;
151 0 : return fd_vinyl_rq_align();
152 0 : }
153 :
154 : static ulong
155 : vinyl_rq_footprint( fd_topo_t const * topo,
156 0 : fd_topo_obj_t const * obj ) {
157 0 : return fd_vinyl_rq_footprint( VAL("req_cnt") );
158 0 : }
159 :
160 : static void
161 : vinyl_rq_new( fd_topo_t const * topo,
162 0 : fd_topo_obj_t const * obj ) {
163 0 : FD_TEST( fd_vinyl_rq_new( fd_topo_obj_laddr( topo, obj->id ), VAL("req_cnt") ) );
164 0 : }
165 :
166 : fd_topo_obj_callbacks_t fd_obj_cb_vinyl_rq = {
167 : .name = "vinyl_rq",
168 : .footprint = vinyl_rq_footprint,
169 : .align = vinyl_rq_align,
170 : .new = vinyl_rq_new,
171 : };
172 :
173 : /* vinyl_cq: completion queue */
174 :
175 : static ulong
176 : vinyl_cq_align( fd_topo_t const * topo,
177 0 : fd_topo_obj_t const * obj ) {
178 0 : (void)topo; (void)obj;
179 0 : return fd_vinyl_cq_align();
180 0 : }
181 :
182 : static ulong
183 : vinyl_cq_footprint( fd_topo_t const * topo,
184 0 : fd_topo_obj_t const * obj ) {
185 0 : return fd_vinyl_cq_footprint( VAL("comp_cnt") );
186 0 : }
187 :
188 : static void
189 : vinyl_cq_new( fd_topo_t const * topo,
190 0 : fd_topo_obj_t const * obj ) {
191 0 : FD_TEST( fd_vinyl_cq_new( fd_topo_obj_laddr( topo, obj->id ), VAL("comp_cnt") ) );
192 0 : }
193 :
194 : fd_topo_obj_callbacks_t fd_obj_cb_vinyl_cq = {
195 : .name = "vinyl_cq",
196 : .footprint = vinyl_cq_footprint,
197 : .align = vinyl_cq_align,
198 : .new = vinyl_cq_new,
199 : };
200 :
201 : static ulong
202 : vinyl_admin_footprint( fd_topo_t const * topo FD_PARAM_UNUSED,
203 0 : fd_topo_obj_t const * obj FD_PARAM_UNUSED ) {
204 0 : return sizeof(fd_vinyl_admin_t);
205 0 : }
206 :
207 : static ulong
208 : vinyl_admin_align( fd_topo_t const * topo FD_PARAM_UNUSED,
209 0 : fd_topo_obj_t const * obj FD_PARAM_UNUSED ) {
210 0 : return alignof(fd_vinyl_admin_t);
211 0 : }
212 :
213 : static void
214 : vinyl_admin_new( fd_topo_t const * topo,
215 0 : fd_topo_obj_t const * obj ) {
216 0 : fd_vinyl_admin_new( fd_topo_obj_laddr( topo, obj->id ) );
217 0 : }
218 :
219 : fd_topo_obj_callbacks_t fd_obj_cb_vinyl_admin = {
220 : .name = "vinyl_admin",
221 : .footprint = vinyl_admin_footprint,
222 : .align = vinyl_admin_align,
223 : .new = vinyl_admin_new,
224 : };
225 :
226 : #undef VAL
|