Archive for the 'Computing' Category

May 4, 2006

The joys of tags

Well, inspired by WB and with little else to do, I decided to look into tags and how best to implement them on my blog. Boy, was that a mistake.

There’s three basic schemas that one can use; non–normalized (the MySQLicious solution) which uses fulltext, the sort–of–normalized and the fully (3NF) normalized. There are problems with each, but in the end I opted for the latter choice. The only major obstacle to overcome was efficiently displaying a list of tags for each entry. Clearly I didn’t want to have to run a query for each individual entry since that would be hidously inefficient.

So after much googling and beating my head against a wall, I came up with an idea. MySQL’s GROUP_CONCAT function is extremely useful, so I used a subquery to get all of the tags for that news entry and GROUP_CONCAT them all together. It’s not pretty, but it works and it seems to be okay–ish. I know subqueries aren’t particularly efficient, but this seems to be the best way that I can think of without doing something completely radical (for instance, dumping the RDBMS system altogether).

Anyway, that’s kept me up until now (3:17am). The rest of the stuff is coming together nicely. Getting load times of between 0.1 and 0.01 seconds on my lowly laptop, so I’m hopeful that this will be a lot more efficient than my last incarnation. Once I’ve got the basic foundations laid, I’ll be setting up the user system and hoping things work nicely. Themes are also getting there, but there’s a lot more to do.

If only I could put this much effort into doing something useful – like revision. Oh well.

3:19 am | Posted in Computing, PHP/MySQL, Warwick Blogs | No Comments »

May 3, 2006

Definately getting there

Over the past few days I’ve been trying to procrastinate as much as is humanly possible – for example, playing GTA: San Andreas for very large periods of time. However, last night I turned my attention to the website backend that I’ve been developing, and so far the results have been promising.

Basically, the entire concept revolves around a single “site” object, which is set up by a global include script. The constructor sets up the smarty templating, a PDO object and starts PHP sessions. It also checks for login requests and the like. Then, when the page is loaded it simply registers itself with the site object (so it can do some pretty GUI things and also track the user through the pages) and then gets on with the business of doing useful things.

Since PHP5 (finally) supports destructors, it then grabs the page content from the output buffer, slaps it all into a smarty template automagically and then outputs without the script page ever having to do a single thing. Also, error handling can be done really easily – an exception handler catches any PDO errors and, if the site–>error() function is called, it sets an error flag and exits. On exit, the destructor is called and it can do the appropriate stuff.

One final thing I want to do is create a PDO proxy object which will catch and log the queries sent to the database for statistics information. The pseudo–function __call is very useful in this respect.

On the Ubuntu side of things, I’ve finally got it all set up the way I want it. Took me ages to sort out the supposedly simple keyboard layout problem, but in the end I just edited the xorg.conf file manually instead of messing around. And, to be honest, I’m very pleased with the outcome. I don’t have to bother messing around with lots of stuff, and now I even have mplayerplugin working correctly. Amazing. Still have to sort out hibernation, but I think that’s a problem with my grub.conf and 915resolution.

I’m also taking the liberty of upgrading software on my server, and getting it all working properly. It’s currently on the 2.6.12 kernel and has an uptime of 158 days (which I’m very proud of), but I’m afraid that it really needs an update. God only knows how many security holes have been found now, so I’ll probably update that tonight and reboot it when I get home. Also decided that enough is enough, and completely removed X support – it’s really not needed at all on a server.

Looking to the future, I’m planning on replacing the role of my home server by my current desktop machine. Ideally I want my home server to be a small box which only deals with router requests and has no other processes running, purely for security reasons. I’m planning on replacing my desktop at the end of next year, although depending on my financial situation, I may decide to replace it in October.

On the hardware front I’ll definately be going for some kind of dual–core Athlon, but I’m not sure which yet. To be honest, I would absolutely love a dual 7800GTX SLi machine – just for kicks – but that might be a little pricey. It’s basically going to come down to what I can afford. Hopefully the price of hard–drives will have come down dramatically, and I’d like to re–use the drives in my current machine for the new one and have some kind of home–network hard–drive option on the server. We’ll just have to wait and see what happens, I suppose.

2:41 pm | Posted in Hardware, Linux, Randomness, Warwick Blogs | No Comments »

April 29, 2006

Compiz Prettyness

Well, it’s quite amazing that I’m actually writing two entries in one day, but what the heck – it’s for a good reason.

I decided that instead of trying (and probably failing) to get Xgl working with my i915 driver, I’d give AIGLX a shot instead. There was a nice howto and repository on the Ubuntu forums which I followed, and that got it all set up in a matter of minutes. I’m now quite pleased to say that everything’s up and running and working much better than I ever expected.

cube/rotate work extremely well, and the transparency effect when opening/closing windows is very nice. Minimize also works really effectively, but unfortunately the switcher is broken for the time being (alt–tab works, but I can’t seem to get out of it – maybe I’m just being dumb). miniwin is also broken, but the other plugins work great. wobbly is fun for a while, but not really of much use other than for nice eye–candy.

The only downside is that resizing windows is quite slow at the moment. Hopefully with successive releases this will improve, but for the time being I’m definately keeping this enabled. It’s really great to see something that’s truly revolutionary. I just wish that we’d moved over to xorg a long time ago, instead of keeping the XFree behemoth alive.

2:38 pm | Posted in Linux, Warwick Blogs | No Comments »

First Impressions

Well, first impressions are really very good. Considering that I installed from an alpha version of the LiveCD, installation went very smoothly. Managed to reformat using the inbuilt GParted widget and get to the very end of the installation process before grub didn’t want to install. Luckily I have quite a lot of experience with grub due to Gentoo installs, so that was easily rectified.

Ubuntu has, amazingly enough, managed to auto–detect pretty much everything. Even ACPI sleep works – something I never got working under Gentoo. Need to sort out hibernation but that’s probably not going to get used that much. Right now I’m running a dist–upgrade, and then its time to try out AIGLX and Compiz for some nice prettyness.

Anyway, time to transfer some documents back over and get the laptop set up.

1:05 pm | Posted in Linux, Warwick Blogs | No Comments »

April 28, 2006

Taking the plunge

Well, after having wasted about three hours trying to fix an obscure Gentoo–related wireless problem, I’ve come to the conclusion that it’s probably time that I tried another distribution for the first time in two years. Gentoo is an amazing distribution, and I really do love working with it. But when you’re trying to get work done, and you can’t because of some silly little problem, it does get quite annoying. Equally annoying is when emerging a package that subsequently breaks everything.

So, I’m going to back up my documents tonight, make a ghost image of my Gentoo partition and install Ubuntu (Flight 6). I’m actually really looking forward to trying out Gnome 2.14 properly, and I might even give Xgl a go if I can get it working nicely with the Intel drivers.

Currently downloading the LiveCD which I intend to try out for a while, and then use the brand–spanking new installer to (hopefully) install without wiping my entire drive.

It’ll be a shame to lose Gentoo after all of these years but it’s getting to the point where I just need something that works out of the box – to a certain degree – without me spending half my time editing configuration files. I shall definately be keeping it on my server boxes, but I think that Ubuntu is definately the way to go on my laptop.

Well, that’s my evening sorted out.

9:02 pm | Posted in Linux, Warwick Blogs | No Comments »

April 19, 2006

First exam… done

So the first exam, Topics in Mathematical Biology, is all out of the way and done. My impressions were that it was fairly similar to the last two years’ worth of past papers, and having done those and the question sheets, it made it slightly easier. However, I couldn’t help but feel that the questions themselves were quite bulky. I found there was an awful lot to do for each question – especially the first, which took me about 45 minutes!

I attempted questions 1–3 and 5. I only answered question 1 in its entirety due to immense time constraints, but I got the vast majority of the work done. For the most part it seemed fairly correct. Unfortuantely I couldn’t quite remember how the very end of the singular pertubation question was supposed to work, so even though I’d got down to the inner and outer solutions, I couldn’t match them up properly to get the composite which was annoying. However, I gave it a decent shot so we’ll see what happens.

Question 3 was actually quite interesting and I very much enjoyed it. I did manage to complete all of the parts barr the very last bit, for which I basically scrawled something down when we were told to put our pens down. Managed to get the same answers as the question, so that’s got to count for something.

Didn’t attempt question 4 since I know next to nothing about lambda-omega wavetrains, so sat down and did question 5. Didn’t do the initial 3-mark starter question as I meant to come back to it later but again, didn’t get around to it which was a bit annoying. Got through most of it with ease, but unfortunately discovered a mistake in the very last part which means that I’m going to have lost a couple of marks.

