Author Topic: Forum lag (possibly) solved  (Read 48108 times)

Offline AStrangeGeek

  • Administrator
  • *****
  • Posts: 21914
  • Gender: Male
    • http://www.asstr.org/~A_Strange_Geek/
Forum lag (possibly) solved
« on: December 07, 2014, 03:27:42 AM »
I am hoping I have fixed the lag we've been experiencing on the forums and gallery. I had to hack the gallery code to fix it, so it's possible things may break that I have not foreseen (if you saw any database errors will in the gallery about 10 minutes ago, that was me mucking with stuff). Backups of the code were made if I need to restore anything.

For the technical-minded: The issue was an SQL query that was intended to query all images in the gallery. It had an unnecessary (I believe) LEFT JOIN that was taking a long time to execute for users that have viewed a large number of images since the new gallery opened. Shame on you for being such loyal members! ;)
Pick one: 1) It's not my fault  2) I wasn't there  3) You have no witnesses  4) It would have happened on it's own anyway.

Avatar image courtesy of CyberK82

Offline Allister

  • Comic Creator
  • *
  • Posts: 1880
  • The next test subject is ready for processing.
    • My Smashwords Page
Re: Forum lag (possibly) solved
« Reply #1 on: December 07, 2014, 03:31:29 AM »
Awesome!

(Man I wish I knew how to code)

Offline TeraS

  • Queen of the Succubi
  • Administrator
  • *****
  • Posts: 49038
  • Gender: Female
  • Behind You... Am I Going To Huggle You Or Poke You
    • http://www.succubus.net/blog
  • Skype: PM Me
Re: Forum lag (possibly) solved
« Reply #2 on: December 07, 2014, 06:18:12 AM »
Thank you ASG...

Please note!

If you do see problems, please report them to myself or ASG with the error you see please!


Tera
Admin
Thank you for calling TeraS, Queen of the Succubi. Please wait and she will be with you shortly...
http://www.succubus.net     http://www.succubi.net     http://www.succubi.com

Offline dzeiger

  • Patreon Supporter
  • *****
  • Posts: 113
Re: Forum lag (possibly) solved
« Reply #3 on: December 07, 2014, 06:26:07 AM »
I'm guessing this is why I'm no longer seeing "new" tags on images I have yet to view in the gallery?

Clicking on "Unviewed" still seems to work, though, so something may still be tracking, it's just the tag in the main gallery that seems to have gone away.

Offline AStrangeGeek

  • Administrator
  • *****
  • Posts: 21914
  • Gender: Male
    • http://www.asstr.org/~A_Strange_Geek/
Re: Forum lag (possibly) solved
« Reply #4 on: December 07, 2014, 06:37:47 AM »
I'm guessing this is why I'm no longer seeing "new" tags on images I have yet to view in the gallery?

Clicking on "Unviewed" still seems to work, though, so something may still be tracking, it's just the tag in the main gallery that seems to have gone away.
Hmm, it still seems to be working for me. Also the tag still properly goes away after I view the image. I also tried it from a non-admin test account I keep around for testing permissions issues.

There is a table that tracks which images are viewed, but I did not touch the data there.

Maybe lets revisit this in a day and see if the problem is still persisting for you.
Pick one: 1) It's not my fault  2) I wasn't there  3) You have no witnesses  4) It would have happened on it's own anyway.

Avatar image courtesy of CyberK82

Offline AStrangeGeek

  • Administrator
  • *****
  • Posts: 21914
  • Gender: Male
    • http://www.asstr.org/~A_Strange_Geek/
Re: Forum lag (possibly) solved
« Reply #5 on: December 07, 2014, 08:01:45 AM »
So there is still some lingering lag, but I believe I know where it is, it will just be a little more tricky to resolve. Still, there does seem to be improvement.
Pick one: 1) It's not my fault  2) I wasn't there  3) You have no witnesses  4) It would have happened on it's own anyway.

Avatar image courtesy of CyberK82

Offline loosegoose

  • Global Moderator
  • *****
  • Posts: 7279
  • Gender: Male
Re: Forum lag (possibly) solved
« Reply #6 on: December 07, 2014, 02:24:07 PM »
You see, this is why the admins take their salaries home in a wheelbarrow. Mucho kudos.

