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

Warm up time

Open tholden92 opened this issue 6 years ago • 7 comments

Hello

Is it possible to use this php extension in such a way that you can avoid the warm up time when doing address_parse() ?

I initially thought that it would work to run the parsing in a while loop accepting addresses to parse, and only have the warmup happen initially, but seems I was wrong?

tholden92 avatar Nov 19 '19 14:11 tholden92

I second this. This is an absolute show-stopper for me. This extension makes every single call to PHP on the command line take several seconds, when normally it takes milliseconds. Even running php -m just to verify if php-postal is enabled takes forever.

Did I miss something? I thought I installed both libpostal and php-postal exactly as it says. And they work on my machine, but are just so doggedly slow. What can be done about this?

curtisdf avatar Jan 31 '20 05:01 curtisdf

This may not work in your environment, but we just made a small network service using https://github.com/openvenues/gopostal and call it when we need to parse a location.

stevenscg avatar Jan 31 '20 18:01 stevenscg

I ended up doing the exact same thing. Wrote a c++ program exposing libpostal over sockets. Thanks for the suggestion though.

tholden92 avatar Jan 31 '20 23:01 tholden92

Chiming in to say I'm seeing the same thing, even when not directly using Postal functionality.

Enabled:

$ time php -v
PHP 7.4.3 (cli) (built: May 26 2020 12:24:22) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.3, Copyright (c), by Zend Technologies
    with Xdebug v2.9.2, Copyright (c) 2002-2020, by Derick Rethans
real	0m4.449s
user	0m3.296s
sys	0m1.132s

Disabled:

$ time php -v
PHP 7.4.3 (cli) (built: May 26 2020 12:24:22) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.3, Copyright (c), by Zend Technologies
    with Xdebug v2.9.2, Copyright (c) 2002-2020, by Derick Rethans
real	0m0.021s
user	0m0.012s
sys	0m0.009s

4 seconds to run php -v is far from ideal. This would make my whole API server somewhere around 20x slower.

enobrev avatar Oct 07 '20 20:10 enobrev

This is a Docker container that provides a REST API to libpostal: https://github.com/johnlonganecker/libpostal-rest-docker (I saw it mentioned in https://github.com/openvenues/php-postal/issues/15#issuecomment-51305913.)

Otherwise, maybe a PHP socket server could work, similar to what @tholden92 says he did with C++.

LordPachelbel avatar Jan 29 '21 02:01 LordPachelbel

Any update on this, on my system its taking over 20seconds to try and run a php script when this extension is enabled

dorgan avatar Jan 12 '22 18:01 dorgan

https://github.com/openvenues/php-postal/pull/30

tm1000 avatar Mar 17 '23 21:03 tm1000