However, it’s all over and done with, and I’m fairly pleased with what I’ve written. I can’t account for moderation and stupid errors on my part, but I guess that 70% isn’t an outrageous estimate. I’d be very pleased with that, considering I only actually went to one of the lectures for the entire course.

Next exam is on Friday morning, and it’s Introduction to Topology. I’m actually really looking forward to that since it’s one of my favourite lecture courses of all time. Unfortunately I also have Combinatorics immediately afterwards, so tonight will be spent completing the very last topology paper, and tomorrow I’ll mostly do Combinatorics.

So, we’ll see how the both of those go. Will hopefully update the blog afterwards, but that depends on how much time it’s going to take since the dreaded Measure Theory is on Monday morning. Eek.

8:31 pm | Posted in Exams, Linux, Maths, Warwick Blogs | No Comments »

April 17, 2006

Updating the Website

Well, I’ve still not totally decided what I’m going to do with this blog and my website, but I do know that I definately want somewhere to put up all of my code and personal stuff. So, starting from when the exams finish, I’m planning on doing a couple of things.

Firstly, I’m re-writing the site from the ground up. The code there at the moment is hideously inefficient for my liking, and I want to give cool things like PDO’s a good try-out. I’m also (probably) going to move my domain over to the home server since I really don’t use all that much bandwidth these days. Not 100% sure about that one yet, but we’ll see when I get around to it.

I’m going to clean up the layout and try and make it look “swish” – or something. As for the blog, I’m still undecided. I like the community here, but I do like having everything under my control and, more importantly, in one place. We shall see…

3:32 am | Posted in Site Development | No Comments »

April 16, 2006

GNOME Trials

I’ve recently become somewhat disillusioned with the annoyances of getting Qt and GStreamer to play nicely, so I thought I’d give Gnome a go. So, I spent a couple of hours emerging the source and getting to know it, and I have to say that I was quite impressed. I spent quite a lot of time trying out little bits here and there, and Nautilus is extremely nippy when compared to Konqueror.

However, after having used it for a few days I’m switching back to KDE. Why? There are certain things that I love doing in KDE that I simply can’t do in pretty much every other OS out there. For example, I can open Konqueror, browse the web for a bit and then open a new tab for browsing the local network, or perhaps transfer a couple of files by FTP. KDE seems a lot more tightly-knit, and for some reason I just couldn’t get along with Firefox.

Perhaps I’m just too picky, but I love the KDE interface. I think it’s one of the most elegant out there, and with a decent font (Bitstream Vera or, in my case, Luxi Mono) it just looks great.

So for now, back to KDE. I’ll probably have to give XFCE another go at some point though.

1:40 am | Posted in Computing, Linux, Warwick Blogs | 2 Comments » | Show comments »

April 12, 2006

Past Exams and More Programming

Well my brain is thoroughly fried; just completed the 2002–2003 past exam papers for Combinatorics and Topology, and now I can barely concentrate so I’m going to take a large break and try not to think about how much I’m going to screw up Measure Theory. Anyway, thought I’d post another entry and see if I can get myself on a roll. Like that’s going to happen.

So, last night I mainly concentrated on getting this homemade YUV overlay built, and it seems to have worked nicely. The problem wasn’t Mesa, more the fact that I was generating 5 textures/frame, and telling OpenGL to overlay them in a very inefficient way. After spending some time reading up on Cg shaders, I created a basic fragment shader that did the job super quickly with only three textures. So I’m happy.

The other topic on my programming agenda is the blog. I really want to get going on my own website, and the blog is quite an integral part of that. I’m quite picky when it comes to having multiple copies of things, and I don’t like the idea of all of my original blog entries being separate from the blog entries here. So I’m going to have to come up with some way of keeping a central store of blog entries and comments, somehow. I was thinking that I might use a cronjob’d php script to grab entries and comments via RSS or similar, then update the database accordingly. But again, there are problems to this approach – what happens when I get a load of entires on here?

Bah, I’ll have to thnk of something. But besides that, I’ve been playing around with PHP’s PDO objects and they’re very cool. I’ll never have to worry about manually escaping my SQL data again. I’ve created a basic abstraction layer for some common functions, but I’m sitting here wondering whether it’s really worth it. Right now, I’m thinking “probably not”.

So those are the things going on at the moment. I should probably be revising, but I’m sick to death of it by this stage in time. Can’t wait until next year – the more 100% assessed modules, the better.

4:59 pm | Posted in Computing, Maths, Revision, Warwick Blogs | 2 Comments » | Show comments »

April 11, 2006

Damned Revision

Well, it’s been a whole load of time since I posted, mainly due to revision and lazyness on my part. So I thought I’d post a quick update on what I’m doing – not that anyone will be all too interested.

So I’m back in Walsall after spending a week down at Sarah’s. Unfortunately, things haven’t been brilliant on the revision front. Whilst I’m mildly optimistic about Combinatorics, Introduction to Topology and to a lesser extent Topics in Mathematical Biology, I know that Measure Theory is going to be awful. I’ve not done a lot of work for it, and to be honest, I just don’t understand a lot of the material.

However, on the upside, I’ve finished all of my Topology and Topics exercise sheets, which is something that has never been done before. I’m now at the stage where, a week before the dreaded exams, I’m getting my act together and doing three past exam papers a day. So maybe there’s hope yet; we shall see, I suppose. I figure that even if Measure Theory goes badly, I can still pull it up with some better marks from the other modules.

However, I didn’t really want to talk about exams so I’ll talk about something equally as boring – programming. Been playing around quite a bit with two things over the holidays. Firstly – and this has been on the agenda for some time now – coding an OpenGL GStreamer application to map video onto a cube or some other random object. Surprisingly, this was initially very easy, once I’d found out how to actually get the contents of the GStreamer buffer into my program.

Basically I use decodebin to get the video playback working, and then pipe it through ffmpegcolorspace to get a nice RGB texture. Then, I use fakesink and a handoff function to actually generate the texture to screen and map it onto a cube. The hardest bit was actually finding out about the handoff function – it’s buried deep inside the GStreamer Plugin Guide, which is quite annoying. However, it does look quite cool. You can even take a look at it for yourself if you’d like.

Even so, I wasn’t quite satisfied. The biggest speed hump is the ffmpegcolorspace conversion, as generically most video files use some kind of YUV format to store video frames. Typically, and somewhat ashamingly, there’s no general way of dealing with YUV textures in OpenGL – all of the extensions out there generally suck, and don’t work for different versions. Plus, none of them cope with 4:2:0 planar YUV, only 4:2:2 pixel-packed for the most part. So some form of conversion to RGB is required, and a significant amount of CPU overhead is incurred in the process.

For the last couple of weeks I’ve been looking at various ways of efficiently using the GPU to do this conversion for me. Colour matrices were the first option I looked at. Basically, given some texture, one can use a colour matrix to remap colours in any given format. However, the major problem is going from 4:2:0 planar to 4:4:4 pixel packed, and that itself incurs quite a significant overhead.

Blending textures is possibly the best way of doing this. Basically, one generates 5 different textures along with using a simple colour-lookup table. Firstly, we lay down the Y channel as a luminance channel. Then the additive U, then subtractive U, and the same for V. In effect, just layering one channel on top of another to simulate the YUV->RGB conversion in the GPU.

However, there are again problems with this. The naive approach is to redraw texture upon texture, which means that every pixel needs to be redrawn 5 times every frame – at 25fps, that’s 125 times/second! In order to get the most out of the GPU, I used the ARB_multitexture extension, which allows you to layer textures extremely quickly in one pass. I also delved into the world of shaders to try and work out whether it might even be worth usnig only 3 textures and doing the RGB conversion through a simple ARB fragment program. This is something I’m still looking into.

Unfortunately, although this actually works and I’ve tested it, it’s still very very slow. However, I’m using quite a crap Intel 915GM based GPU under Linux. The i915 driver is not particularly good at the moment, and upgrading to Mesa 6.5 seems to have made matters even worse. glxgears is showing only 600fps – I should be getting at least 1300 according to other guys with the same card. So I’m guessing – and hoping – that the problem lies with the drivers and not my card. When I get back, I’m going to check it out on my Radeon 9800 and we’ll see how that copes.

Anyway, that’s probably enough for now. I’m going to reboot and see if I can get this all working nicely.

10:00 pm | Posted in GStreamer, Linux, Maths, Revision, Warwick Blogs | 3 Comments » | Show comments »