• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

XF 1.5 What is deferred.php and why might it be hit repeatedly

TheLaw

Well-known member
#1
I'm now in the optimizing stage and I've watched some pages load a little slowly with the main problem being this. What is deferred.php and what does it do? To be honest, it's on a popular addon page but this file apparently relates to the Xenforo core so I'm going to ask what it does. I've noticed more drag with certain addons and I'll let the developers know...

deferred.png
 

Daniel Hood

Well-known member
#2
XenForo introduced the deferred system to help slow processes from affecting the user's experience. Something that takes a long time is tossed into the deferred queue and run on the client side by the user's browser in the background.
New general-purpose system for long running processes
1.2 adds a new "deferred" system for running any code that can be broken up into pieces and may take a long time (multiple seconds or more) to run. Deferred tasks can be triggered automatically by the code as necessary and they will either be run automatically in the background (by page views) or by displaying the current running state to the administrator (in the case of some cache rebuilds). This effectively unifies the cache rebuild systems with cron and other potentially long running processes (such as the bulk user change system discussed in the past).
XF 1.2 - Assorted Small Things
 

TheLaw

Well-known member
#6
Unless more deferred returns true, right? Like if there's a backlog of tasks for some reason.
That's a lot of backlogged tasks that just happened to accumulate and after 1-2 minutes, were gone. Not sure how and why they would be relevant to the loading of that page. I'll keep an eye on it.
 

Mike

XenForo developer
Staff member
#8
Unless more deferred returns true, right?
Correct. Long running tasks will automatically retrigger after "completing". Or if you have a large number of pending jobs. We had a ticket recently caused by over 200,000 jobs pending (in this case, due to a huge amount of thread moves).
 

Daniel Hood

Well-known member
#9
That's a lot of backlogged tasks that just happened to accumulate and after 1-2 minutes, were gone. Not sure how and why they would be relevant to the loading of that page. I'll keep an eye on it.
The thing is, they aren't actually connected to the page you're on. It has more to do with the page you were on before that one. Plus, it could be someone else that actually trigger the call, you're just the one running it. The way it works is if I do something to do trigger a deferred task, the next person to load any page of the forum, is going to be the one that actually processes the task in the background of their browser.