Skip to content

Commit 3cb9ffe

Browse files
committed
box warp routes
box warp routes to avoid super heavy types. Performance impact should be okay, since these heavy types are not cache friendly. This reduces type complexity significantly, but some really long type chains remain. I've identified two, but they may be more 1. Boxed or chains 2. Response type chains We can replace the boxed or chains with a Vec, since they all contain the same box type now. Such a type doesn't seem to exist in warp yet. `cargo install --path .` Compile time before 4m49s Compile time now 4m14s Tool to list heavy functions: ` CARGO_PROFILE_RELEASE_LTO=fat cargo llvm-lines --release --bin quickwit > llvm_lines ` Size down from 32MB to 22MB addresses #5539
1 parent ee362fc commit 3cb9ffe

File tree

16 files changed

+76
-8
lines changed

16 files changed

+76
-8
lines changed

quickwit/quickwit-serve/src/cluster_api/rest_handler.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ pub fn cluster_handler(
4545
.and(extract_format_from_qs())
4646
.map(into_rest_api_response)
4747
.recover(recover_fn)
48+
.boxed()
4849
}
4950

5051
#[utoipa::path(

quickwit/quickwit-serve/src/delete_task_api/handler.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ pub fn delete_task_api_handlers(
6565
get_delete_tasks_handler(metastore.clone())
6666
.or(post_delete_tasks_handler(metastore.clone()))
6767
.recover(recover_fn)
68+
.boxed()
6869
}
6970

7071
pub fn get_delete_tasks_handler(

quickwit/quickwit-serve/src/developer_api/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ pub(crate) fn developer_api_routes(
4646
warp::path!("api" / "developer" / ..)
4747
.and(
4848
debug_handler(cluster.clone())
49-
.or(log_level_handler(env_filter_reload_fn.clone()))
49+
.or(log_level_handler(env_filter_reload_fn.clone()).boxed())
5050
.or(pprof_handlers()),
5151
)
5252
.recover(recover_fn)

quickwit/quickwit-serve/src/elasticsearch_api/bulk.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ pub fn es_compat_index_bulk_handler(
7676
.and(extract_format_from_qs())
7777
.map(make_elastic_api_response)
7878
.recover(recover_fn)
79+
.boxed()
7980
}
8081

8182
async fn elastic_ingest_bulk(

quickwit/quickwit-serve/src/elasticsearch_api/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ pub fn elastic_api_handlers(
6767
ingest_service.clone(),
6868
ingest_router.clone(),
6969
))
70+
.boxed()
7071
.or(es_compat_index_bulk_handler(ingest_service, ingest_router))
7172
.or(es_compat_index_search_handler(search_service.clone()))
7273
.or(es_compat_index_count_handler(search_service.clone()))
@@ -75,13 +76,15 @@ pub fn elastic_api_handlers(
7576
.or(es_compat_index_field_capabilities_handler(
7677
search_service.clone(),
7778
))
79+
.boxed()
7880
.or(es_compat_index_stats_handler(metastore.clone()))
7981
.or(es_compat_delete_index_handler(index_service))
8082
.or(es_compat_stats_handler(metastore.clone()))
8183
.or(es_compat_index_cat_indices_handler(metastore.clone()))
8284
.or(es_compat_cat_indices_handler(metastore.clone()))
8385
.or(es_compat_resolve_index_handler(metastore.clone()))
8486
.recover(recover_fn)
87+
.boxed()
8588
// Register newly created handlers here.
8689
}
8790

quickwit/quickwit-serve/src/elasticsearch_api/rest_handler.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ pub fn es_compat_cluster_info_handler(
9090
}))
9191
},
9292
)
93+
.boxed()
9394
}
9495

9596
/// GET or POST _elastic/_search
@@ -135,6 +136,7 @@ pub fn es_compat_delete_index_handler(
135136
.and(with_arg(index_service))
136137
.then(es_compat_delete_index)
137138
.map(|result| make_elastic_api_response(result, BodyFormat::default()))
139+
.boxed()
138140
}
139141

