Skip to content

Commit a2106f7

Browse files
committed
disco: refactor tiles into standard layout
The tile code had been getting copy pasted and duplicated in interesting ways that were starting to show their age. This commit refactors all of the tiles onto a standard infrastructure, the mux tile. The mux tile is used because it is the most general. * All tiles are rewritten to be a small wrapper around the mux tile. The mux tile gains some functionality, namely the ability to make callbacks to the user, to enable the tiles to change its behavior. This eliminates a large amount of boilerplate and makes it obvious in what ways each tile deviate from the standard. Mux also gains the ability to filter fragments. * As part of this refactor, many of the deviations from the standard were removed because they were either no longer needed or were not correct. Some of these include, - Each flow control imlementation was subtly different, and these differences were dropped. All flow control is now standard mux logic. Same goes for deciding which (if any) producer to poll. - Redundant metrics written to the cnc diagnostic region by the QUIC tile are removed. - Some tiles republished ctl, tspub, and other fields, and some did not. All tiles now republish as appropriate. - The pack tile distributed to N consumers with N mcaches, rather than 1 like the mux tile. It also repurposed flow control credits to be used as a "pack" credit, which wasn't being initialized correctly but also was unclear. - Various others. * The boundary between fdctl and frank has been removed, and the boundary betwen (what was) frank and disco has been clarified. The tiles in disco are an API, with fdctl as one of the callers. The API boundary is that disco will not allocate any memory, and expects all objects needed to communicate with the rest of the system to be provided to it with no further configuration needed. Objects that are shared between multiple processes or need to be observed by a supervisor are created by, and then mapped into the tile processes. Objects only needed by an individual tile (for example, the tcache in dedup), are created in scratch space on the stack if possible, or if they are too large, in the tile's workspace. There are no other allocations. * The bounds checking on tile fragment readers has been improved (or implemented at all in some cases). * The QUIC tile has been refactored more deeply. The raw UDP transaction handling is moved out to disco, and the context object for that logic is merged with the QUIC context object for simplicity. * The shared TPU workspace between tiles has been removed as a security issue, tiles are back to copying data between each stage of the TPU pipeline. * The TPU MTU was removed from the config file since it's always static. * The forwarding tile skeleton has been removed, since we have decided not to implement this functionality. * Moved the frank tile pieces into fdctl and removed all references to "frank" in the codebase. Frankendancer remains only in the README, to describe the current side-by-side model on main. * Removed disco from FFI, there's not really any reason anyone would need to call Firedancer tiles from Rust, and it just slowed down the build. * The dev1 command had broken at some point due to sandbox changes, and has been restored. * The `fd_tempo_tick_per_ns` calibration is moved to the `init` step of each tile, if they need to access fd_tempo_tick_per_ns, rather than being passed in via. fdctl.
1 parent 743618d commit a2106f7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+2326
-3363
lines changed

.github/workflows/functional_tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
- main
77
workflow_dispatch:
88
jobs:
9-
frank-single-transaction:
9+
single-transaction:
1010
runs-on:
1111
group: github-v1
1212
env:
@@ -25,4 +25,4 @@ jobs:
2525

2626
- name: Run functional tests
2727
run: |
28-
./src/test/frank-single-transaction.sh
28+
./src/test/single-transaction.sh

ffi/rust/firedancer-sys/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ include = [
1111
"staging",
1212
"build.rs",
1313
"wrapper_ballet.h",
14-
"wrapper_disco.h",
1514
"wrapper_tango.h",
1615
"wrapper_util.h",
1716
]

ffi/rust/firedancer-sys/build.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,11 @@ fn main() {
5353
println!("cargo:rerun-if-changed=../../../src/ballet");
5454
println!("cargo:rerun-if-changed=wrapper_tango.h");
5555
println!("cargo:rerun-if-changed=../../../src/tango");
56-
println!("cargo:rerun-if-changed=wrapper_disco.h");
57-
println!("cargo:rerun-if-changed=../../../src/disco");
5856

5957
"../../../"
6058
};
6159

