Review main Abandoned

78337[TASK] Improve performance of PathUtility

Christian Eßl CR 0 V 0 Normal +33 −30 updated 03/27/25, 17:52

Commit message

Rewrite the loop for resolving a canonical path to
avoid expensive array_splice()-calls.

Improves performance by ~20%, which is especially useful for file tree
generation in the filelist module and similar use cases, where the
PathUtility methods can easily get called several thousands of times
in one request.

Review

  • Code review CR 0
  • Verified V 0

Issues 1

Files 2

Review log 1723

  1. Christian Eßl uploaded patch set 1 03/31/23, 14:02

  2. core-ci voted on patch set 1 V -1 03/31/23, 14:11 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/39901

  3. Christian Eßl uploaded patch set 2 V -1 03/31/23, 14:20

  4. core-ci voted on patch set 2 V +1 03/31/23, 14:35 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/39906

  5. Christian Kuhn commented on patch set 2 CR -1 04/01/23, 03:02

    PathUtility.php:293

    -1 for the same reason as with the makeInstance() patch.
  6. Christian Eßl uploaded patch set 3 CR -1 V +1 04/01/23, 08:04

  7. Christian Eßl commented on patch set 3 04/01/23, 08:04

    PathUtility.php:293 Reply

    Ack
  8. Christian Eßl commented on patch set 3 04/01/23, 08:09

    PathUtility.php:293 Reply

    Seems to really make no differencehere, removed. But the rewriting of getCanonicalPath() can really make a difference inside filelist (where this function can easily be called thousands of times)
  9. core-ci voted on patch set 3 V +1 04/01/23, 08:12 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/39930

  10. Christian Eßl updated the commit message in patch set 4 V +1 04/03/23, 17:00

  11. core-ci voted on patch set 4 V +1 04/03/23, 17:10 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/40032

  12. Markus Klein commented on patch set 4 V +1 CR +1 04/07/23, 19:51

    It's easier to read
  13. Tymoteusz Motylewski voted on patch set 4 V +1 CR +1 04/07/23, 21:41

  14. Tymoteusz Motylewski voted on patch set 4 V 0 CR 0 04/07/23, 22:19

  15. Markus Klein commented on patch set 4 V 0 04/10/23, 20:03

    Tymoteusz discovered that changing the while condition to allow `$removeIndex >= 0` does not lead to failing tests. So either this actually doesn't matter (due to some `isset()` check covering this) or we do not have good enough tests. Could you check Christian?
  16. Simon Schaufelberger uploaded patch set 5 CR +1 V +1 04/22/24, 17:27

  17. Simon Schaufelberger commented on patch set 5 V -1 04/22/24, 17:27

    Reply

    I have found a bug in the new implementation which is covered by a new test. This works in the old implementation but fails with the new one.
  18. core-ci voted on patch set 5 V -1 04/22/24, 17:34 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/56503

  19. Simon Schaufelberger uploaded patch set 6 V -1 04/22/24, 17:36

  20. Simon Schaufelberger commented on patch set 6 V -1 04/22/24, 17:37

    Reply Unresolved

    @christian.essl@seam.at would you be willing to fix the bug?
  21. core-ci voted on patch set 6 V -1 04/22/24, 17:41 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/56504

  22. Stefan Bürk commented on patch set 6 CR -1 04/23/24, 00:05

    Unresolved

    If changes is postulated as performance related, it is eminant to provide proper benchmarking or some numbers and not only a `percentage`. 20 percent - is that 1ms , is that 20 seconds ? Also, what does "called several thousand of times" ? To be honest, I did not profiled the backend and the amount of calls in the file list module, but I did a simplified benchmark and comparision of the method call with and without this change (with the included bug). Here is the GIST with the cli command, some output and a conclusion at the end: https://gist.github.com/sbuerk/ceb78259fc495a13efcd2af2b7ecd4d1 > 50000 calls: 5ms > 500000 calls: 25ms (taking slowest from current againsts fasted fro change the diff is only 36ms) I'd guess that if these number of method calls are hit, specially the 500k one, you have other issues in the backend than that. Beside that, 25ms would be okay for that amount. To be honest - I'd did no profiling and countent usual or casual amount of method calls - do you have real numbers of it in current core versions (v12/main) Taking these numbers I'd would stay away from reworking this method, as the try showed it is not that easy without introducing side effects or bugs. Thus, I would stay with the proven to work implementation instead of taking the risk. I'm open for a more comprehensive and detailed benchmark - looking on the watch, I may have made some errors with it.
  23. Georg Ringer abandoned the change 03/27/25, 17:52

    abandoning as cleanup of gerrit, can be picked up later anytime