140142
/// GET _elastic/_stats
@@ -146,6 +148,7 @@ pub fn es_compat_stats_handler(
146148
.then(es_compat_stats)
147149
.map(|result| make_elastic_api_response(result, BodyFormat::default()))
148150
.recover(recover_fn)
151+
.boxed()
149152
}
150153

151154
/// GET _elastic/{index}/_stats
@@ -157,6 +160,7 @@ pub fn es_compat_index_stats_handler(
157160
.then(es_compat_index_stats)
158161
.map(|result| make_elastic_api_response(result, BodyFormat::default()))
159162
.recover(recover_fn)
163+
.boxed()
160164
}
161165

162166
/// GET _elastic/_cat/indices
@@ -168,6 +172,7 @@ pub fn es_compat_cat_indices_handler(
168172
.then(es_compat_cat_indices)
169173
.map(|result| make_elastic_api_response(result, BodyFormat::default()))
170174
.recover(recover_fn)
175+
.boxed()
171176
}
172177

173178
/// GET _elastic/_cat/indices/{index}
@@ -179,6 +184,7 @@ pub fn es_compat_index_cat_indices_handler(
179184
.then(es_compat_index_cat_indices)
180185
.map(|result| make_elastic_api_response(result, BodyFormat::default()))
181186
.recover(recover_fn)
187+
.boxed()
182188
}
183189

184190
/// GET _elastic/_resolve/index/{index}
@@ -189,6 +195,7 @@ pub fn es_compat_resolve_index_handler(
189195
.and(with_arg(metastore_service))
190196
.then(es_compat_resolve_index)
191197
.map(|result| make_elastic_api_response(result, BodyFormat::default()))
198+
.boxed()
192199
}
193200

194201
/// GET or POST _elastic/{index}/_search
@@ -200,6 +207,7 @@ pub fn es_compat_index_search_handler(
200207
.then(es_compat_index_search)
201208
.map(|result| make_elastic_api_response(result, BodyFormat::default()))
202209
.recover(recover_fn)
210+
.boxed()
203211
}
204212

205213
/// GET or POST _elastic/{index}/_count
@@ -211,6 +219,7 @@ pub fn es_compat_index_count_handler(
211219
.then(es_compat_index_count)
212220
.map(|result| make_elastic_api_response(result, BodyFormat::default()))
213221
.recover(recover_fn)
222+
.boxed()
214223
}
215224

216225
/// POST _elastic/_msearch
@@ -228,6 +237,7 @@ pub fn es_compat_index_multi_search_handler(
228237
RestApiResponse::new(&result, status_code, BodyFormat::default())
229238
})
230239
.recover(recover_fn)
240+
.boxed()
231241
}
232242

233243
/// GET or POST _elastic/_search/scroll
@@ -239,6 +249,7 @@ pub fn es_compat_scroll_handler(
239249
.then(es_scroll)
240250
.map(|result| make_elastic_api_response(result, BodyFormat::default()))
241251
.recover(recover_fn)
252+
.boxed()
242253
}
243254