Offline dzeiger

  • Patreon Supporter
  • *****
  • Posts: 113
Re: Forum lag (possibly) solved
« Reply #7 on: December 07, 2014, 09:35:35 PM »

Hmm, it still seems to be working for me. Also the tag still properly goes away after I view the image. I also tried it from a non-admin test account I keep around for testing permissions issues.

There is a table that tracks which images are viewed, but I did not touch the data there.

Maybe lets revisit this in a day and see if the problem is still persisting for you.

Played around with it a little more today.

The tag is there in the default "Recent Pictures" list, but if you click "List all" to go to "Last Pictures Uploaded" the tag no longer shows up for unviewed pictures.

Offline AStrangeGeek

  • Administrator
  • *****
  • Posts: 21914
  • Gender: Male
    • http://www.asstr.org/~A_Strange_Geek/
Re: Forum lag (possibly) solved
« Reply #8 on: December 07, 2014, 09:40:48 PM »

Hmm, it still seems to be working for me. Also the tag still properly goes away after I view the image. I also tried it from a non-admin test account I keep around for testing permissions issues.

There is a table that tracks which images are viewed, but I did not touch the data there.

Maybe lets revisit this in a day and see if the problem is still persisting for you.

Played around with it a little more today.

The tag is there in the default "Recent Pictures" list, but if you click "List all" to go to "Last Pictures Uploaded" the tag no longer shows up for unviewed pictures.
Okay, I do see that. If that is the only issue, we may have to just put up with it. The problem with the lag issue is that if I put the query back the way it was, the problem will steadily get worse as more people look at pictures. I think most people tend to look at the main page anyway to determine the new images that have been added.
Pick one: 1) It's not my fault  2) I wasn't there  3) You have no witnesses  4) It would have happened on it's own anyway.

Avatar image courtesy of CyberK82

Offline Allister

  • Comic Creator
  • *
  • Posts: 1880
  • The next test subject is ready for processing.
    • My Smashwords Page
Re: Forum lag (possibly) solved
« Reply #9 on: December 08, 2014, 07:58:56 PM »
The forums are sure zipping along today. It's very nice!

Offline AStrangeGeek

  • Administrator
  • *****
  • Posts: 21914
  • Gender: Male
    • http://www.asstr.org/~A_Strange_Geek/
Re: Forum lag (possibly) solved
« Reply #10 on: December 23, 2014, 06:03:18 PM »
So just an update on this.

We still have one remaining lag issue. I know where exactly in the code that the SQL query-o-doom is that is causing it but the query itself cannot be fixed. I've tried experimentally rewriting it several different ways without success. The only way to fix it is to break it into two queries and write a lot of additional php code to do the additional processing.

The problem is caused when some users click the "Unviewed" button in the gallery. For some users, the subsequent query takes 4 to 5 seconds to run. Users who have been looking at almost every pic in the gallery since the new gallery opened are incurring this delay. So for those using this option, if every time you click it you see this delay, then your user account is one of the ones incurring the lag. While that query runs, everything else has to queue up behind it.

This is not the fault of the users utilizing that function, it's just revealing a poor software design decision by the SMF gallery developers. I hope to have a chance to see if I can fix the code, but if I can't and the lag get's worse, I may have to take that feature away.
Pick one: 1) It's not my fault  2) I wasn't there  3) You have no witnesses  4) It would have happened on it's own anyway.

Avatar image courtesy of CyberK82

Offline Allister

  • Comic Creator
  • *
  • Posts: 1880
  • The next test subject is ready for processing.
    • My Smashwords Page
Re: Forum lag (possibly) solved
« Reply #11 on: December 23, 2014, 08:02:37 PM »
Nice to have someone on board who knows how to code.  :)

Offline MCaesar

  • Patreon Supporter
  • *****
  • Posts: 7800
  • Gender: Male
  • Balance in all things. Even perversion.
Re: Forum lag (possibly) solved
« Reply #12 on: December 24, 2014, 12:37:19 AM »
The problem is caused when some users click the "Unviewed" button in the gallery. For some users, the subsequent query takes 4 to 5 seconds to run. Users who have been looking at almost every pic in the gallery since the new gallery opened are incurring this delay.

