sdk-php icon indicating copy to clipboard operation
sdk-php copied to clipboard

Use DateInterval instead of Carbon

Open xepozz opened this issue 4 years ago • 4 comments

What's the reason to use Carbon? It's slower than DateInterval. Very slower.

xepozz avatar Jul 01 '21 18:07 xepozz

It's slower than DateInterval. Very slower.

Can you please attach the benchmark results that you did?

SerafimArts avatar Jul 01 '21 18:07 SerafimArts

FWIW, I think the issue is not that it's slower, but that it would better serve everyone if the SDK used standard primitives.

rauanmayemir avatar Jul 01 '21 18:07 rauanmayemir

I do not think that Carbon leaks anywhere in user code, so it should be safe to optimize it in the future releases.

wolfy-j avatar Jul 01 '21 18:07 wolfy-j

@rauanmayemir It is used internally. All public places are described by common DateTimeInterface and DateInterval classes and/or interfaces. Like this: https://github.com/temporalio/sdk-php/blob/master/src/Activity/ActivityOptions.php#L53

Approximately this difference in speed we will get when replacing "hot spots" with the native implementation (For example, sending the local temporal time to the server): image

Now I will look at the rest of the "hot spots". To assess how critical the replacement is.

P.S. Yes, parsing time from the temporal server is 4 times longer: image

And in theory we can win about ~0.00003s per 1 i/o.

SerafimArts avatar Jul 01 '21 18:07 SerafimArts

Closing due to inactivity.

wolfy-j avatar Jul 11 '23 12:07 wolfy-j