244255
fn build_request_for_es_api(

quickwit/quickwit-serve/src/index_api/rest_handler.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,22 +95,26 @@ pub fn index_management_handlers(
9595
.or(update_index_handler(index_service.metastore()))
9696
.or(clear_index_handler(index_service.clone()))
9797
.or(delete_index_handler(index_service.clone()))
98+
.boxed()
9899
// Splits handlers
99100
.or(list_splits_handler(index_service.metastore()))
100101
.or(describe_index_handler(index_service.metastore()))
101102
.or(mark_splits_for_deletion_handler(index_service.metastore()))
103+
.boxed()
102104
// Sources handlers.
103105
.or(reset_source_checkpoint_handler(index_service.metastore()))
104106
.or(toggle_source_handler(index_service.metastore()))
105107
.or(create_source_handler(index_service.clone()))
106108
.or(get_source_handler(index_service.metastore()))
107109
.or(delete_source_handler(index_service.metastore()))
108110
.or(get_source_shards_handler(index_service.metastore()))
111+
.boxed()
109112
// Tokenizer handlers.
110113
.or(analyze_request_handler())
111114
// Parse query into query AST handler.
112115
.or(parse_query_request_handler())
113116
.recover(recover_fn)
117+
.boxed()
114118
}
115119

116120
fn json_body<T: DeserializeOwned + Send>(
@@ -127,6 +131,7 @@ pub fn get_index_metadata_handler(
127131
.then(get_index_metadata)
128132
.and(extract_format_from_qs())
129133
.map(into_rest_api_response)
134+
.boxed()
130135
}
131136

132137
async fn get_index_metadata(
@@ -163,6 +168,7 @@ fn list_indexes_metadata_handler(
163168
.then(list_indexes_metadata)
164169
.and(extract_format_from_qs())
165170
.map(into_rest_api_response)
171+
.boxed()
166172
}
167173

168174
/// Describes an index with its main information and statistics.
@@ -260,6 +266,7 @@ fn describe_index_handler(
260266
.then(describe_index)
261267
.and(extract_format_from_qs())
262268
.map(into_rest_api_response)
269+
.boxed()
263270
}
264271

265272
/// This struct represents the QueryString passed to
@@ -377,6 +384,7 @@ fn list_splits_handler(
377384
.then(list_splits)
378385
.and(extract_format_from_qs())
379386
.map(into_rest_api_response)
387+
.boxed()
380388
}
381389

382390
#[derive(Deserialize, utoipa::ToSchema)]
@@ -433,6 +441,7 @@ fn mark_splits_for_deletion_handler(
433441
.then(mark_splits_for_deletion)
434442
.and(extract_format_from_qs())
435443
.map(into_rest_api_response)
444+
.boxed()
436445
}
437446

438447
#[utoipa::path(
@@ -496,6 +505,7 @@ fn create_index_handler(
496505
.map(log_failure("failed to create index"))
497506
.and(extract_format_from_qs())
498507
.map(into_rest_api_response)
508+
.boxed()
499509
}
500510

501511
#[utoipa::path(
@@ -544,6 +554,7 @@ fn update_index_handler(
544554
.map(log_failure("failed to update index"))
545555
.and(extract_format_from_qs())
546556
.map(into_rest_api_response)
557+
.boxed()
547558
}
548559

549560
#[utoipa::path(
@@ -606,6 +617,7 @@ fn clear_index_handler(
606617
.then(clear_index)
607618
.and(extract_format_from_qs())
608619
.map(into_rest_api_response)
620+
.boxed()
609621
}
610622

611623
#[utoipa::path(
@@ -646,6 +658,7 @@ fn delete_index_handler(
646658
.then(delete_index)
647659
.and(extract_format_from_qs())
648660
.map(into_rest_api_response)
661+
.boxed()
649662
}
650663

651664
#[utoipa::path(
@@ -686,6 +699,7 @@ fn create_source_handler(
686699
.map(log_failure("failed to create source"))
687700
.and(extract_format_from_qs())
688701
.map(into_rest_api_response)
702+
.boxed()
689703
}
690704

691705
#[utoipa::path(
@@ -741,6 +755,7 @@ fn get_source_handler(
741755
.then(get_source)
742756
.and(extract_format_from_qs())
743757
.map(into_rest_api_response)
758+
.boxed()
744759
}
745760

746761
async fn get_source(
@@ -774,6 +789,7 @@ fn reset_source_checkpoint_handler(
774789
.then(reset_source_checkpoint)
775790
.and(extract_format_from_qs())
776791
.map(into_rest_api_response)
792+
.boxed()
777793
}
778794

779795
#[utoipa::path(
@@ -821,6 +837,7 @@ fn toggle_source_handler(
821837
.then(toggle_source)
822838
.and(extract_format_from_qs())
823839
.map(into_rest_api_response)
840+
.boxed()
824841
}
825842

826843
#[derive(Deserialize, utoipa::ToSchema)]
@@ -880,6 +897,7 @@ fn delete_source_handler(
880897
.then(delete_source)
881898
.and(extract_format_from_qs())
882899
.map(into_rest_api_response)
900+
.boxed()
883901
}
884902

885903
#[utoipa::path(
@@ -930,6 +948,7 @@ fn get_source_shards_handler(
930948
.then(get_source_shards)
931949
.and(extract_format_from_qs())
932950
.map(into_rest_api_response)
951+
.boxed()
933952
}
934953

935954
async fn get_source_shards(
@@ -982,6 +1001,7 @@ fn analyze_request_handler() -> impl Filter<Extract = (impl warp::Reply,), Error
9821001
.then(analyze_request)
9831002
.and(extract_format_from_qs())
9841003
.map(into_rest_api_response)
1004+
.boxed()
9851005
}
9861006

9871007
/// Analyzes text with given tokenizer config and returns the list of tokens.
@@ -1027,6 +1047,7 @@ fn parse_query_request_handler(
10271047
.then(parse_query_request)
10281048
.and(extract_format_from_qs())
10291049
.map(into_rest_api_response)
1050+
.boxed()
10301051
}
10311052

10321053
/// Analyzes text with given tokenizer config and returns the list of tokens.

quickwit/quickwit-serve/src/indexing_api/rest_handler.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,5 @@ pub fn indexing_get_handler(
6262
.and(extract_format_from_qs())
6363
.map(into_rest_api_response)
6464
.recover(recover_fn)
65+
.boxed()
6566
}

quickwit/quickwit-serve/src/ingest_api/rest_handler.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ pub(crate) fn ingest_api_handlers(
7272
ingest_handler(ingest_service.clone(), config.clone())
7373
.or(tail_handler(ingest_service))
7474
.or(ingest_v2_handler(ingest_router, config))
75+
.boxed()
7576
}
7677

7778
fn ingest_filter(
@@ -96,6 +97,7 @@ fn ingest_handler(
9697
.and(with_arg(ingest_service))
9798
.then(ingest)
9899
.map(|result| into_rest_api_response(result, BodyFormat::default()))
100+
.boxed()
99101
}
100102

101103
fn ingest_v2_filter(
@@ -121,6 +123,7 @@ fn ingest_v2_handler(
121123
.then(ingest_v2)
122124
.and(with_arg(BodyFormat::default()))
123125
.map(into_rest_api_response)
126+
.boxed()
124127
}
125128

126129
async fn ingest_v2(
@@ -223,6 +226,7 @@ pub fn tail_handler(
223226
.then(tail_endpoint)
224227
.and(extract_format_from_qs())
225228
.map(into_rest_api_response)
229+
.boxed()
226230
}
227231

228232
fn tail_filter() -> impl Filter<Extract = (String,), Error = Rejection> + Clone {

quickwit/quickwit-serve/src/jaeger_api/rest_handler.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ pub(crate) fn jaeger_api_handlers(
6868
.or(jaeger_traces_search_handler(jaeger_service_opt.clone()))
6969
.or(jaeger_traces_handler(jaeger_service_opt.clone()))
7070
.recover(recover_fn)
71+
.boxed()
7172
}
7273

7374
fn jaeger_api_path_filter() -> impl Filter<Extract = (Vec<String>,), Error = Rejection> + Clone {

quickwit/quickwit-serve/src/node_info_handler.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ pub fn node_info_handler(
3838
node_version_handler(build_info, runtime_info)
3939
.or(node_config_handler(config))
4040
.recover(recover_fn)
41+
.boxed()
4142
}
4243

4344
#[utoipa::path(get, tag = "Node Info", path = "/version")]

0 commit comments

Comments
 (0)