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

Measuring PGRX overhead with a Rust vs C extension benchmark #1967

Open
mllorente-msft opened this issue Jan 24, 2025 · 1 comment
Open

Measuring PGRX overhead with a Rust vs C extension benchmark #1967

mllorente-msft opened this issue Jan 24, 2025 · 1 comment

Comments

@mllorente-msft
Copy link

Hi all. As an exercise I rewrote an extension similar to pg_stats_statements where the extension counts the number of queries fired in a given time period. When benchmarking my Rust extension using PGRX against the extension written in C, I found about a ~10% decrease in total queries being fired, which to me indicates a slight overhead that PGRX had. Not sure if there is any similar discourse that exists on this topic, but just wanted to share my findings and see if anyone else has run a benchmark on comparing Rust and C extensions for postgres. On the discord, a couple users have discussed that the overhead can perhaps be attributed to SPI and variable types.

@ccleve
Copy link
Contributor

ccleve commented Jan 27, 2025

Remove #[pg_guard] annotations and see what happens. I'm not recommending this for production -- pg_guard is pretty important for safety -- but it may account for the difference.

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

No branches or pull requests

2 participants