I had suspected that determining which items have been viewed or unviewed by each user would be a costly operation. Too bad that's the most convenient way for me to browse. When I do refresh unviewed though, it doesn't seem to take very long, most of the time.

Offline AStrangeGeek

  • Administrator
  • *****
  • Posts: 21914
  • Gender: Male
    • http://www.asstr.org/~A_Strange_Geek/
Re: Forum lag (possibly) solved
« Reply #13 on: December 24, 2014, 12:53:00 AM »
The problem is caused when some users click the "Unviewed" button in the gallery. For some users, the subsequent query takes 4 to 5 seconds to run. Users who have been looking at almost every pic in the gallery since the new gallery opened are incurring this delay.

I had suspected that determining which items have been viewed or unviewed by each user would be a costly operation. Too bad that's the most convenient way for me to browse. When I do refresh unviewed though, it doesn't seem to take very long, most of the time.
Yeah, it's only certain user accounts that do it. When I plugged my user ID into the query, it came back in a fraction of a second, but I don't peruse the gallery as much, and when I do, I just scroll the main page looking for "unviewed" tags (since that's what I was used to doing in the old gallery).

I'll do my best to preserve the functionality.
Pick one: 1) It's not my fault  2) I wasn't there  3) You have no witnesses  4) It would have happened on it's own anyway.

Avatar image courtesy of CyberK82

Offline Silverkat

  • RP Forum Moderator
  • ***
  • Posts: 17687
  • Gender: Female
Re: Forum lag (possibly) solved
« Reply #14 on: January 08, 2015, 03:07:00 AM »
I seem to be getting bad lag randomly and have been for quite a while now.

When the new forum started I got no lag at all, but then one day it seemed to shift and I'd get extremely bad lag, but only now and again. I can refresh the same page a bunch of times and get nearly instant loading... but then it will suddenly take minutes to do so.

It's worst when I'm looking at my PMs, but can strike the forums as well.

Posting replys is extremely laggy as well.

Offline AStrangeGeek

  • Administrator
  • *****
  • Posts: 21914
  • Gender: Male
    • http://www.asstr.org/~A_Strange_Geek/
Re: Forum lag (possibly) solved
« Reply #15 on: January 08, 2015, 03:28:40 AM »
I seem to be getting bad lag randomly and have been for quite a while now.

When the new forum started I got no lag at all, but then one day it seemed to shift and I'd get extremely bad lag, but only now and again. I can refresh the same page a bunch of times and get nearly instant loading... but then it will suddenly take minutes to do so.

It's worst when I'm looking at my PMs, but can strike the forums as well.

Posting replys is extremely laggy as well.
Yeah, it happens when a lot of people are logged into the gallery all trying to click on the "Unviewed" button, as that is what is generating the lag (though not for all users). I hope to see if I can modify the code soon.

So the good news is I know exactly what is causing it. The solution will just be tricky.
Pick one: 1) It's not my fault  2) I wasn't there  3) You have no witnesses  4) It would have happened on it's own anyway.

Avatar image courtesy of CyberK82

Offline AStrangeGeek

  • Administrator
  • *****
  • Posts: 21914
  • Gender: Male
    • http://www.asstr.org/~A_Strange_Geek/
Re: Forum lag (possibly) solved
« Reply #16 on: March 01, 2015, 12:52:42 AM »
I am in the process of testing a change to one of the gallery scripts in hope of fixing the lag. I want to test it some more before I swap it in.
Pick one: 1) It's not my fault  2) I wasn't there  3) You have no witnesses  4) It would have happened on it's own anyway.

Avatar image courtesy of CyberK82

Offline AStrangeGeek

  • Administrator
  • *****
  • Posts: 21914
  • Gender: Male
    • http://www.asstr.org/~A_Strange_Geek/
Re: Forum lag (possibly) solved
« Reply #17 on: March 01, 2015, 01:07:09 AM »
The fix is now in place. The gallery function that was affected is the "unviewed" button, so please let me know if anything is broken.
Pick one: 1) It's not my fault  2) I wasn't there  3) You have no witnesses  4) It would have happened on it's own anyway.

Avatar image courtesy of CyberK82

 




Visit Our Sister Site!