CAN I BE OF ASSISTANCE?
Saturday, March 31
Always In The Last Place You Look
I've been scratching my head trying to work out why the main query that drives Minx blogs is so inefficient. I tweak indexes and I tweak selection criteria and I tweak sorting and nothing seems to improve the query time reported at the bottom of the page. Now, normally it's only 20ms or so, but if you catch it after an update - a new post or comment - it blows out to 400ms or so because the query cache just got flushed.
So I tweaked and I twiddled and I fiddled and fretted, and I took the query and plugged in some parameters and ran it outside of Minx, and it turned out to be, in fact, reasonably quick.
Then I tried disabling the sidebar to see what effect that had on the total query time.
19ms cached; 28ms uncached. Perfectly reasonable for selecting and sorting and joining multiple fairly complex (albeit small) subsets of 13,000 records.
It's those darn recent comments again!
Update: And now I remember why recent comments are slow. When you list the recent comments, you're listing the last 20 (or whatever) comments in a folder. But comments aren't in folders, they're in threads, so you have to look at the threads in the folder, and then find the most recent comments from among the comments in those threads. Big slow join before the sort.
There's a straightforward way to optimise the common case - use either multiple queries or subqueries to restrict MySQL to only inspect the 20 most recently updated threads. That gets messy for the general case, though, where you want page 17 of recent comments.
Need to spend a bit more time thinking about this one.
Update: Gargh! MySQL 5.0.27 doesn't support
LIMIT in subqueries anyway.
Update: Well, it doesn't if you're using
IN to restrict the main search to a subset of threads selected by the subquery, but if you use the subquery to return the update datetime of the
nth most recently updated thread and then restrict the search to threads updated since then, you're swimming in gravy.
...
Which would be pretty unpleasant, come to think of it.
Posted by: Pixy Misa at
06:13 AM
| Comments (19)
| Add Comment
| Trackbacks (Suck)
Post contains 367 words, total size 2 kb.
1
Of
course it's the last place you look, because once you find it,
you stop looking.
Posted by: Steven Den Beste at Saturday, March 31 2007 05:18 PM (+rSRq)
2
Rule only applies to normal people.
Posted by: Pixy Misa at Saturday, March 31 2007 05:19 PM (PiXy!)
3
New query is in place. Seems not to have broken things too badly...
Posted by: Pixy Misa at Monday, April 02 2007 03:28 AM (PiXy!)
4
Seems to be roughly 20x faster on the common worst case (query cache flushed, showing most recent comments) and no slower on the best case (query in cache) or absolute worst case (cache flushed, page n of n).
Posted by: Pixy Misa at Monday, April 02 2007 03:32 AM (PiXy!)
5
Except that it
didn't work!Well, the way it worked was that if you wanted, say, the 20 most recent comments, it found the date of the 20th most recently updated post, and only scanned the comments of posts updated at least as recently as that.
If you didn't have 20 posts, that kind of went bang.
Testing a modified version now.
Posted by: Pixy Misa at Monday, April 02 2007 12:25 PM (PiXy!)
6
Yeah, that seems to be okay too. Take the max() of the updated datetime of the N most recent posts instead.
Posted by: Pixy Misa at Monday, April 02 2007 12:26 PM (PiXy!)
7
Okay, I'm not sure that the new version actually
works, performance-wise. Test test...
Posted by: Pixy Misa at Monday, April 02 2007 12:32 PM (PiXy!)
Posted by: Pixy Misa at Monday, April 02 2007 12:32 PM (PiXy!)
9
What if I tweak the query a little to use this new index?
Posted by: Pixy Misa at Monday, April 02 2007 12:35 PM (PiXy!)
Posted by: Pixy Misa at Monday, April 02 2007 12:35 PM (PiXy!)
11
Fnordles. The new subquery works just fine as a stand-alone query, but plug it into the main query and it all sucks. Some kind of limitation or bug in the MySQL query optimiser? Dunno.
But since an extra query only adds a few hundred microseconds, and I've already spent hours trying to make this work, I'm gonna go for the easy way out.
Posted by: Pixy Misa at Monday, April 02 2007 12:56 PM (PiXy!)
12
Well, that's not working either. But now that I can see the results from the subquery, I know why it's not working.
I don't know how to make it work, but I know why it's not working.
Posted by: Pixy Misa at Monday, April 02 2007 01:15 PM (PiXy!)
13
Trying again, this time with nested subqueries...
Posted by: Pixy Misa at Monday, April 02 2007 01:46 PM (PiXy!)
Posted by: Pixy Misa at Monday, April 02 2007 01:46 PM (PiXy!)
Posted by: Pixy Misa at Monday, April 02 2007 01:46 PM (PiXy!)
16
Hey, Webmaster! There's some loon using the name "Pixy" who's spamming your blog. If I were you, I'd ban him. (He can't possibly have anything interesting to say.)
Posted by: Steven Den Beste at Monday, April 02 2007 02:05 PM (+rSRq)
17
Thanks for the tip, Steven.
By the way, I think your network cable is plugged in upside down!
Posted by: Pixy Misa at Monday, April 02 2007 02:21 PM (PiXy!)
18
Could be; I'll check it out!
Posted by: Steven Den Beste at Monday, April 02 2007 02:31 PM (+rSRq)
19
I hope that's all it is... I don't want to have to turn my monitor upside down.
Posted by: Wonderduck at Monday, April 02 2007 04:15 PM (R/R0E)
Hide Comments
| Add Comment
Catagrees
Categories. On the right. On the category icons. In the trees. They're everywhere! Eeeeee!!!
...
Sorry.
Fixed a couple of problems. The MT->Minx transfer marked posts as unpublished under their individual categories (sort of, it's complicated), so they showed on the main blog page, but not on the category pages. And a bug in the recent comments query meant that recent comments didn't show up at all on category pages.
Now, back to being driven crazy by this darn editor.
Posted by: Pixy Misa at
03:57 AM
| No Comments
| Add Comment
| Trackbacks (Suck)
Post contains 81 words, total size 1 kb.
Friday, March 30
Bad Surprises
I was back at my old job today, preparing for what I hope is one of the last phone company bill runs I ever have to do, when suddenly, at about 5:45 on a Friday afternoon,* the billing server dropped dead.
My first thought was
Do we have backups? Yes, we have backups.** Okay then, let's haul the server out, plug it into a monitor (the computer room is not terribly well organised), and see what we get.
After a certain amount of fiddling I managed to get a BIOS screen up, and select the boot menu, whereupon the server spontaneously rebooted. I tried this several times with identical results; in fact, leaving the server alone would result in a boot-crash-boot-crash cycle just like my unlamented Compaq notebook.
There are four lights on the front of the server that indicate a POST code, so I hit Dell's website for the user manual and looked it up. Running down the list: CPU failure, memory failure, hard drive failure.***
USB failure.
Swapped the keyboard to a different USB port and it worked perfectly.
* There's some sort of physical law that requires this.
** It would take a couple of days to rebuild the system and restore the backups, but at least we had backups. From the previous day, I should add.
*** This is the mission-critical server that was spec'd with only one disk drive, so my first thought was exactly that.
Posted by: Pixy Misa at
08:42 PM
| Comments (1)
| Add Comment
| Trackbacks (Suck)
Post contains 243 words, total size 2 kb.
1
Yes. I can see how USB is key to a computer, let alone a server, operating.
Posted by: Andrew at Monday, April 02 2007 08:19 PM (/uGTr)
Hide Comments
| Add Comment
All Purpose Cultural Shopping Arcade Abenobashi
The music is good too.
Posted by: Pixy Misa at
05:09 PM
| Comments (2)
| Add Comment
| Trackbacks (Suck)
Post contains 11 words, total size 1 kb.
1
Now that I've actually seen it, I went back and reread Chris Beveridge's reviews of the series. He turns out to be the one who hated the ending. I really strongly disagree with him on that -- but that's what makes horse-races, I guess.
Posted by: Steven Den Beste at Saturday, March 31 2007 08:29 AM (+rSRq)
2
I've not seen the whole series, only the first couple of eps, but I laughed all the way thru them. I didn't have any urge to go out and see anything more, though.
Now I do, darn it.
Posted by: Wonderduck at Saturday, March 31 2007 11:24 AM (svIB9)
Hide Comments
| Add Comment
Timing Is Everything
70ms for the main page without comments.
150ms with comments.
96 comments displayed (including the Recent Comments thingy).
Hmm. A bit disappointing, considering this is the fastest hardware I'm likely to get this year.
I just hope that Ace, who has 200+ comments on individual posts, doesn't try to do inline comments.
Update: Well, it's not broken, just a bit poky at certain tasks. An individual entry page takes 5.7ms (elapsed time) if you remove the Recent Comments. 2.9ms of that is the SQL queries. The forum page sans sidebar takes 54ms to list 20 posts; 6ms for the queries. (The query times are for cached queries; uncached takes longer in elapsed time, but that doesn't come into CPU efficiency of the application code.)
If I tweak the forum listing to include the body of the post, it takes exactly the same amount of time to within the limits of precision of the built-in timer. Which shouldn't be surprising I guess; all the data processing is done whether the template needs it or not, and Python's string processing is very efficient. It does point to where I need to concentrate my attention, though.
Update: Adding the planned [
topics] selector and the associated [
topic] data tags reduces the time for a forum page sans sidebar to 13ms. The sidebar adds another 13ms. Extending it from 20 to 50 topics pushes the time out to 42ms: about 500μs per topic, compared to about 2ms per entry.
Posted by: Pixy Misa at
12:06 PM
| Comments (7)
| Add Comment
| Trackbacks (Suck)
Post contains 245 words, total size 2 kb.
1
Ace and the Jawas are the smoke test. If you can survive them, you can survive anything.
Posted by: Steven Den Beste at Saturday, March 31 2007 12:16 AM (+rSRq)
2
Both Ace and the Jawas are already running an early version of the Minx comment system, because MT comments folded up under the strain. The full version has a lot more features and so is slower, but it isn't enormously slower.
Here's the result from an Ace post with 295 comments on the old system:
Processing 0.13, elapsed 0.1542 seconds.
15 queries taking 0.0494 seconds, 304 records returned.
Page size 185 kb.
Powered by Minx 0.7 alpha.
Posted by: Pixy Misa at Saturday, March 31 2007 03:58 AM (PiXy!)
3
Did you ever puzzle out what was causing the input lag in high comment count posts? There have been a lot of 200+ posts over there lately, and the lag gets really noticable beyond that point.
Posted by: Will at Saturday, March 31 2007 11:38 AM (olS40)
4
...
Input lag?
If you entered something in New Comments Thingy, it wouldn't update the main page or the entry page, but it updates the New Comments Thingy page right away... Unless it still has caching enabled... Which would affect everyone but me, because it doesn't cache if you're logged in...
ops:
Posted by: Pixy Misa at Saturday, March 31 2007 12:08 PM (kdEVa)
5
Well I had noticed a problem with the comment count on the main page not updating (new posts show 0 comments for quite a while), but what I was actually referring to is a noticable lag between entering keystrokes and the letters appearing on the screen in the text box of the New Comments Thingy.
I've been watching the CPU Usage in the Task Manager while typing a comment on a couple threads over at AoSHQ, and it spikes when you begin typing a comment in a thread that already has about 150+ comments. If you just keep typing away furiously, none of the text will appear until after you've paused and given it time to catch up.
The more comments, the worse the problem gets. I don't know if it's a problem with the comments system or maybe IE (or other browsers) interacting with the comment system. Several people have remarked on it over at Ace's, so it can't be just me. Try his recent open thread and see if you observe the same thing happening.
Posted by: Will at Saturday, March 31 2007 04:43 PM (SOx9v)
6
Oh.
No, I don't get that at all. But I use Firefox. Let me try it in IE...
Gak!!! That's horrible! What the hell?!
I'll definitely look into that. But the editor itself works fine on IE, so I don't know why it would suddenly blow up on long threads. It shouldn't make any difference.
Posted by: Pixy Misa at Saturday, March 31 2007 04:55 PM (PiXy!)
7
Well, you're certainly right. It only seems to happen in IE, and only on longer threads. I even tried the "view page in IE" plugin I have installed in Firefox, and it worked just fine there.
Very weird indeed.
Posted by: Pixy Misa at Saturday, March 31 2007 05:06 PM (PiXy!)
Hide Comments
| Add Comment
Wednesday, March 28
Last Tags For Now
Simple, but neat:
[
me] Pixy Misa
[
you] you
[
you=du] du
[
me] picks up the author of the current post or comment. [
you] gets your username if you're logged in, or the name you used on your most recent comment if it's still retained by the session code, or the text specified, or if all else fails, "you".
Posted by: Pixy Misa at
10:48 PM
| Comments (16)
| Add Comment
| Trackbacks (Suck)
Post contains 52 words, total size 1 kb.
Posted by: Zim at Thursday, March 29 2007 09:49 AM (kdEVa)
2
Hmm. Tags no worky in recent comments section.
Posted by: Pixy Misa at Thursday, March 29 2007 09:52 AM (PiXy!)
3
Test comment changes...
Posted by: Pixy Misa at Thursday, March 29 2007 10:27 AM (PiXy!)
4
Did you get rid of the editing buttons?
Posted by: Steven Den Beste at Thursday, March 29 2007 12:07 PM (+rSRq)
5
No, I didn't. Hmm. I'm still seeing them in Firefox and IE7. Not in Opera though, which is a little odd.
Anyone else?
Posted by: Pixy Misa at Thursday, March 29 2007 12:22 PM (PiXy!)
6
It appears it was my fault. I have some rather rigorous filtration rules set up with Proxomitron to shut off various aspects of Javascript that are often abused, and one of them must have come into conflict with your editing stuff.
With Proxomitron disabled, the editing buttons are back.
By the way, I have to confess that I tried an experiment with my previous post. I wanted to see if you permitted me to put an "embed" statement in a comment, and it turns out that you didn't. Now that I'm using your full comment doohickey, I'm going to try it again and see what happens:
So the embed shows up on preview; let's see if it comes through after it's posted.
Posted by: Steven Den Beste at Thursday, March 29 2007 12:40 PM (+rSRq)
7
Ha! You're smarter than I am!
Posted by: Steven Den Beste at Thursday, March 29 2007 12:41 PM (+rSRq)
8
I have a full-bore SGML parser that unpacks comments, strips unwanted tags and attributes, balances unbalanced tags, and repacks everything. It runs dynamically every time a page is generated, and accounts for up to 70% of the page generation time.
On the other hand, it works.
Posted by: Pixy Misa at Thursday, March 29 2007 01:02 PM (PiXy!)
9
Impressive Pixy. Damned impressive
Posted by: me at Thursday, March 29 2007 01:42 PM (CglRh)
10
hmmm, did I forget the brackets?
Posted by: [me] at Thursday, March 29 2007 01:43 PM (CglRh)
11
Nope, that wasn't it... I'll learn this somehow and Steven is right, YOU are smarter 'n me!
Posted by: GM Roper at Thursday, March 29 2007 01:44 PM (CglRh)
12
You can only put it in the body of the comment, not in the name field.
Posted by: Pixy Misa at Thursday, March 29 2007 01:56 PM (PiXy!)
13
Okay my eyes are crossing. I've been silly enough to volunteer to do some web stuff for a group I belong to. I was simply going to help the webmaster... but as soon as I volunteered, he said "gee thanks now I can get out of this". I've been looking at html and php for the last week... I haven't done any dynamic coding before this - so I must say, I am very very impressed with everything you've done.
Now to check out the taggies and see what happens...
Teresa
you
Posted by: Teresa at Thursday, March 29 2007 02:36 PM (gsbs5)
14
Day-UM, you would think I would have KNOWN that.
GM Roper
Posted by: GM Roper at Thursday, March 29 2007 04:20 PM (CglRh)
15
Pete Zaitcev has one question. What is the practical application of this feature? Pete Zaitcev also laments the lack of a "preview" button.
Posted by: Pete Zaitcev at Friday, March 30 2007 04:25 PM (9imyF)
16
OK. I see what's going on. It's a plot to get us talking in anime language. "Aoi would not mind to share the futon with Kaoru-sama". Cute.
Posted by: Pete Zaitcev at Friday, March 30 2007 04:27 PM (9imyF)
Hide Comments
| Add Comment
Eeeevil!
Windows Update just croaked both my desktop and my notebook. I've spent the past hour in the Windows XP Repair thingy.
That little yellow blippy can sit there forever as far as I'm concerned. In fact, hey, c'mere. Automatic Updates
Off. Little red blippy
Always Hide.
Much better.
Posted by: Pixy Misa at
03:43 PM
| Comments (8)
| Add Comment
| Trackbacks (Suck)
Post contains 49 words, total size 1 kb.
1
Automatic Update is truly evil. I have never turned it on.
It's possible to make that little reminder go away. Originally I figured out the program that was doing it and deleted the program (and then went into the OS backup directory and deleted it there, too, so that it didn't automatically get restored) but later I found a place where you could tell Windows to stop bugging you. Alas, I don't remember the details now, but I think that the latter was a setting buried in the "Security Center" control section for auto-update.
Posted by: Steven Den Beste at Thursday, March 29 2007 04:18 AM (+rSRq)
2
Sorry for a little test.
This is a separate line.
This is also a separate line, with a blank line just above it.
I think I'm going to lose my linebreaks when this comment is posted.
Posted by: Steven Den Beste at Thursday, March 29 2007 04:19 AM (+rSRq)
3
I don't know if it's your fault or my fault, but I no longer see any formatting controls for comment entry, and my line breaks are all getting eaten.
Let's see what happens to the two "br" tags I just put in above this line.
Posted by: Steven Den Beste at Thursday, March 29 2007 04:21 AM (+rSRq)
4
Hmmm... the comment I left ("Yes, Security Center is where it's at... I turned mine off 5 minutes after turning on my new computer. Dialup and all that. Blah blah blah") seems to have disappeared.
Something I said?
Posted by: Wonderduck at Thursday, March 29 2007 06:08 PM (fQiSx)
5
Um. Don't know. I was messing around with the comment system, but I don't know if the times coincide.
Posted by: Pixy Misa at Thursday, March 29 2007 08:18 PM (PiXy!)
6
Would have been around 930am central time, which would have been, let's see... (the F1 race was at 1pm Sunday your time, and 10pm our time on Saturday, so that would make it... 13 hours, more or less, so...) 1030pm your time? Give or take.
There were actually two comments, one here, one in the 2006 anime conversation, both poofed.
Ah well.
Posted by: Wonderduck at Friday, March 30 2007 01:04 AM (135bi)
7
That was about when I was messing with the comments. It was only down briefly, so I guess you were just unlucky.
Posted by: Pixy Misa at Friday, March 30 2007 01:24 AM (+7YmF)
8
Bad timing, indeed. Oh well. Lost the greatest line ever, too: "Pixy, I love you in the special way only a duck can love an evil magical girl, but I disagree with you."
Hey, there it is again!
Posted by: Wonderduck at Friday, March 30 2007 04:32 PM (fQiSx)
Hide Comments
| Add Comment
Haruhi-sama!
Steven wrote:Though it's good, it doesn't strike me as being that outstanding. I suspect that what I'm missing is context. What I suspect I'm missing is that the hooplah was from people who were comparing it to all the other shows that came out at the same time, and by comparison to the normal run-of-the-dreck series from the last year, it really did seem like a lightning strike.
Context is key, in two ways.
First, as Steven says, 2006 was a pretty blah year for anime, and
Haruhi is a good show, with a solid story, strong cast, and high production values.
But second, and specific to
Haruhi Suzumiya, is the effect of the re-ordering of the episodes. It's effective when you watch the episodes one after the other, but it's crazy-making when you watch them a week apart.
BBCode update one for the morning: You can now add links to the attribution in [
quote] tags. Just separate the author name and the link with a pipe character, |. So in this case, the code was [
quote="Steven|http://denbeste.nu"], producing
Steven wrote:
Posted by: Pixy Misa at
09:17 AM
| Comments (5)
| Add Comment
| Trackbacks (Suck)
Post contains 176 words, total size 1 kb.
1
How is 2006 a blah year, with Zero No Tsukaima? Siesta's melonpan would make honors to any year. ^_^
Posted by: Pete Zaitcev at Wednesday, March 28 2007 11:22 PM (9imyF)
2
I'm not that big a fan of
Zero no Tsukaima.
Shakugan no Shana, though, while we're on the subject of melon-pan.
Okay, so two really good series in 2006. What else am I forgetting? (And don't say Kanon!!!)
Posted by: Pixy Misa at Thursday, March 29 2007 12:20 AM (kdEVa)
3
I haven't seen either (I know, everybody can turn up their nose at me now).
However, I can attest that getting into an ongoing series or serial of
any nature can at times be a completely different experience than
shotgunning it after the fact. I've seen or read things that had
me by the edge of my seat at the time, yet just weren't as powerful
when I went back to them after they had been completed. There's
just something about not knowing what's going to happen next, waiting
days on end to find out. Your brain entertains itself by
imagining possibilities, wargaming scenarios. That's a lot of fun
by itself, and those who went through the experience will likely
cherish that as much as, if not more than, the original content.
Posted by: Big D at Thursday, March 29 2007 12:39 AM (2wI5S)
4
"Okay, so two really good series in 2006. What else am I forgetting?"
Death Note.
Ouran High School Host Club.
Welcome To The NHK!
Nodame Cantible (though, really, it debuted in early January, 2007).
Kanon 2006.
Simoun.
Aria the Natural.
...and that's just off the top of my head, not even including Shana and Zero (neither of which did I watch).
I think the "2006 was a crappy year for anime" meme should be killed off immediately. Haruhi was arguably the best of a very good group, as opposed to "the diamond in a bucket of filth" as some are beginning to say.
This list doesn't even include Otome wa... , Nana, Strawberry Panic, or Hellsing Ultimate, all of which were popular, though not what anybody would call classics.
Context may be everything, but claiming that Haruhi was the only shining spot in a blah year is just wrong.
Posted by: Wonderduck at Thursday, March 29 2007 03:20 AM (135bi)
5
Death Note.
Haven't seen it; it certainly has its fans.
Ouran High School Host Club.
Watched five or six episodes. Hated it.
Welcome To The NHK!
Watched six or seven episodes. Hated it.
Nodame Cantible
Will give this one a try.
Kanon 2006
BLARGH!Simoun
Watched the first episode; felt no great desire to watch the second.
Aria the Natural
I quite liked Aria the Animation, but haven't finished it, so I haven't watched Aria the Natural yet.
Context may be everything, but claiming that Haruhi was the only shining spot in a blah year is just wrong.
I'm not quite saying that. I'm saying that
Haruhi was
a shining spot in a mostly blah year.
Posted by: Pixy Misa at Thursday, March 29 2007 04:10 AM (PiXy!)
Hide Comments
| Add Comment
Return Of The Sticky
So that's why my honeypot wasn't catching any flies. I hadn't properly updated the code, and it was still expecting the Page object to be a global - which hasn't been true since the Great Rewrite back in January.
Without the Page object, it didn't have access to... well, much of anything, really. Including the database. So it never actually created any records.
Let's see what it does now...
Hmm. Still empty, but it hasn't been fixed very long.
Guess I should pretend to be a spammer and actually test it.
Posted by: Pixy Misa at
12:45 AM
| Comments (5)
| Add Comment
| Trackbacks (Suck)
Post contains 95 words, total size 1 kb.
1
Let's see now.
Yep, banned myself nicely.
Posted by: Pixy Misa at Wednesday, March 28 2007 12:00 PM (PiXy!)
2
Okay, updated the standard form (and made a mess the first time), so let's see if comments still work.
Posted by: Pixy Misa at Wednesday, March 28 2007 12:06 PM (PiXy!)
3
One time I stumbled onto J Greely's honeypot by accident and had to send him email to ask to be unbanned. When you said you were going to test your own honeypot I was worried for a moment that you might find yourself completely locked out of your development system.
Posted by: Steven Den Beste at Wednesday, March 28 2007 04:51 PM (+rSRq)
4
Usually you only do that once, and then you whitelist one IP address to make sure you can get back in and undo it. I was very careful to set mine up this way, since the machine was 75 miles away and didn't have a remote console. :-)
In this case, he's probably only blacklisting at the application level, not changing his firewall config to drop all packets the way I do when someone visits the /banmyipaddress/ URL on my site.
-j
Posted by: J Greely at Wednesday, March 28 2007 07:16 PM (9Nz6c)
5
Yep. I'd be pretty hesitant about auto-firewalling anyone given the number of sites hosted on this server.
Posted by: Pixy Misa at Wednesday, March 28 2007 07:49 PM (PiXy!)
Hide Comments
| Add Comment
90kb generated in CPU 0.0418, elapsed 0.2909 seconds.
58 queries taking 0.2579 seconds, 425 records returned.
Powered by Minx 1.1.6c-pink.