kaejax demoed

Okay – based on the ideas that I described earlier, I now have a working demo.

The problem as described, is that AJAX is not very good at coping with massive numbers of small function calls – the http requests gum up the networks.

The solution was to try to aggregate all the small calls into single http requests, run all the function requests on the server, and return the results as a single array.

Here are my results:

old non-aggregated version New KaeJAX Whiter-Than-White brand
demo demo
output:

loading… please wait
test1 completed in 10559 milliseconds
test2 completed in 20694 milliseconds
test3 completed in 32109 milliseconds
test4 completed in 43278 milliseconds

output:

loading… please wait
test1 completed in 1101 milliseconds
test2 completed in 1184 milliseconds
test3 completed in 1292 milliseconds
test4 completed in 1530 milliseconds

tamperdata screenshot

hah! i don’t think so – it was well too large to even bother replicating

.

tamperdata screenshot
tamperdata-after.png
source code source code

Judge for yourself.

kaejax

I’ve been using Sajax for quite a while, and hacked it in several ways to match my needs. However, there is one problem that it has which I can’t get around simply; massive parallel requests. If there is 100 ajax requests that need results, Sajax creates 100 separate http requests. This can slow things down immensely.

demo

In the demo, I’ve initiated 4 loops, each of which makes 100 requests. It took me 51140ms for the requests to complete. My goal is to bring that down to less than 500ms.

I have not created the solution yet. Just wanted to show the problem while I work on it.

The specification that I’ve settled on is:

  • should work similar to Sajax. ie; server functions are called with “x_functionBlah(var1,var2,callbackFunction);”
  • variables are transferred using JSON
  • allow server-side functions to be defined from completely separate URLs
  • delay sending the requests, in order to collect multiple requests to the same URL and send them all as one.

I figure this would massively improve any AJAX application which uses multiple parallel requests.

Unfortunately, Sajax is just not suited for handling this, so I will need to write my script from scratch. Gosh – my own AJAX framework.

I’ve already dubbed the new framework “KaeJAX”, because I’m vain and like bandwagons.

I will hopefully have a working example later today.

good philosophy book

Great book, this. Philosophy, The Basics, by Nigel Warburton

A lot of problems are described very simply, without recourse to huge multisyllabic words like “multisyllabic”.

As an atheist, I enjoyed the discussions on the various proofs that there is indeed a god. No conclusions were given, other than that there is more discussion needed.

I’ve just finished reading up on ethics, and am only slightly disappointed to find that there are indeed no hard and fast rules for how to live your life (unless you are religious, in which case “good” means “what god says”). Some ethic theories (utilitarianism, virtue theory, Kantian ethics, etc) were discussed, along with some example problems and how they might be solved with the various systems.

Based on the above, I think I may follow something like “negative utilitarianism”, whereby the goal of any action is to minimise suffering.

Now that I think of it, that could even explain my vegetarianism – I don’t kill and eat cows, because it would cause the cows pain, and I don’t suffer by eating potatoes instead.

How that allows me to come to work in suede shoes, and leather trousers, is beyond me – but hell, I’m not a consistent person!

The book is aimed at people who don’t study philosophy in-depth, but want an overview of it. That aim has been achieved. Everything is explained clearly and concisely.

Of course, not everything is explained – after reading certain sections, I had some questions that were not answered, but the book supplies “further reading” lists at the end of each chapter.

general stuff

workin’ nine to five

I’ve switched to a more “normal” 9-5 work routine, instead of the usual 7:30-4 routine I had before. I guess that leaving at 4pm makes me look like a slacker maybe.

I have no idea why so many people work a 9-5 shift. I mean, when I walk to/from work at 6:30am or 4pm, there is no fanfare – I get to /enjoy/ my walk and think about things as I walk.

If I leave at 8am/5pm, though, I can’t think clearly, as I am surrounded by cars and people.

I think it’s quite funny really, to see people navigate through towns in cars. An example in case: my boss gave me a lift part of the way home. I got out in Monaghan town. He asked me to post some letters while I was there. It took about ten minutes to go to the post office, post the letters, then walk along my route until I got to the cross-roads by Dunnes Stores, where I overtook my boss who was still driving through town. Hilarious!

kfm

On the KFM side of things, I’ve slowed down substantially, as my daughter demands quite a bit of time (I got home yesterday – me: “hi”, Jareth: “mm!”, Boann: “wah!”, Brownyn: “here you go. take her”).

I’m working on a small problem at the moment, which I’m taking my time over. The problem is that “:hover”, the CSS selector which allows you to style the element that the mouse is over, does nothing if the mouse is dragging when it enters the element.

The obvious and computationally expensive solution is to check each element whenever the mouse moves, to see if the mouse has entered it.

I’m mentally constructing a more efficient method, but it will take a little time to come out of my head (I’m not concentrating on it fully – got other stuff to do).

What I have so far, though, is:

  • action: mouse moves, calls function getContainer(mouse_position, elements_to _check, clear_afterwards)
    • get cached array of elements to check
    • if no cache exists, create it, populating it with every element that needs checking
    • check through list of elements to see if mouse is contained in them. if so:
      • if clear_afterwards is set, clear the cache
      • return the element
    • if the number of elements is greater than 2, try to group elements that are in the same area together in an object (this bit is tricky) and edit the cache accordingly
    • return null

