• Welcome to Simple Machines Community Forum. Please login or sign up.

Twenty-four things you can do to make SMF go faster (Updated June 16th, 2010)

Started by Vekseid, February 16, 2009, 06:29:50 AM

Previous topic - Next topic

Something like that

Set the permissions on the directory to 777 (read, write, execute for owner, group, everyone).

Y2Chaos

Quote from: Mark Rose on September 08, 2009, 08:45:00 PM
Set the permissions on the directory to 777 (read, write, execute for owner, group, everyone).

I know this sounds incredibly newb'ish but how do I do that? At the ftp site, I clicked properties, and checked permissions for owner, group, all users. Is there a different way to do this or what is the correct way to change the permissions? Also, do I just to do it to avs, or do I also have to do it forums, and docs?

Thanks in advance.

Something like that

Quote from: Y2Chaos on September 08, 2009, 08:51:30 PM
Quote from: Mark Rose on September 08, 2009, 08:45:00 PM
Set the permissions on the directory to 777 (read, write, execute for owner, group, everyone).

I know this sounds incredibly newb'ish but how do I do that? At the ftp site, I clicked properties, and checked permissions for owner, group, all users. Is there a different way to do this or what is the correct way to change the permissions? Also, do I just to do it to avs, or do I also have to do it forums, and docs?

Thanks in advance.

Just make sure the read, write, and execute bit are checked for owner, group, and all users.  You only have to do that for avs.

Y2Chaos

Quote from: Mark Rose on September 08, 2009, 09:02:07 PM

Just make sure the read, write, and execute bit are checked for owner, group, and all users.  You only have to do that for avs.

I may be doing something wrong. At the ftp site, I right clicked avs, selected properties, and checked read, write, execute for owner, group, all users.

I still get the following error message

The attachments upload directory is not writable. Your attachment or avatar cannot be saved.

Something like that

Quote from: Y2Chaos on September 08, 2009, 09:55:17 PM
Quote from: Mark Rose on September 08, 2009, 09:02:07 PM

Just make sure the read, write, and execute bit are checked for owner, group, and all users.  You only have to do that for avs.

I may be doing something wrong. At the ftp site, I right clicked avs, selected properties, and checked read, write, execute for owner, group, all users.

I still get the following error message

The attachments upload directory is not writable. Your attachment or avatar cannot be saved.

Make sure you have the directory correctly specified in smf -- if it doesn't exist, you'll get an error like that.

Y2Chaos

If you go back to the last post on page 5, you can see how I currently have my Avatar and Attachments settings. Did I do something wrong there?


Y2Chaos

Upload directory:      /forums/avs
Upload URL:             http://y2chaos.com/docs/forums/avs/

Okay, I changed it to the above. Is that the way it should be? By chance, should it be docs/forums/avs in the upload directory? Sorry for being such a pest. I changed it to the above and still got that error message.


Something like that

Try /home/content/m/i/s/mistabinks02/html/forums/avs
/forums/avs probably doesn't exist on your server ;)

ElectricSquid

Quote from: ☯ Mark Rose on February 21, 2009, 05:30:19 AM
If you have a lot of attachments, this change can greatly lower SMF's CPU usage.

This modification disables theme loading for attachments. It's a simple tweak for a big boost.

In Load.php, copy this:

// The following determines the user agent (browser) as best it can.
$context['browser'] = array(
'is_opera' => strpos($_SERVER['HTTP_USER_AGENT'], 'Opera') !== false,
'is_opera6' => strpos($_SERVER['HTTP_USER_AGENT'], 'Opera 6') !== false,
'is_opera7' => strpos($_SERVER['HTTP_USER_AGENT'], 'Opera 7') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'Opera/7') !== false,
'is_opera8' => strpos($_SERVER['HTTP_USER_AGENT'], 'Opera 8') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'Opera/8') !== false,
'is_ie4' => strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 4') !== false && strpos($_SERVER['HTTP_USER_AGENT'], 'WebTV') === false,
'is_safari' => strpos($_SERVER['HTTP_USER_AGENT'], 'Safari') !== false,
'is_mac_ie' => strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 5.') !== false && strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false,
'is_web_tv' => strpos($_SERVER['HTTP_USER_AGENT'], 'WebTV') !== false,
'is_konqueror' => strpos($_SERVER['HTTP_USER_AGENT'], 'Konqueror') !== false,
'is_firefox' => strpos($_SERVER['HTTP_USER_AGENT'], 'Firefox') !== false,
'is_firefox1' => strpos($_SERVER['HTTP_USER_AGENT'], 'Firefox/1.') !== false,
'is_firefox2' => strpos($_SERVER['HTTP_USER_AGENT'], 'Firefox/2.') !== false,
);

$context['browser']['is_gecko'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Gecko') !== false && !$context['browser']['is_safari'] && !$context['browser']['is_konqueror'];

// Internet Explorer 5 and 6 are often "emulated".
$context['browser']['is_ie7'] = strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 7') !== false && !$context['browser']['is_opera'] && !$context['browser']['is_gecko'] && !$context['browser']['is_web_tv'];
$context['browser']['is_ie6'] = strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 6') !== false && !$context['browser']['is_opera'] && !$context['browser']['is_gecko'] && !$context['browser']['is_web_tv'];
$context['browser']['is_ie5.5'] = strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 5.5') !== false && !$context['browser']['is_opera'] && !$context['browser']['is_gecko'] && !$context['browser']['is_web_tv'];
$context['browser']['is_ie5'] = strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 5.0') !== false && !$context['browser']['is_opera'] && !$context['browser']['is_gecko'] && !$context['browser']['is_web_tv'];

$context['browser']['is_ie'] = $context['browser']['is_ie4'] || $context['browser']['is_ie5'] || $context['browser']['is_ie5.5'] || $context['browser']['is_ie6'] || $context['browser']['is_ie7'];
$context['browser']['needs_size_fix'] = ($context['browser']['is_ie5'] || $context['browser']['is_ie5.5'] || $context['browser']['is_ie4'] || $context['browser']['is_opera6']) && strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') === false;

to a new function, detectBrowser(), in Load.php. Don't forget to include global $context; at the top.

I replaced this in index.php:

// Load the current theme.  (note that ?theme=1 will also work, may be used for guest theming.)
loadTheme();

with

// Load the current theme.  (note that ?theme=1 will also work, may be used for guest theming.)
if (! (isset($_REQUEST['action']) && $_REQUEST['action'] == 'dlattach'))
loadTheme();
else
detectBrowser();


On my system, it reduced my CPU usage by 14%. I do about 4 downloads for every 1 page view.

I do about 800,000 attachments & thumbnail downloads per day, so it really added up.

Is this able to work with SMF 1.1.10?

Something like that

Quote from: ∑£ℓ¢†®¡¢ §ợų¡đ on September 10, 2009, 10:46:04 PM
Quote from: ☯ Mark Rose on February 21, 2009, 05:30:19 AM
If you have a lot of attachments, this change can greatly lower SMF's CPU usage.

This modification disables theme loading for attachments. It's a simple tweak for a big boost.

In Load.php, copy this:

// The following determines the user agent (browser) as best it can.
$context['browser'] = array(
'is_opera' => strpos($_SERVER['HTTP_USER_AGENT'], 'Opera') !== false,
'is_opera6' => strpos($_SERVER['HTTP_USER_AGENT'], 'Opera 6') !== false,
'is_opera7' => strpos($_SERVER['HTTP_USER_AGENT'], 'Opera 7') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'Opera/7') !== false,
'is_opera8' => strpos($_SERVER['HTTP_USER_AGENT'], 'Opera 8') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'Opera/8') !== false,
'is_ie4' => strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 4') !== false && strpos($_SERVER['HTTP_USER_AGENT'], 'WebTV') === false,
'is_safari' => strpos($_SERVER['HTTP_USER_AGENT'], 'Safari') !== false,
'is_mac_ie' => strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 5.') !== false && strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false,
'is_web_tv' => strpos($_SERVER['HTTP_USER_AGENT'], 'WebTV') !== false,
'is_konqueror' => strpos($_SERVER['HTTP_USER_AGENT'], 'Konqueror') !== false,
'is_firefox' => strpos($_SERVER['HTTP_USER_AGENT'], 'Firefox') !== false,
'is_firefox1' => strpos($_SERVER['HTTP_USER_AGENT'], 'Firefox/1.') !== false,
'is_firefox2' => strpos($_SERVER['HTTP_USER_AGENT'], 'Firefox/2.') !== false,
);

