[login forms] performance improvements in two factor authentication#8951
[login forms] performance improvements in two factor authentication#8951rdeutz merged 12 commits intojoomla:stagingfrom
Conversation
There was a problem hiding this comment.
You're using PHP 5.4 syntax here.
|
travis seems to be confused... |
|
Restarted Travis. FWIW it's not FOF that's the problem. You can remove the FOF code by replacing those two lines with the Joomla specific versions: JPluginHelper::importPlugin('twofactorauth');
$identities = JEventDispatcher::getInstance()->trigger('onUserTwofactorIdentify', array());And I went from the method taking 84ms to 82ms :P (for the admin login page). Therefore I assume the time is actually gained by not running the plugin event (and it's a long know but impossible to fix without screwing b/c fact) that Joomla's plugin system is slow as hell. Therefore the question to me is that is it b/c doing what you are doing. Other 3rd party two factor plugins may have more logic in their Just as a sidenote we actually load FOF on every page :P https://github.com/joomla/joomla-cms/blob/staging/libraries/cms.php#L42-L46 |
|
@wilsonge didn't notice fof was loaded every time on every page. thanks for enlightening me. Don't know yet Joomla code so well. Is there a reason for fof being loaded in everypage and not only when needed?
Yeah, you're right again.
Yes, it seems it's only used in joomla plugins to get the section in the two auth plugins in joomla. It that i mind i will see it after the changes needed this PR still makes sense later. |
|
That file is just loading FOF's autoloader, not including the whole library into memory. |
|
@mbabker, ok. thanks for explaining. @wilsonge, after several testing i revised the PR to use the We still get a performance/memory usage improvement in making the same thing so i think this PR still makes sense and this way, i think, there are no B/C problems. |
|
Did some tests with PHP 5.6.16, without Joomla caching, with PHP OpCache disabled and without open_basedir. JDEBUG ? JProfiler::getInstance('Application')->mark('- START') : null;
$twofactormethods = xxxxxxxxxxxxxx::getTwoFactorMethods();
JDEBUG ? JProfiler::getInstance('Application')->mark('- <strong>DONE</strong>') : null;Before PR
After PR
So at least 4 ms and 0.5MB difference. The same could apply to all the other pages that have the login form (admin login, offline, com_users login). |
|
@andrepereiradasilva Could you resolve the conflicts here please? |
|
conflicts fixed. let's hope this additional work will make someone test this ... |
|
@andrepereiradasilva I am going to get it tested tomorrow ;) Thanks. |
|
Me too
|
|
thanks guys |
|
Tested with patch and could login ok in all 4 places using the yubikey Tested performance of the front-end login module with the supplied instructions Before21.05 ms / 573.97 ms Memory: 0.573 MB / 11.59 MB Application: - Time to get twofactorauth methods AfterTime: 9.10 ms / 551.29 ms Memory: 0.161 MB / 11.17 MB Application: - Time to get twofactorauth methods |
|
I have tested this item ✅ successfully on f279041 This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/8951. |
|
I have tested this item ✅ successfully on f279041
Before PR Although there is a small difference (probably because of my machine) there is a difference This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/8951. |
|
RTC as we have 2 successful tests This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/8951. |
…oomla#8951) * improve get two factor authentication in mod_login (site & admin) and offline template * uniformize spaces * use php 5.3 compatible syntax thanks again @mbabker * the same for frontend component user view login too * continue using onUserTwofactorIdentify trigger * cs - empty line at the end of file * fix conflicts 1 * fix conflicts 2 * fix conflicts final * __DEPLOY_VERSION__ * improve code blocks
…oomla#8951) * improve get two factor authentication in mod_login (site & admin) and offline template * uniformize spaces * use php 5.3 compatible syntax thanks again @mbabker * the same for frontend component user view login too * continue using onUserTwofactorIdentify trigger * cs - empty line at the end of file * fix conflicts 1 * fix conflicts 2 * fix conflicts final * __DEPLOY_VERSION__ * improve code blocks
Description
This PR improves performance and memory usage of the admin login page, the offline page, all the pages that have a login module in the frontend and the component users view login form.
Joomla is loading fof just to check if any two factor auth plugins are enabled to show the "Secret key" field. IMHO we can use Joomla (already loaded) libraries for that.
This way we can have performance improvements(around 4-6ms PHP 5.6.16) in every page that use this login modules.
Performance before PR (frontend mod_login as example)
Performance after PR (frontend mod_login as example)
How to test
Note: for test the performance go to any (or all this files):
And put a mark in the debug profiler before and after the call to get the two factor methods.
Example: /modules/mod_login/mod_login.php
Observations
Suggestions, improvements and code reviews are welcome.