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

Slower Than C #310

Open
arshidkv12 opened this issue Jan 24, 2024 · 4 comments
Open

Slower Than C #310

arshidkv12 opened this issue Jan 24, 2024 · 4 comments

Comments

@arshidkv12
Copy link

Hi
I tested with xdebug profile option with grind cache.
Functions are slower than c. How to speed up?

@ryangjchandler
Copy link

The difference in speed is likely due to converting between PHP types (Zval) and Rust types such as String, Vec, etc.

@joehoyle
Copy link
Collaborator

I think to test this assumption it could be a good idea to benchmark:

#[php_function]
fn should_be_fast(&Zval zval ) -> Zval {
    zval.shallow_clone()
}

I suspect we might actually have several inefficiencies in the calling bridging, unnecessarily allocating etc.

@ryangjchandler
Copy link

That would just be benchmarking a direct clone of a Zval though right? Not the Vec<T> allocations, etc?

@joehoyle
Copy link
Collaborator

I'm not sure, I think the #[php_function] may generate code that has additional allocations etc in.

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

3 participants