-
Notifications
You must be signed in to change notification settings - Fork 19
[meta] Split the core #96
Comments
Thoughts @hoaproject/hoackers? |
And what happens to |
@Jir4 Because I am not sure about what to do with this one so far. |
That make sense, it would be very interesting to do some benchmarks before/after core splitting to check the real difference on performances (not saying that it'll decrease performances but numbers/data are interesting). |
@osaris 👍 |
I started to split |
|
I am starting to update libraries with |
All tests are green for |
Everything is OK! |
@hoaproject/hoackers Please, I need your help!
Thanks! |
|
|
|
@Jir4 We will remove it when we will no longer have any downloads. Until we have downloads, we must keep the repository live :-]. |
@Hywan the downside of this approach is that we will have downloads (at least for CI systems) so long as it will be available… |
@CircleCode Hmm… Every year, we can clean deprecated repositories? So far, we only have |
Several month but not years, we just have to let the time to users to update their legacy code. |
|
All libraries are updated. Now I am running |
Done. |
Next step is to merge everything and create new snapshots for all libraries. I don't have enough time to do it well if something failed right now. Let see tonight or tomorrow! |
Done \o/. |
👍 |
😅 |
👏 |
@1e1 What we earn? I don't understand. |
I suppose that he speak about performance |
That's very light. Let me try a small benchmark. |
Yeap! (Sorry) |
tl;drHere is small benchmark result when loading Hoa (because we have 1 require autoloaded file):
TimeFirst script for i in `seq 1 1000`; do
php -r 'require "/usr/local/lib/Hoa/Core/Core.php";'
done Second script for i in `seq 1 1000`; do
php -r 'require "/usr/local/lib/Hoa/Consistency/Prelude.php";'
done Time for $ time /tmp/a.sh
/tmp/a.sh 11.37s user 5.64s system 94% cpu 18.084 total
$ time /tmp/b.sh
/tmp/b.sh 9.56s user 5.07s system 91% cpu 15.959 total That's an improvement of 11.751% at loading time. MemoryFirst script <?php
$a = memory_get_usage();
require '/usr/local/lib/Hoa/Core/Core.php';
var_dump(memory_get_usage() - $a); Second script <?php
$a = memory_get_usage();
require '/usr/local/lib/Hoa/Consistency/Prelude.php';
var_dump(memory_get_usage() - $a); Time to run: $ php /tmp/a.php
int(335408)
$ php /tmp/b.php
int(56744) That's an improvement of 278664b, be 272Kb, be 83.082% at initialization per process per run. |
History
The core gathers several thin layers into a single library for performance reasons. Let me explain it shortly. Parsing time is not very costly compared to I/O: Accessing to a file, opening it and reading it. The core aimed at putting the minimum always needed codes into small files, in order to reduce this I/O time. Since recent PHP versions and recent I/O progresses (SSD, kernel, FS…), this is no longer necessary. We can then split the core.
Global idea
The core contains the following layers:
Hoa\Core\Consistency
,Hoa\Core\Data
,Hoa\Core\Event
,Hoa\Core\Exception
,Hoa\Core\Parameter
,Hoa\Core\Protocol
.We can split it into the following libraries:
Hoa\Consistency
,Hoa\Event
,Hoa\Exception
,Hoa\Protocol
.They can live outside the core without any problem. So far, though,
Hoa\Core\Data
andHoa\Core\Parameter
will be kept as is.Dealing with pre-loading
Hoa\Core\Consistency
,Hoa\Core\Parameter
andHoa\Core\Protocol
were de-facto pre-loaded withHoa\Core\Core
. This latter is automatically pre-loaded with theautoload.files
Composer's property. Whatever the split, we have to ensure this behavior.Case of
Hoa\Core\Consistency
This layer contains:
Only the latter is important at any runtime and will be loaded as a separated file with Composer. This will reduce the number of loaded code by approximately 60%.
Case of
Hoa\Core\Parameter
Will not be extracted yet. Nothing to do.(see bellow)Case of
Hoa\Core\Protocol
We need to register the
hoa://
protocol at any runtime. We use it everywhere. It has never hurt anyone in the whole Hoa's history. So we can load the file that is responsible to register the stream wrapper with Composer. This will reduce the number of loaded code by approximately 50%.Steps
Here are the following steps to follow (the order is important):
Hoa\Exception
:Hoa\Exception
(fromHoa\Core\Exception
),Hoa\Exception
,Hoa\Core\Exception
.Hoa\Event
:Hoa\Event
(fromHoa\Core\Event
),Hoa\Event
,Hoa\Core\Event
.Hoa\Protocol
:Hoa\Protocol
,Hoa\Protocol
,Hoa\Core\Protocol
.Hoa\Consistency
:Hoa\Consistency
,Hoa\Consistency
,Hoa\Core\Consistency
.Next steps
Continue to split the core, see #97.Here are the following steps to follow:
Hoa\Xyl\Data
:Hoa\Core\Data
toHoa\Xyl\Data
,Hoa\View
and other libraries to understand a mixed data structured instead (to remove a dependency),Hoa\Core\Data
.Hoa\Parameter
:Hoa\Parameter
(fromHoa\Core\Parameter
),Hoa\Core\Parameter
.Hoa\Core
:Update all
composer.json
filesBecause we are dropping PHP5.4 too.
The text was updated successfully, but these errors were encountered: