Customizing SMF > SMF Coding Discussion
[WIP]SQLite3 Cache System
Arantor:
I'd benchmark it. Anything else may actually be placebo effect.
CircleDock:
I agree that any apparent speed increase may be subjective. However there must be some gain due to the fact that illegal file names won't be used as cache keys.
Arantor:
That's a definite functional enhancement, sure, and even if you don't get a performance boost, it's certainly useful.
Of course, that relies on having SQLite3 available...
CircleDock:
There is one line that's causing a problem on the production server but not on my local server. In function sicache_trans()
--- Code: ---ob_end_flush();
--- End code ---
It's causing errors on that server and a read of the PHP docs suggests the call may actually not be necessary.
Edit:
ob_end_flush is necessary otherwise the MySQL database isn't updated with any changes. However:
--- Code: ---if (ob_get_level() > 0)
ob_end_flush();
--- End code ---
seems to fix that problem.
nend:
@ Circledock, vacuum has been working in the recent code. On the previous code I forgot to call vacuum;. Also if you use PDO it is going to use SQLite 2, which is OK also.
As for performance gains, It is a little difficult to explain because mainly there looks to be none. The initial connection is actually slower than the file cache, which means that the first few cache calls will be slower, however anything after will be faster usually. If you benchmark it you will either get results faster, slower or about equal.
One suggestion though, I had to figure this out also. What you want in SQLite is to lock that database file the least amount time possible. Basically anything that writes to the DB file, "INSERT;DELETE;UPDATE;VACUUM" should be called in a transaction to minimize file locking.
--- Quote from: CircleDock on May 23, 2012, 07:45:17 AM ---There is one line that's causing a problem on the production server but not on my local server. In function sicache_trans()
--- Code: ---ob_end_flush();
--- End code ---
It's causing errors on that server and a read of the PHP docs suggests the call may actually not be necessary.
Edit:
ob_end_flush is necessary otherwise the MySQL database isn't updated with any changes. However:
--- Code: ---if (ob_get_level() > 0)
ob_end_flush();
--- End code ---
seems to fix that problem.
--- End quote ---
Yeah, notice that error a while back and forgot to fix it. It is caused by the buffer being empty, doesn't happen to much but it does happen.
The code around this area is a workaround for a bug in PHP, if I don't flush the buffer and there is a function in the callback that uses the cache then SMF will crash with no output. I hate the bug and even hate my own workaround because it is a blind query. All SQLite database operations crash in the output buffer callback.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version