[ADD-ON] improve forum speed

Mod that adds a birthday field to the users profile, theire age are displayed beside the posts, and on there birthday they will have a greeting popup
Forum rules
The content in this forum is dated Dec. 21 2005 and can be used as Archive only. This Forum is LOCKED and READ ONLY !

[ADD-ON] improve forum speed

Postby Blisk on Fri 10. Sep, 2004 21:32

This mod slows down forum very much.
I think because everytime I load index page this mod check all users for birthday. I think that is the problem.
Maybe it will be better that this mod do that only few times per day.
Or maybe some other improvement to speed up page loading where this mod is installed.
Blisk
Poster
Poster
 
Posts: 128
Joined: Wed 20. Aug, 2003 14:14

Postby Niels on Sun 12. Sep, 2004 22:44

you are rigth about the speed on index page, it will slow it down - any extra information needed will slow down your www.

Sadly windows OS can't handle dates back in time (prior to 1986), and as you might now, meny users have a birthday back in time :lol:
therefore it have been nessesary to make php functions witch can calculate dates prior to this, as the dates have to be calculated for all users, this will take some time, all depending on how meny users have filled a birthday.

if your server is runing on a NIX server (linux), you may gain speed improvements if installing this mod as described for unix, see the how-to about how to do this (you need to modify functions.php)
(if a how-to is EM ready, it will mostly be bullet prof, since a machine is more picky than a human. :D)
User avatar
Niels
Poster
Poster
 
Posts: 4390
Joined: Sat 27. Jul, 2002 15:46

Postby Blisk on Mon 13. Sep, 2004 09:20

tnx for info, I use linux server.
I will check, that what you suggest.

Sorry I don't understand quite good what I must change, can somebody help me???
I change
//function realdate($date_syntax="Ymd",$date=0)
with
//{ return create_date($date_syntax,$date*86400+1,0); }
Bit doesn't work!
Blisk
Poster
Poster
 
Posts: 128
Joined: Wed 20. Aug, 2003 14:14

Postby Niels on Mon 13. Sep, 2004 21:56

it is the COMPLETE function witch should be replaced... (ONLY FOR SERVERS RUNING *NIX e.g. linux)

e.g.

FIND
Code: Select all
function realdate($date_syntax="Ymd",$date=0)
{
   global $lang;
   $i=2;
   if ($date>=0)
   {
       return create_date($date_syntax,$date*86400+1,0);
   } else
   {
      $year= -(date%1461);
      $days = $date + $year*1461;
      while ($days<0)
      {
         $year--;
         $days+=365;
         if ($i++==3)
         {
            $i=0;
            $days++;
         }
      }
   }
   $leap_year = ($i==0) ? TRUE : FALSE;
   $months_array = ($i==0) ?
      array (0,31,60,91,121,152,182,213,244,274,305,335,366) :
      array (0,31,59,90,120,151,181,212,243,273,304,334,365);
   for ($month=1;$month<12;$month++)
   {
      if ($days<$months_array[$month]) break;
   }

   $day=$days-$months_array[$month-1]+1;
   //you may gain speed performance by remove som of the below entry's if they are not needed/used
   return strtr ($date_syntax, array(
      'd' => ($day>9) ? $day : '0'.$day,
      'D' => $lang['day_short'][($date-3)%7],
      'F' => $lang['month_long'][$month-1],
      'j' => $day,
      'l' => $lang['day_long'][($date-3)%7],
      'L' => $leap_year,
      'm' => ($month>9) ? $month : '0'.$month,
      'M' => $lang['month_short'][$month-1],
      'n' => $month,
      't' => $months_array[$month]-$months_array[$month-1],
      'y' => ($year>29) ? $year-30 : $year+70,
      'Y' => $year+1970,
      'z' => $days,
      'a' => '',
      'A' => '',
      '\\d' => 'd',
      'd' => ($day>9) ? $day : '0'.$day,
      '\\D' => 'D',
      'D' => $lang['day_short'][($date-3)%7],
      '\\F' => 'F',
      'F' => $lang['month_long'][$month-1],
      'g' => '',
      'G' => '',
      'H' => '',
      'h' => '',
      'i' => '',
      'I' => '',
      '\\j' => 'j',
      'j' => $day,
      '\\l' => 'l',
      'l' => $lang['day_long'][($date-3)%7],
      '\\L' => 'L',
      'L' => $leap_year,
      '\\m' => 'm',
      'm' => ($month>9) ? $month : '0'.$month,
      '\\M' => 'M',
      'M' => $lang['month_short'][$month-1],
      '\\n' => 'n',
      'n' => $month,
      'O' => '',
      's' => '',
      'S' => '',
      '\\t' => 't',
      't' => $months_array[$month]-$months_array[$month-1],
      'w' => '',
      '\\y' => 'y',
      'y' => ($year>29) ? $year-30 : $year+70,
      '\\Y' => 'Y',
      'Y' => $year+1970,
      '\\z' => 'z',
      'z' => $days,
      '\\W' => '',
      'W' => '') );
}


REPLACE WITH
Code: Select all
function realdate($date_syntax="Ymd",$date=0)
{ return create_date($date_syntax,$date*86400+1,0); }



this should dramatically improve the speed on index.
Last edited by Niels on Sat 23. Oct, 2004 14:49, edited 1 time in total.
(if a how-to is EM ready, it will mostly be bullet prof, since a machine is more picky than a human. :D)
User avatar
Niels
Poster
Poster
 
Posts: 4390
Joined: Sat 27. Jul, 2002 15:46

Postby Niels on Mon 13. Sep, 2004 21:58

you see the complex code is needed if your server is windoze, while unix will settel with the small version - this code is executed for every user on your site, so it should improve your speed...

btw. I use the windoze version :cry:
Last edited by Niels on Sun 17. Oct, 2004 12:37, edited 1 time in total.
(if a how-to is EM ready, it will mostly be bullet prof, since a machine is more picky than a human. :D)
User avatar
Niels
Poster
Poster
 
Posts: 4390
Joined: Sat 27. Jul, 2002 15:46

Postby Blisk on Tue 14. Sep, 2004 07:42

TNX for help!
I must trully say, that I like to use windoze too, because with linux there is so much trouble, but now I learn a lot, and to install a linux and forum on in is really simple.
But all other things makes life complicated, windows are much simplier.
Blisk
Poster
Poster
 
Posts: 128
Joined: Wed 20. Aug, 2003 14:14

Postby Niels on Wed 15. Sep, 2004 22:54

Once a linux is up and runing, and you have done the configuration, it will will run for ever, without need of "maintaince" - whitch can not be said about a windoze.
once you get microsoft inside a machine,, you need constantly to monitor it, clean up, update it, restart, re-install, ect.
I belive in long term, it is a benefit to run on linux.

As a developper, it is better to run on a windoze - mainly becouse it is not as compatible as linux.
in php ther eis a few limitations regarding windoze + PHP
some features will simply not work on a windoze server.
you see I make software, witch should work on both windoze and linux - If I was runing on a linux, I could not detect, and test the fault, witch only showed on a windoze.
So I guess Im kind of stuck with windows...
I do though belive that I the futare are changing to linux, this will though require me to have "windoze "development" mashine runing to test on
(if a how-to is EM ready, it will mostly be bullet prof, since a machine is more picky than a human. :D)
User avatar
Niels
Poster
Poster
 
Posts: 4390
Joined: Sat 27. Jul, 2002 15:46

Postby Niels on Thu 16. Sep, 2004 00:06

need of more speed ?
I have now made a data cache, with caches the birthday list, so this is only calculated for every 10 min.
this will bring your index backto the "old" speed - atleast the majority of the time.
(if a how-to is EM ready, it will mostly be bullet prof, since a machine is more picky than a human. :D)
User avatar
Niels
Poster
Poster
 
Posts: 4390
Joined: Sat 27. Jul, 2002 15:46

Next

Return to Birthday [2.0.10/EM]

Who is online

Users browsing this forum: No registered users and 1 guest

cron