62-
for lib in ["util", "ballet", "tango", "disco"] {
60+
for lib in ["util", "ballet", "tango"] {
6361
// Generate bindings to the header files
6462
let mut builder = bindgen::Builder::default()
6563
.wrap_static_fns(true)
@@ -179,12 +177,9 @@ fn main() {
179177
.env("CC", "gcc") // Always use GCC for building FFI
180178
.env("BASEDIR", out_dir.join("build"));
181179

182-
// No statics in disco yet so no extern wrapper file is produced
183-
if lib != "disco" {
184-
let key = format!("{}_STATIC_EXTERN_OBJECT", lib.to_uppercase());
185-
let value = out_dir.join(&format!("gen_{}.c", lib));
186-
command.env(key, value);
187-
}
180+
let key = format!("{}_STATIC_EXTERN_OBJECT", lib.to_uppercase());
181+
let value = out_dir.join(&format!("gen_{}.c", lib));
182+
command.env(key, value);
188183

189184
let output = command.output().unwrap_or_else(|_| {
190185
panic!(
@@ -211,7 +206,6 @@ fn main() {
211206
);
212207
println!("cargo:rustc-link-lib=static=fd_util");
213208
println!("cargo:rustc-link-lib=static=fd_tango");
214-
println!("cargo:rustc-link-lib=static=fd_disco");
215209
println!("cargo:rustc-link-lib=static=fd_ballet");
216210
println!("cargo:rustc-link-lib=stdc++");
217211
}

ffi/rust/firedancer-sys/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ mod generated {
1919

2020
include!(concat!(env!("OUT_DIR"), "/bindings_util.rs"));
2121
include!(concat!(env!("OUT_DIR"), "/bindings_ballet.rs"));
22-
include!(concat!(env!("OUT_DIR"), "/bindings_disco.rs"));
2322
include!(concat!(env!("OUT_DIR"), "/bindings_tango.rs"));
2423
}
2524

ffi/rust/firedancer-sys/src/tango/dcache.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ pub use crate::generated::{
44
fd_dcache_app_laddr_const,
55
fd_dcache_app_sz,
66
fd_dcache_compact_chunk0,
7+
fd_dcache_compact_wmark,
8+
fd_dcache_compact_next,
79
fd_dcache_compact_is_safe,
810
fd_dcache_data_sz,
911
fd_dcache_delete,

ffi/rust/firedancer-sys/wrapper_disco.h

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/app/fdctl/Local.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ ifdef FD_HAS_DOUBLE
55

66
.PHONY: fdctl run monitor cargo
77

8-
$(call add-objs,main1 config security utility run keygen ready monitor/monitor monitor/helper configure/configure configure/large_pages configure/sysctl configure/shmem configure/xdp configure/xdp_leftover configure/ethtool configure/workspace_leftover configure/workspace,fd_fdctl)
9-
$(call make-bin-rust,fdctl,main,fd_fdctl fd_frank fd_disco fd_ballet fd_tango fd_util fd_quic solana_validator_fd)
8+
$(call add-objs,main1 config security utility run/run run/tiles/dedup run/tiles/pack run/tiles/quic run/tiles/verify keygen ready monitor/monitor monitor/helper configure/configure configure/large_pages configure/sysctl configure/shmem configure/xdp configure/xdp_leftover configure/ethtool configure/workspace_leftover configure/workspace,fd_fdctl)
9+
$(call make-bin-rust,fdctl,main,fd_fdctl fd_disco fd_ballet fd_tango fd_util fd_quic solana_validator_fd)
1010
$(OBJDIR)/obj/app/fdctl/configure/xdp.o: src/tango/xdp/fd_xdp_redirect_prog.o
1111
$(OBJDIR)/obj/app/fdctl/config.o: src/app/fdctl/config/default.toml
1212

src/app/fdctl/config.c

Lines changed: 16 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "fdctl.h"
22

3-
#include "../frank/fd_frank.h"
3+
#include "run/run.h"
4+
45
#include "../../util/net/fd_eth.h"
56

67
#include <stdio.h>
@@ -24,11 +25,10 @@ find_wksp( config_t * const config,
2425
FD_LOG_ERR(( "no workspace with name `%s` found", name ));
2526
}
2627

27-
/* partial frank_bank definition since the tile doesn't really exist */
28-
static fd_frank_task_t frank_bank = {
28+
/* partial bank definition since the tile doesn't really exist */
29+
static fd_tile_config_t bank = {
2930
.in_wksp = "pack_bank",
3031
.out_wksp = "bank_shred",
31-
.extra_wksp = NULL,
3232
};
3333

3434
ulong
@@ -38,7 +38,7 @@ memlock_max_bytes( config_t * const config ) {
3838
workspace_config_t * wksp = &config->shmem.workspaces[ j ];
3939

4040
#define TILE_MAX( tile ) do { \
41-
ulong in_bytes = 0, out_bytes = 0, extra_bytes = 0; \
41+
ulong in_bytes = 0, out_bytes = 0; \
4242
if( FD_LIKELY( tile.in_wksp ) ) { \
4343
workspace_config_t * in_wksp = find_wksp( config, tile.in_wksp ); \
4444
in_bytes = in_wksp->num_pages * in_wksp->page_size; \
@@ -47,43 +47,33 @@ memlock_max_bytes( config_t * const config ) {
4747
workspace_config_t * out_wksp = find_wksp( config, tile.out_wksp ); \
4848
out_bytes = out_wksp->num_pages * out_wksp->page_size; \
4949
} \
50-
if( FD_LIKELY( tile.extra_wksp ) ) { \
51-
workspace_config_t * extra_wksp = find_wksp( config, tile.extra_wksp ); \
52-
extra_bytes = extra_wksp->num_pages * extra_wksp->page_size; \
53-
} \
5450
memlock_max_bytes = fd_ulong_max( memlock_max_bytes, \
5551
wksp->page_size * wksp->num_pages + \
5652
in_bytes + \
57-
out_bytes + \
58-
extra_bytes ); \
53+
out_bytes ); \
5954
} while(0)
6055

6156
switch ( wksp->kind ) {
62-
case wksp_tpu_txn_data:
6357
case wksp_quic_verify:
6458
case wksp_verify_dedup:
6559
case wksp_dedup_pack:
6660
case wksp_pack_bank:
67-
case wksp_pack_forward:
6861
case wksp_bank_shred:
6962
break;
7063
case wksp_quic:
71-
TILE_MAX( frank_quic );
64+
TILE_MAX( quic );
7265
break;
7366
case wksp_verify:
74-
TILE_MAX( frank_verify );
67+
TILE_MAX( verify );
7568
break;
7669
case wksp_dedup:
77-
TILE_MAX( frank_dedup );
70+
TILE_MAX( dedup );
7871
break;
7972
case wksp_pack:
80-
TILE_MAX( frank_pack );
73+
TILE_MAX( pack );
8174
break;
8275
case wksp_bank:
83-
TILE_MAX( frank_bank );
84-
break;
85-
case wksp_forward:
86-
TILE_MAX( frank_forward );
76+
TILE_MAX( bank );
8777
break;
8878
}
8979
}
@@ -301,8 +291,6 @@ static void parse_key_value( config_t * config,
301291

302292
ENTRY_UINT ( ., tiles.bank, receive_buffer_size );
303293

304-
ENTRY_UINT ( ., tiles.forward, receive_buffer_size );
305-
306294
ENTRY_UINT ( ., tiles.dedup, signature_cache_size );
307295
}
308296

@@ -480,27 +468,21 @@ static void
480468
init_workspaces( config_t * config ) {
481469
ulong idx = 0;
482470

483-
config->shmem.workspaces[ idx ].kind = wksp_tpu_txn_data;
484-
config->shmem.workspaces[ idx ].name = "tpu_txn_data";
485-
config->shmem.workspaces[ idx ].page_size = FD_SHMEM_GIGANTIC_PAGE_SZ;
486-
config->shmem.workspaces[ idx ].num_pages = 1;
487-
idx++;
488-
489471
config->shmem.workspaces[ idx ].kind = wksp_quic_verify;
490472
config->shmem.workspaces[ idx ].name = "quic_verify";
491-
config->shmem.workspaces[ idx ].page_size = FD_SHMEM_HUGE_PAGE_SZ;
492-
config->shmem.workspaces[ idx ].num_pages = 2;
473+
config->shmem.workspaces[ idx ].page_size = FD_SHMEM_GIGANTIC_PAGE_SZ;
474+
config->shmem.workspaces[ idx ].num_pages = 1;
493475
idx++;
494476

495477
config->shmem.workspaces[ idx ].kind = wksp_verify_dedup;
496478
config->shmem.workspaces[ idx ].name = "verify_dedup";
497-
config->shmem.workspaces[ idx ].page_size = FD_SHMEM_HUGE_PAGE_SZ;
498-
config->shmem.workspaces[ idx ].num_pages = 2;
479+
config->shmem.workspaces[ idx ].page_size = FD_SHMEM_GIGANTIC_PAGE_SZ;
480+
config->shmem.workspaces[ idx ].num_pages = 1;
499481
idx++;
500482

501483
config->shmem.workspaces[ idx ].kind = wksp_dedup_pack;
502484
config->shmem.workspaces[ idx ].name = "dedup_pack";
503-
config->shmem.workspaces[ idx ].page_size = FD_SHMEM_HUGE_PAGE_SZ;
485+
config->shmem.workspaces[ idx ].page_size = FD_SHMEM_GIGANTIC_PAGE_SZ;
504486
config->shmem.workspaces[ idx ].num_pages = 1;
505487
idx++;
506488

@@ -510,12 +492,6 @@ init_workspaces( config_t * config ) {
510492
config->shmem.workspaces[ idx ].num_pages = 1;
511493
idx++;
512494

513-
config->shmem.workspaces[ idx ].kind = wksp_pack_forward;
514-
config->shmem.workspaces[ idx ].name = "pack_forward";
515-
config->shmem.workspaces[ idx ].page_size = FD_SHMEM_GIGANTIC_PAGE_SZ;
516-
config->shmem.workspaces[ idx ].num_pages = 1;
517-
idx++;
518-
519495
config->shmem.workspaces[ idx ].kind = wksp_bank_shred;
520496
config->shmem.workspaces[ idx ].name = "bank_shred";
521497
config->shmem.workspaces[ idx ].page_size = FD_SHMEM_GIGANTIC_PAGE_SZ;
@@ -552,12 +528,6 @@ init_workspaces( config_t * config ) {
552528
config->shmem.workspaces[ idx ].num_pages = 1;
553529
idx++;
554530

555-
config->shmem.workspaces[ idx ].kind = wksp_forward;
556-
config->shmem.workspaces[ idx ].name = "forward";
557-
config->shmem.workspaces[ idx ].page_size = FD_SHMEM_GIGANTIC_PAGE_SZ;
558-
config->shmem.workspaces[ idx ].num_pages = 1;
559-
idx++;
560-
561531
for( ulong i=0; i<config->layout.bank_tile_count; i++ ) {
562532
config->shmem.workspaces[ idx ].kind = wksp_bank;
563533
config->shmem.workspaces[ idx ].name = "bank";

src/app/fdctl/config.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,16 @@
1414

1515
typedef struct {
1616
enum {
17-
wksp_tpu_txn_data,
1817
wksp_quic_verify,
1918
wksp_verify_dedup,
2019
wksp_dedup_pack,
2120
wksp_pack_bank,
22-
wksp_pack_forward,
2321
wksp_bank_shred,
2422
wksp_quic,
2523
wksp_verify,
2624
wksp_dedup,
2725
wksp_pack,
2826
wksp_bank,
29-
wksp_forward,
3027
} kind;
3128
char * name;
3229
ulong kind_idx;
@@ -163,10 +160,6 @@ typedef struct {
163160
uint receive_buffer_size;
164161
} bank;
165162

166-
struct {
167-
uint receive_buffer_size;
168-
} forward;
169-
170163
struct {
171164
uint signature_cache_size;
172165
} dedup;

0 commit comments

Comments
 (0)