phper icon indicating copy to clipboard operation
phper copied to clipboard

Shower Than C Extension

Open arshidkv12 opened this issue 1 year ago • 6 comments

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

arshidkv12 avatar Jan 24 '24 08:01 arshidkv12

What about the data?

jmjoy avatar Jan 25 '24 01:01 jmjoy

cachegrind

PHP code:

for ($i=0; $i < 1000; $i++) { 
        say_hello("sdf"); //rust
        strpos("sdfsf", "d", 1); //c function
}

Rust:

pub fn say_hello(arguments: &mut [ZVal]) -> phper::Result<()> {

    Ok(())
}

arshidkv12 avatar Jan 25 '24 02:01 arshidkv12

Do you build under release?

jmjoy avatar Jan 25 '24 03:01 jmjoy

Yes

On Thu, 25 Jan, 2024, 8:40 am jmjoy, @.***> wrote:

Do you build under release?

— Reply to this email directly, view it on GitHub https://github.com/phper-framework/phper/issues/149#issuecomment-1909271654, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABT5Y5KK4RFWKLXKBRSRK23YQHEI7AVCNFSM6AAAAABCIK47M2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMBZGI3TCNRVGQ . You are receiving this because you authored the thread.Message ID: @.***>

arshidkv12 avatar Jan 25 '24 03:01 arshidkv12

image

jmjoy avatar Jan 25 '24 06:01 jmjoy

image

0.18 > 0.11

Why does the Rust function take longer than the C complex O(n) function?

How to optimise it?

arshidkv12 avatar Jan 25 '24 06:01 arshidkv12

PHP is not very friendly to writing extensions in non-C/C++ languages because PHP's source code is heavy and uses macros, while Rust does not support C macros, so some tricks are needed to achieve the desired effect, which can affect performance. However, the purpose of this project is not to improve performance, but simply to use Rust to write PHP extensions, so performance issues are not considered.

jmjoy avatar Aug 07 '24 07:08 jmjoy