The part that I’m mulling over is the bit marked “this bit is tricky”.

The idea is that if you have four objects with positions and widths, a[0,0,1,1], b[4,0,1,1], c[0,1,1,1], d[4,4,1,1], the element check could be reduced a bit by creating new container objects e, f containing the first four, geographically segregated: e[0,0,1,2,contains:a,c], f[4,0,1,5,contains:b,d]

With the above, the position check would be vastly quicker, when huge numbers of elements are checked, especially if the segregation is recursive; ie, each container object contains sub-containers, etc, until no container contains more than two objects/elements.

I think you can see why I think this is tricky 😉 writing the position-checking algorithm is very simple, but deciding how which elements get segregated from which others is complex.

Maybe this has been solved before by other people? I don’t know. I’ll check my Bumper Book Of Algorithms when I get home.

other stuff

em… dunno

oh – here’s one: why is it that you get a voltage difference when you measure both sides of the same battery, but not if you measure the plus of one battery versus the negative of another? In other words, if one side of the battery is like a tower of water, and the other is like an empty hole, then why do the electrons prefer one hole over the other?

nyeh, I say. nyeh.

back to work

I’m sitting in the office after a two week’s (it was only two weeks??) paternity leave to get the new arrival suitably acclimatised to this world.

At least, that’s the official word. We fathers all know, though, that paternity leave is about taking the brunt of the kid’s frontal assault on this domain, while the mother learns not to vent her anger every time the sprog demands feeding.

I hope the house is still standing when I get back.

I’ve learned yet again how useless a father feels for the first few weeks. Even though I spent 48 hours a day taking care of the kid, and the mother, and the kid’s brother, that somehow did not seem to be enough.

Bronwyn is a very stubborn girl, which makes some things difficult for people that need to live around her.

For example, she insists that Boann will be breastfed, as Jareth was, despite the experience that she gained from Jareth.

For me, that means holding a screaming hungry child with no way of satisfying it, whenever Bronwyn is too busy (or just not interested enough) to feed her. That can be very stressful. Especially at 3am. Especially when Jareth is also screaming for attention. Especially at 3am.

I’ve been up since 4am, which is when Jareth got me out of bed. I don’t mind that. At least I’m out of the house for a while, even if my nose is bunged up and my fingers are freezing.

Right – finally, I can get some work done without having to stop every five minutes to “hold the baby” (that’s what baby chairs are for!).

/me starts building a list of stuff that needs taking care of.

KFM watchers, I hope to be back to normal working order later on, now that Boann’s first two weeks are finished.

 

I love them, really, but don’t tell them that.

f%&$in kids!!!

My daughter, Boann, light of my life and bringer of joy, just closed her eyes and shut her gob after a full night of kicking, screaming, pissing and vomiting – on me.

Do you know how piercing a baby’s scream is? It’s designed to make parents drop everything and attend to their immediate needs, no matter how much pain the mother is in (Bronwyn’s been lying curled up in agony for seven or eight hours for some reason) or how few hours of sleep and how few milk-producing nipples the father has.

Finally, she’s asleep. I can go to bed now.

But no! Jareth always wakes up on the dot at 6am, which is in 6 minutes.

Such is life…

I really need to bring up the subject of “the snip” with Bronwyn.

a lickle magic trick

not quite perfectly executed, but I think it’s good for an amateur:

a card trick

I’m not going to tell you how it’s done – it’s much more satisfying if you figure it out yourself.

clue: not a camera trick, and no, there is no gimmick card in this.

and… it’s a kfm!

I’ve just released KFM 0.5.

New features:

# New Languages
    * French (thanks to Hubert Garrido)
    * Spanish, thanks to Arathael
    * Dutch (thanks to Roy Lubbers)
# selected file can be changed using the left/right arrow keys
# you can edit plain-text files online
# caption-extraction from JPG files
# total rebuild of the directory panel
# recursive context-menus.

Looking at the above, I am suddenly reminded that I speak Irish… next release will have a ga.js language file, I promise.

I had a visit from my bosses yesterday. They came to see my other baby, Boann, who was born last week (and I still haven’t uploaded the relevant photos!), but I couldn’t resist showing off some of the new features.

They seemed to be excited about one of the new features – the ability to edit files online, instead of having to download them, edit them, then re-upload them – they said it would help solve one major irritant that a client/partner of ours has (oy, LiamRo – I know you’re reading this – excited?? this is just the beginning!). I’ve restricted it to plain text files for now, but will expand out to xml-based languages if no bugs rear their heads.

Well! Had a good chat with Janich Rasmussen, the most prolific bug-reporter on the KFM bug tracker, and maintainer of the Danish language file. It’s always good to speak one-to-one to other developers.

For any other people that want to chat with me about KFM, I can sometimes be caught in #kfm on irc.freenode.net.

Time for coffee, then I have a lot of 0.6 work to do!