View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update | 
|---|---|---|---|---|---|
| 0035198 | mantisbt | performance | public | 2024-12-21 13:52 | 2025-03-01 18:40 | 
| Reporter | raspopov | Assigned To | dregad | ||
| Priority | normal | Severity | minor | Reproducibility | always | 
| Status | closed | Resolution | fixed | ||
| Product Version | 2.27.0 | ||||
| Target Version | 2.27.1 | Fixed in Version | 2.27.1 | ||
| Summary | 0035198: Caching language loading can be more efficient. | ||||
| Description | Found it almost by accident when I was researching how MantisBT works with languages. The current set of plugins uses languages before caching, which repeatedly causes the array of languages and their codes to be rebuilt. The caching code in core.php probably needs to be placed a bit higher than the plugin loading code. | ||||
| Tags | No tags attached. | ||||
| PR: 2060. | |
| I noticed that one more optimization wouldn't hurt the language loading code, replacing the expensive  PR 2059. | |
| Program performance and performance measurement as we know it is a very tricky thing where intuition usually fools the programmer. Knowing this, I decided to measure the code performance before and after the commit once again. And ... my goodness I didn't find any performance gain after replacing the seemingly heavy  I've attached a graphical performance report for different versions (the unit on the charts is 10ns) of  
 The charts show that only the last variant has a performance gain. I did not evaluate memory, perhaps  PR: 2061. | |
| Wow you sure spent a lot of time profiling this, for a 0.7 ms gain ;-) | |
| Basically, the idea is to get to know the code base and understand how things actually work. I also want to refresh my PHP knowledge and learn about debugging and profiling tools that I haven't used before (my main language is C++). Thanks for the opportunity and for being so patient. | |
| MantisBT: master-2.27 9e2b936c 2024-12-21 01:43 Committer: dregad Details Diff | Optimize lang_load() function Replacing preg_replace() with strncmp() and substr(). Note: the original implementation used str_starts_with() but that requires PHP 8.0 or later, and we're on 7.4. Fixes 0035198, PR https://github.com/mantisbt/mantisbt/pull/2059 Signed-off-by: Damien Regad <dregad@mantisbt.org> | Affected Issues 0035198 | |
| mod - core/lang_api.php | Diff File | ||
| MantisBT: master-2.27 317abee4 2024-12-21 13:43 Committer: dregad Details Diff | Fix caching when current language is 'auto' Caching the languages before initializing the plugin API results in a single call instead of a minimum of five. Fixes 0035198, PR https://github.com/mantisbt/mantisbt/pull/2060 Signed-off-by: Damien Regad <dregad@mantisbt.org> | Affected Issues 0035198 | |
| mod - core.php | Diff File | ||
| MantisBT: master-2.27 36481ac9 2024-12-23 10:42 Committer: dregad Details Diff | Fix lang_load() performance again Micro-optimization, using string index comparison instead of strncmp(), as explained in [1]. Fixes 0035198, PR https://github.com/mantisbt/mantisbt/pull/2061 [1]: https://mantisbt.org/bugs/view.php?id=35198#c69600 Signed-off-by: Damien Regad <dregad@mantisbt.org> | Affected Issues 0035198 | |
| mod - core/lang_api.php | Diff File | ||