$context['browser']['is_gecko'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Gecko') !== false && !$context['browser']['is_safari'] && !$context['browser']['is_konqueror'];

// Internet Explorer 5 and 6 are often "emulated".
$context['browser']['is_ie7'] = strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 7') !== false && !$context['browser']['is_opera'] && !$context['browser']['is_gecko'] && !$context['browser']['is_web_tv'];
$context['browser']['is_ie6'] = strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 6') !== false && !$context['browser']['is_opera'] && !$context['browser']['is_gecko'] && !$context['browser']['is_web_tv'];
$context['browser']['is_ie5.5'] = strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 5.5') !== false && !$context['browser']['is_opera'] && !$context['browser']['is_gecko'] && !$context['browser']['is_web_tv'];
$context['browser']['is_ie5'] = strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 5.0') !== false && !$context['browser']['is_opera'] && !$context['browser']['is_gecko'] && !$context['browser']['is_web_tv'];

$context['browser']['is_ie'] = $context['browser']['is_ie4'] || $context['browser']['is_ie5'] || $context['browser']['is_ie5.5'] || $context['browser']['is_ie6'] || $context['browser']['is_ie7'];
$context['browser']['needs_size_fix'] = ($context['browser']['is_ie5'] || $context['browser']['is_ie5.5'] || $context['browser']['is_ie4'] || $context['browser']['is_opera6']) && strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') === false;

to a new function, detectBrowser(), in Load.php. Don't forget to include global $context; at the top.

I replaced this in index.php:

// Load the current theme.  (note that ?theme=1 will also work, may be used for guest theming.)
loadTheme();

with

// Load the current theme.  (note that ?theme=1 will also work, may be used for guest theming.)
if (! (isset($_REQUEST['action']) && $_REQUEST['action'] == 'dlattach'))
loadTheme();
else
detectBrowser();


On my system, it reduced my CPU usage by 14%. I do about 4 downloads for every 1 page view.

I do about 800,000 attachments & thumbnail downloads per day, so it really added up.

Is this able to work with SMF 1.1.10?

It should.

Of course, only people who can figure out the code should try doing it... so make the change at your own risk :)

ElectricSquid

Quote
Of course, only people who can figure out the code should try doing it... so make the change at your own risk :)

Oh, thanks. Nothing easy here, eh?

I'll fumble my way through it. That's how I learn.
If I screw it up, there is always the backup file.
LOL, one advantage of running my own server is the backup is as fast as a copy and paste :P

------------------------------------------------------------------------

I've been going through the MySQL optimization stuff back on page 2. For some reason I cannot get MySQL to restart after adding innodb_flush_method=O_DIRECT to my.ini (Windows)
Is there any special reason this won't work?

Something like that

Quote from: ∑£ℓ¢†®¡¢ §ợų¡đ on September 10, 2009, 11:35:18 PM
Quote
Of course, only people who can figure out the code should try doing it... so make the change at your own risk :)

Oh, thanks. Nothing easy here, eh?

It's just to scare people away from messing with things they don't know enough to fix if they screw up :)

Quote
I've been going through the MySQL optimization stuff back on page 2. For some reason I cannot get MySQL to restart after adding innodb_flush_method=O_DIRECT to my.ini (Windows)
Is there any special reason this won't work?

Yeah, Windows doesn't support that flush method. :)

ElectricSquid

Quote from: Mark Rose on September 10, 2009, 11:55:15 PM

It's just to scare people away from messing with things they don't know enough to fix if they screw up :)


OK, that was easy...
How do I tell if it's working?

ElectricSquid

... and does it matter where in Load I add the function, or should it be in a certain place?
Any idea if TinyPortal 0.9.8 will have an issue with it?

Arantor

No, you can put the function anywhere AFAIK provided the call is correctly placed.
No good deed goes unpunished
All helpful urges should be circumvented

Something like that

Quote from: ∑£ℓ¢†®¡¢ §ợų¡đ on September 11, 2009, 10:16:39 AM
Quote from: Mark Rose on September 10, 2009, 11:55:15 PM

It's just to scare people away from messing with things they don't know enough to fix if they screw up :)


OK, that was easy...
How do I tell if it's working?

Your CPU usage will lower significantly if:
a) You have a lot of attachments
b) You haven't specified a custom avatar directory

If your attachment thumbnails are loading correctly, it's working :)

Quote from: ∑£ℓ¢†®¡¢ §ợų¡đ on September 11, 2009, 10:24:11 AM
... and does it matter where in Load I add the function, or should it be in a certain place?
Any idea if TinyPortal 0.9.8 will have an issue with it?

TinyPortal shouldn't have any issues with it. It only matters when you are showing attachment thumbnails, and don't have a custom attachment directory.

Quote from: Arantor on September 11, 2009, 10:31:42 AM
No, you can put the function anywhere AFAIK provided the call is correctly placed.

Correct. As long as the function is loaded before it's called, you're good. :)

ElectricSquid

I'm not sure why, but with coded in, TPortal.php breaks.
With every attachment, I get undefined index errors for 'is_admin' and a few others in TPortal.php

If I remove this function detectBrowser(), all is well in the error log.

Creating the function was a snap, but fixing TP to play nice is outside of the scope of my abilities right now, so I may have to save this for another time.

I know that TP does do it's own browser detection, so I'm not sure if it's somehow in conflict.

Oh, and the attachment thumbs loaded properly.
LOL, if I don't get an error on the first try, it makes me wonder if it's even working :P

ElectricSquid

Yea, I tried to rename it detectBrowswer2() but that throws the same errors.

Joshua Dickerson

I wonder why it is using so much CPU on a bunch of simple strpos calls.
Come work with me at Promenade Group



Need help? See the wiki. Want to help SMF? See the wiki!

Did you know you can help develop SMF? See us on Github.

How have you bettered the world today?

Advertisement: