Description
Description
In some local benchmarks, I have noticed a slow-down when the compiler db fills up. While some side effects of a full db are expected, I would've anticipated a much lower impact of overall executable count on individual file validation.
It is especially interesting that this even occurred when the executables all had the exact same content, as this might indicate some caching problems in salsa.
I'll try to investigate further and provide some benchmarks to reproduce. In the meantime: is there any way to drop documents from the db other than cloning the entire database?
Edit: I added benchmarks below. As seen in the graph, most of the performance problems seem to be caused by a long delay between two iterations at ~1-2k iterations. Is this maybe caused by additional memory allocation?
simple_query_compiler_with_single_file_validation
time: [25.527 µs 25.649 µs 25.799 µs]
Found 16 outliers among 100 measurements (16.00%)
6 (6.00%) low severe
3 (3.00%) low mild
3 (3.00%) high mild
4 (4.00%) high severe
simple_query_compiler_with_multi_file_validation
time: [552.60 µs 822.02 µs 1.0782 ms]
change: [-47.065% -22.119% +11.327%] (p = 0.17 > 0.05)
No change in performance detected.
Found 12 outliers among 100 measurements (12.00%)
12 (12.00%) high severe
Benchmark code
fn bench_simple_query_compiler_with_single_file_validation(c: &mut Criterion) {
let query = include_str!("testdata/simple_query.graphql");
let schema = include_str!("testdata/simple_schema.graphql");
c.bench_function("simple_query_compiler_with_single_file_validation", move |b| {
b.iter(|| {
let mut compiler = ApolloCompiler::new();
compiler.add_type_system(schema, "schema.graphql");
let executable_id = compiler.add_executable(query, "query.graphql");
compiler.db.validate_executable(executable_id)
})
});
}
fn bench_simple_query_compiler_with_multi_file_validation(c: &mut Criterion) {
let query = include_str!("testdata/simple_query.graphql");
let schema = include_str!("testdata/simple_schema.graphql");
let mut compiler = ApolloCompiler::new();
compiler.add_type_system(schema, "schema.graphql");
compiler.validate();
c.bench_function("simple_query_compiler_with_multi_file_validation", move |b| {
b.iter(|| {
let executable_id = compiler.add_executable(query, "query.graphql");
compiler.db.validate_executable(executable_id)
})
});
}
criterion_group!(
benches,
bench_simple_query_compiler_with_single_file_validation,
bench_simple_query_compiler_with_multi_file_validation
);
criterion_main!(benches);