@@ -5,110 +5,52 @@ use chroma_benchmark::benchmark::{bench_run, tokio_multi_thread};
5
5
use chroma_config:: { registry:: Registry , Configurable } ;
6
6
use chroma_segment:: test:: TestDistributedSegment ;
7
7
use chroma_system:: { ComponentHandle , Dispatcher , Orchestrator , System } ;
8
+ use chroma_types:: operator:: { Filter , Limit , Projection } ;
8
9
use criterion:: { criterion_group, criterion_main, Criterion } ;
9
10
use load:: {
10
11
all_projection, always_false_filter_for_modulo_metadata,
11
12
always_true_filter_for_modulo_metadata, empty_fetch_log, offset_limit, sift1m_segments,
12
13
trivial_filter, trivial_limit, trivial_projection,
13
14
} ;
14
- use worker:: { config:: RootConfig , execution:: orchestration:: get:: GetOrchestrator } ;
15
-
16
- fn trivial_get (
17
- test_segments : & TestDistributedSegment ,
18
- dispatcher_handle : ComponentHandle < Dispatcher > ,
19
- ) -> GetOrchestrator {
20
- let blockfile_provider = test_segments. blockfile_provider . clone ( ) ;
21
- let collection_uuid = test_segments. collection . collection_id ;
22
- GetOrchestrator :: new (
23
- blockfile_provider,
24
- dispatcher_handle,
25
- 1000 ,
26
- test_segments. into ( ) ,
27
- empty_fetch_log ( collection_uuid) ,
28
- trivial_filter ( ) ,
29
- trivial_limit ( ) ,
30
- trivial_projection ( ) ,
31
- )
32
- }
33
-
34
- fn get_false_filter (
35
- test_segments : & TestDistributedSegment ,
36
- dispatcher_handle : ComponentHandle < Dispatcher > ,
37
- ) -> GetOrchestrator {
38
- let blockfile_provider = test_segments. blockfile_provider . clone ( ) ;
39
- let collection_uuid = test_segments. collection . collection_id ;
40
- GetOrchestrator :: new (
41
- blockfile_provider,
42
- dispatcher_handle,
43
- 1000 ,
44
- test_segments. into ( ) ,
45
- empty_fetch_log ( collection_uuid) ,
46
- always_false_filter_for_modulo_metadata ( ) ,
47
- trivial_limit ( ) ,
48
- trivial_projection ( ) ,
49
- )
50
- }
51
-
52
- fn get_true_filter (
53
- test_segments : & TestDistributedSegment ,
54
- dispatcher_handle : ComponentHandle < Dispatcher > ,
55
- ) -> GetOrchestrator {
56
- let blockfile_provider = test_segments. blockfile_provider . clone ( ) ;
57
- let collection_uuid = test_segments. collection . collection_id ;
58
- GetOrchestrator :: new (
59
- blockfile_provider,
60
- dispatcher_handle,
61
- 1000 ,
62
- test_segments. into ( ) ,
63
- empty_fetch_log ( collection_uuid) ,
64
- always_true_filter_for_modulo_metadata ( ) ,
65
- trivial_limit ( ) ,
66
- trivial_projection ( ) ,
67
- )
68
- }
15
+ use worker:: {
16
+ config:: RootConfig ,
17
+ execution:: orchestration:: { filter:: FilterOrchestrator , get:: GetOrchestrator } ,
18
+ } ;
69
19
70
- fn get_true_filter_limit (
71
- test_segments : & TestDistributedSegment ,
72
- dispatcher_handle : ComponentHandle < Dispatcher > ,
73
- ) -> GetOrchestrator {
74
- let blockfile_provider = test_segments. blockfile_provider . clone ( ) ;
75
- let collection_uuid = test_segments. collection . collection_id ;
76
- GetOrchestrator :: new (
77
- blockfile_provider,
78
- dispatcher_handle,
20
+ async fn bench_routine (
21
+ ( system, dispatcher, test_segments, filter, limit, projection, expected_ids) : (
22
+ System ,
23
+ ComponentHandle < Dispatcher > ,
24
+ & TestDistributedSegment ,
25
+ Filter ,
26
+ Limit ,
27
+ Projection ,
28
+ Vec < String > ,
29
+ ) ,
30
+ ) {
31
+ let matching_records = FilterOrchestrator :: new (
32
+ test_segments. blockfile_provider . clone ( ) ,
33
+ dispatcher. clone ( ) ,
34
+ test_segments. hnsw_provider . clone ( ) ,
79
35
1000 ,
80
36
test_segments. into ( ) ,
81
- empty_fetch_log ( collection_uuid) ,
82
- always_true_filter_for_modulo_metadata ( ) ,
83
- offset_limit ( ) ,
84
- trivial_projection ( ) ,
37
+ empty_fetch_log ( test_segments. collection . collection_id ) ,
38
+ filter,
85
39
)
86
- }
87
-
88
- fn get_true_filter_limit_projection (
89
- test_segments : & TestDistributedSegment ,
90
- dispatcher_handle : ComponentHandle < Dispatcher > ,
91
- ) -> GetOrchestrator {
92
- let blockfile_provider = test_segments. blockfile_provider . clone ( ) ;
93
- let collection_uuid = test_segments. collection . collection_id ;
94
- GetOrchestrator :: new (
95
- blockfile_provider,
96
- dispatcher_handle,
40
+ . run ( system. clone ( ) )
41
+ . await
42
+ . expect ( "Filter orchestrator should not fail" ) ;
43
+ let output = GetOrchestrator :: new (
44
+ test_segments. blockfile_provider . clone ( ) ,
45
+ dispatcher,
97
46
1000 ,
98
- test_segments. into ( ) ,
99
- empty_fetch_log ( collection_uuid) ,
100
- always_true_filter_for_modulo_metadata ( ) ,
101
- offset_limit ( ) ,
102
- all_projection ( ) ,
47
+ matching_records,
48
+ limit,
49
+ projection,
103
50
)
104
- }
105
-
106
- async fn bench_routine ( input : ( System , GetOrchestrator , Vec < String > ) ) {
107
- let ( system, orchestrator, expected_ids) = input;
108
- let output = orchestrator
109
- . run ( system)
110
- . await
111
- . expect ( "Orchestrator should not fail" ) ;
51
+ . run ( system)
52
+ . await
53
+ . expect ( "Get orchestrator should not fail" ) ;
112
54
assert_eq ! (
113
55
output
114
56
. result
@@ -138,35 +80,55 @@ fn bench_get(criterion: &mut Criterion) {
138
80
let trivial_get_setup = || {
139
81
(
140
82
system. clone ( ) ,
141
- trivial_get ( & test_segments, dispatcher_handle. clone ( ) ) ,
83
+ dispatcher_handle. clone ( ) ,
84
+ & test_segments,
85
+ trivial_filter ( ) ,
86
+ trivial_limit ( ) ,
87
+ trivial_projection ( ) ,
142
88
( 0 ..100 ) . map ( |id| id. to_string ( ) ) . collect ( ) ,
143
89
)
144
90
} ;
145
91
let get_false_filter_setup = || {
146
92
(
147
93
system. clone ( ) ,
148
- get_false_filter ( & test_segments, dispatcher_handle. clone ( ) ) ,
94
+ dispatcher_handle. clone ( ) ,
95
+ & test_segments,
96
+ always_false_filter_for_modulo_metadata ( ) ,
97
+ trivial_limit ( ) ,
98
+ trivial_projection ( ) ,
149
99
Vec :: new ( ) ,
150
100
)
151
101
} ;
152
102
let get_true_filter_setup = || {
153
103
(
154
104
system. clone ( ) ,
155
- get_true_filter ( & test_segments, dispatcher_handle. clone ( ) ) ,
105
+ dispatcher_handle. clone ( ) ,
106
+ & test_segments,
107
+ always_true_filter_for_modulo_metadata ( ) ,
108
+ trivial_limit ( ) ,
109
+ trivial_projection ( ) ,
156
110
( 0 ..100 ) . map ( |id| id. to_string ( ) ) . collect ( ) ,
157
111
)
158
112
} ;
159
113
let get_true_filter_limit_setup = || {
160
114
(
161
115
system. clone ( ) ,
162
- get_true_filter_limit ( & test_segments, dispatcher_handle. clone ( ) ) ,
116
+ dispatcher_handle. clone ( ) ,
117
+ & test_segments,
118
+ always_true_filter_for_modulo_metadata ( ) ,
119
+ offset_limit ( ) ,
120
+ trivial_projection ( ) ,
163
121
( 100 ..200 ) . map ( |id| id. to_string ( ) ) . collect ( ) ,
164
122
)
165
123
} ;
166
124
let get_true_filter_limit_projection_setup = || {
167
125
(
168
126
system. clone ( ) ,
169
- get_true_filter_limit_projection ( & test_segments, dispatcher_handle. clone ( ) ) ,
127
+ dispatcher_handle. clone ( ) ,
128
+ & test_segments,
129
+ always_true_filter_for_modulo_metadata ( ) ,
130
+ offset_limit ( ) ,
131
+ all_projection ( ) ,
170
132
( 100 ..200 ) . map ( |id| id. to_string ( ) ) . collect ( ) ,
171
133
)
172
134
} ;
0 commit comments