Apr 032016

See the issue raised here.

On 1 April 2016, we had some large commits (you can see them all here). This ground the front page to a halt. But as you can see, that link above loads rather quickly.


At first, I thought it was because the date-based page was caching the results. I was wrong. It was merely faster overall.

I started looking at the code and discovered that it was not caching at all. I soon fixed that. Part of the code was already written, and the existing code just needed to start using it.

I also added cache clearing support, which involved adding a new table (cache_clearing_dates).

Why is date.php faster than index.php?

If you compare the output of today’s commits (e.g. https://www.freshports.org/date.php?date=2016/4/3) with the home page, the output is the same, or at least it looks the same to me. I don’t see any differences.

Let’s examine the code.

date.php uses the Commits class (see line 113).

index.php uses the LatestCommits class (see line 159).

I suspect the difference is in there.

The SQL for the Commits class (used by date.php) is relatively easy to follow for someone with intermediate SQL skills. It’s about 60 lines.

I know what the code for LatestCommits (i.e. index.php) looks like; it is a juggernaut. It is deceiving. It’s a mere 10 lines long but there is much below the surface, and done mostly via stored procedures.

I think I will amend the Commits class to handle a date and a limit.

Website Pin Facebook Twitter Myspace Friendfeed Technorati del.icio.us Digg Google StumbleUpon Premium Responsive