Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize codec initialization #71

Merged
merged 1 commit into from
Oct 2, 2023
Merged

Optimize codec initialization #71

merged 1 commit into from
Oct 2, 2023

Conversation

quinchs
Copy link
Collaborator

@quinchs quinchs commented Sep 25, 2023

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

await client.QueryAsync<string>("select \"Hello, World!\"");
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 |

@quinchs quinchs merged commit 392e69f into dev Oct 2, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants