Thursday, 30 September 2010

Junk food update

Just the junk food photos that have accumulated on my camera recently.

I went into City Shop with the idea of buying some Cadbury chocolate. They didn't have any, but they did have a range of interesting Milka flavours. This was probably for the best, as Cadbury has unfortunately come to favour lower production costs over actually making a product worth eating. Ever since the debacle where they moved production of their Chocolate to Australia, and decreased the actual.. chocolate in their chocolate replacing it with palm oil or some similar thing, I cannot muster the interest to buy their "chocolate".

Anyway, yogurt chocolate. It just sounds right. I think this was ~21 RMB.

2010-09-17 - Shanghai - Junk Food - 01 - Milka Jogurt chocolate


And it looks pretty promising. Unfortunately, the flavour is somewhat nondescript. I expect a yogurt product to be tangy and more yogurty. But I guess when you approximate it as a chocolate bar filling, you can only get so close. Still, it was worth trying and I wouldn't say I wouldn't buy it again.

2010-09-17 - Shanghai - Junk Food - 02 - Milka Jogurt chocolate


One thing I used to buy, everytime I flew back home for Xmas was Daim candies. You couldn't buy them there. So Daim flavoured chocolate seems like a natural thing to do. I think this was also ~21 RMB.

2010-09-17 - Shanghai - Junk Food - 03 - Milka Daim chocolate


But really, if you can actually buy Daim candies, I don't know why you would buy this. Daim candies are simply more "Daimy" than this hybrid product. But still, lacking ability to source the candies, this is a reasonably priced simulacrum.

2010-09-17 - Shanghai - Junk Food - 04 - Milka Daim chocolate


I felt like something chocolatey. So I chose this, as it was relatively reasonably priced at ~12 RMB if I recall correctly.

2010-09-24 - Shanghai - Junk Food - 01 - Oreo wafers


The flavour and sensation of eating these, was simply that of eating some cocoa flavoured factory product. There was no pleasure in the act, and doing so made me think of some factory floor where they pressed these out of some slop.

2010-09-24 - Shanghai - Junk Food - 02 - Oreo wafers


I am heading back to City Shop tomorrow, so I'll try and limit myself to one block of Milka. Assuming there are flavours I have not tried yet.

Reading from non-blocking sockets

Until recently, I had never actually used my Stackless socket module for anything other than my own hobbyist projects. These are done out purely of interest, and the limited networking traffic they receive is solely me testing them. I had also never received any complaints about the throughput of the module. So it was a complete surprise to me when I learnt that I was doing non-blocking IO incorrectly with Python's socket module.

I had always assumed that when a call to select indicated there was data to be read, this meant that it was okay to do a recv call. And for my purposes, this appeared to work fine. But when you are polling select thirty times a second, and the packet sizes that are received are consistently around 16 KB, that limits the throughput to 280 KB/s. For instance, an application on an embedded device might be fetching 115 MB in updates. This would take 4 minutes.

It turns out that when select indicates there is data waiting to be read on a socket, you can call recv until EWOULDBLOCK is raised. Who knew? Probably someone who had read appropriate documentation, this document seems to be pretty pertinent.

With the above implemented, the current implementation reads the 115 MB in 13 seconds. And that is with it limiting the number of recv calls within each poll of asyncore, in order to yield in a timely fashion to the application that is pumping it.