A dive into Birchpress performance: This is making Birchpress slow

Posted · Add Comment

Scheduler Forums BirchPress Scheduler A dive into Birchpress performance: This is making Birchpress slow

Tagged: 

This topic contains 5 replies, has 3 voices, and was last updated by  Jason Overhulser 6 years, 7 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #30081

    Anton Stonor
    Participant

    One of our clients started to use Birchpress a few months ago. They like the functionality, but performance – not so much.

    Particular the waiting time of sometimes 10-20 seconds to fetch the calendar in the backend or get a list of available time slots for a particular day.

    So to figure our what is going on, we did some profiling. At first, we thought the data model was the culprit. After all the WordPress postmetadata table is not the most efficient way to store and query structured data.

    However, it looks like the main reason is to find elsewhere: The way Birchpress deals with WordPress hooks (filters and actions). It wraps all functions in the hook framework and makes many, many, many invocations of it.

    Lets look a specific example. We are looking at the calendar for future appointments at the admin interface and are fetching 193 of those via this ajax call:

    /wp-admin/admin-ajax.php?action= &birs_time_start=2017-06-26+00%3A00%3A00&birs_time_end=2017-08-03+00%3A00%3A00&birs_location_id=-1&birs_staff_id=-1

    The ajax request takes 24.8 sec on a server without traffic. 19 sec. of those are spent in the “has_filter” function that is invoked more than 60.000 times (!) — almost all of them triggered by Birchpress.

    We measured this with the xhprof profiler (we can provide more details).

    I realize this might be difficult to fix as this is part of the core design, but do really hope the Birchpress team will work on it to make Birchpress more useful for sites with more then a few appointments.

    #30133

    Anton Stonor
    Participant

    An update. We managed to improve the performance significantly.

    A request that would take 20 sec, now takes less the 4 sec.

    The trick is to bypass the hook system for the most invoked functions that seems to to provide unused hooks.

    In __invoke (framework/includes/birch.php) we did this hack:

    https://gist.github.com/stonor/dcbaa57a9bb0441ab5f764b1d87b7b0c

    #30417

    🙂 Interesting. Could you upload the modified file to Github? TIA.

    #30418

    Anton Stonor
    Participant

    Hi Stefan,

    I’m not sure I’m allowed to do that. What do you say, Birchpress support?

    But you can just take my diff file and use “patch” to patch birch.php.

    /Anton

    #30419

    True. 🙂 Will do that. Thanks!

    Best wishes and thanks for your time.

    #30606

    Jason Overhulser
    Participant

    Thanks Anton! This is very much appreciated.

Viewing 6 posts - 1 through 6 (of 6 total)

The forum ‘BirchPress Scheduler’ is closed to new topics and replies.

Comments are closed.