This PR adds a simple optimization by parallelizing the Execute <=> Initialize phase by "preheating" the codecs to their final form. The more complex (the number of different types and descriptors) a query is(has), the better the performance gain. This also gets gains from long-running queries, as while the binding waits for EdgeDB to return the data, it can preheat codecs.
Click to show benchmark results
**Before Optimization**
```
| Method | Mean | Error | StdDev |
|----------------- |---------:|--------:|--------:|
| FullExecuteAsync | 362.6 us | 7.09 us | 5.92 us |
```
**After Optimization**
```
| Method | Mean | Error | StdDev |
|----------------- |---------:|--------:|--------:|
| FullExecuteAsync | 355.1 us | 6.21 us | 5.51 us |
```
Larger query benchmarks
public class Person
{
[EdgeDBProperty("name")]
public string? Name { get; set; }
[EdgeDBProperty("email")]
public string? Email { get; set; }
}
public class Movie
{
[EdgeDBProperty("title")]
public string? Title { get; set; }
[EdgeDBProperty("year")]
public int Year { get; set; }
[EdgeDBProperty("director")]
public Person? Director { get; set; }
[EdgeDBProperty("actors")]
public Person[]? Actors { get; set; }
}
await client.QueryAsync<Movie>("select Movie { actors: { email, name }, director: { email, name }, title, year }");
Click to show benchmark results
**Before Optimization**
```
| Method | Mean | Error | StdDev |
|----------------- |---------:|--------:|--------:|
| FullExecuteAsync | 442.3 us | 8.12 us | 7.98 us |
```
**After Optimization**
```
| Method | Mean | Error | StdDev |
|----------------- |---------:|--------:|--------:|
| FullExecuteAsync | 419.6 us | 8.37 us | 8.96 us |
```
Summary
This PR adds a simple optimization by parallelizing the Execute <=> Initialize phase by "preheating" the codecs to their final form. The more complex (the number of different types and descriptors) a query is(has), the better the performance gain. This also gets gains from long-running queries, as while the binding waits for EdgeDB to return the data, it can preheat codecs.
Small query benchmarks
Click to show benchmark results
**Before Optimization** ``` | Method | Mean | Error | StdDev | |----------------- |---------:|--------:|--------:| | FullExecuteAsync | 362.6 us | 7.09 us | 5.92 us | ``` **After Optimization** ``` | Method | Mean | Error | StdDev | |----------------- |---------:|--------:|--------:| | FullExecuteAsync | 355.1 us | 6.21 us | 5.51 us | ```Larger query benchmarks
Click to show benchmark results
**Before Optimization** ``` | Method | Mean | Error | StdDev | |----------------- |---------:|--------:|--------:| | FullExecuteAsync | 442.3 us | 8.12 us | 7.98 us | ``` **After Optimization** ``` | Method | Mean | Error | StdDev | |----------------- |---------:|--------:|--------:| | FullExecuteAsync | 419.6 us | 8.37 us | 8.96 us | ```