Mischiefblog
I WATN 2 MAEK GAEM!

Tech

Cache eviction

Posted by Chris Jones
On July 25th, 2008 at 17:09

Permalink | Trackback | Links In |

Comments Off
Posted in Java, Tech

B: size of the buffer
K: number of items having distinct access probabilities

LRU eviction: O(KB)
FIFO eviction: O(K)

Unless it costs a lot more to load an object into the cache, FIFO eviction may make the most sense. In most LRU implementations I’ve written, the cost to maintain the “use” status of the cached object was more expensive than a cache miss because of the object had been evicted. Consider the cost of loading the object versus the SLA for the service. Also, if the cache objects retrieved tend to be clustered very strongly with few if any changes, the cached objects won’t be evicted from the cache very often. A FIFO strategy only loses in the case of a full cache where rarely used objects are occasionally inserted and frequently used objects are evicted and reloaded.


The JVM garbage collector is generally less efficient with larger heap sizes. Heaps over 1 GB with efficient garbage collection is possible if the JVM is properly tuned. Concurrent Mark and Sweep collector may be buggy in very large heaps–tiny JDK 6+ JVMs in federation worked okay. Cache growth should be limited (especially with hashmap caches). The number of long living objects is a problem moreso than the size of those objects, so consider serializing/deserializing the objects to byte arrays (the JVM is optimized around short-lived object garbage collection and the cost of young generation garbage collection is proportionally lower than older generation garbage collection).

Tuning JVM Garbage Collection JDK 5.0

JCS vs Ehcache metrics

Weekend update

Posted by Chris Jones
On March 10th, 2008 at 11:45

Permalink | Trackback | Links In |

Comments Off
Posted in Pets, Tech

I got my new laptop on Friday, an ASUS G1S-B1 from NewEgg. It was the best deal on the hardware that I could find, and it’s a strong performer, over five times faster (in terms of 3DMark 06) than my desktop. Lenovo wouldn’t have shipped a laptop to me until March 20, so it was worth going with such a consistently well-reviewed piece of hardware. I spent a lot of time playing Waffle in Warsong Gulch over the weekend. This week, I’ll be receiving a Zalman notebook cooler and a SIIG USB Soundwave 7.1 Pro USB microphone and audio adapter. The cooler is for obvious reasons, and this one reviewed well. The USB audio is because on my last Cardinal laptop, a Dell, the solder on the audio card and audio jack was defective which caused the audio to fail. Since I only plan on using headphones and a microphone when playing in a different room from Becky, I’ll plug the audio adapter into a USB hub (a poor man’s docking station) and use it that way.

The afternoon after I ordered my laptop, Arnold’s eye started weeping. He apparently developed glaucoma in his right eye, the feline iris melanoma finally progressing to the point where, during our vet trip on Thursday afternoon, Dr. Wrycha recommended enucleation. I dropped Arnold off at the vet for surgery this morning: he gets the last of the tax refund money and all of the pet savings account for his medical care. Arnold spent the weekend feeling no pain as I’ve kept him doped up on Torbugesic syrup, 1.0 cc’s every twelve hours.

102.JPG

Brody and Rose are getting alone. While Becky and I played online games, Rose babysat Brody.

Rose and Brody

Brody is a very sweet, cuddly dog. He’s going to be a total nightmare when he gets to be a “teen” in three months or so.

093.JPG

Laying the groundwork

Posted by Chris Jones
On January 4th, 2008 at 15:37

Permalink | Trackback | Links In |

Comments Off
Posted in Python, Tech

I’ve previously identified a few elements that are needed to make a successful web based application. Since then, I’ve been prototyping, designing, coding on the bus and while making dinner, and have a pared down, minimal proof of concept for a few of those.

  • XMLHttpRequest: I’ve verified XMLHttpRequest works with my wife’s iPhone. I expected it to, but had to make sure. This is the core Javascript call for dynamic web pages that retrieve content from servers.
  • Timer: I still need to verify this works as expected on the iPhone, but I have a demo page to verify it ready.

In addition to the front end work (of which there will be much, much more), I needed a back-end that I could develop actively. My platform choices were limited in that it needs to work on a Dreamhost shared server, work on my desktop at home, and also on my laptop for the bus or coding around the house. Tomcat had to be discarded: I’d need to set up a separate Tomcat server and Java environment at Dreamhost. Perl was discarded as I really don’t appreciate the language. :) I strongly considered PHP but decided against it in the end. Ruby was also considered but I didn’t want to learn a new language while coding a new app. I toyed with using Lua. In the end, I decided on Python 2.4 so I don’t have to do any gymnastics at Dreamhost. As far as my scripts are concerned, it’s a one-line change between platforms:

#!/Python24/pythonw for Win32
#!/usr/bin/python for Linux

I have a working Python back-end that gives me a minimum of helper objects for working with HTTP requests in a CGI environment. (No WSGI here, at least not yet.) I have room to plug in different request interpreters and a complete world engine or whatever might strike my fancy as long as I keep this minimal interface in place.

Now, nobody said I had to produce anything pretty when proving this works…

Try out my first proof of concept

I’d like my next proof of concept to be an interactive “game” or other social, multi-user activity.

Band aids? Upfront process and design are better

Posted by Chris Jones
On December 29th, 2007 at 10:37

Permalink | Trackback | Links In |

Comments Off
Posted in Design Journal, Tech

From Zubon of Kill Ten Rats:

Fixing the fundamental only gets worse once you already have a dozen band-aids on the wound. You must tear them all off and throw them away. But at least you get to do all those things you wanted to do if you had it to do over again.

And this is why we Unit Test.

Games that ship and have few bugs have well developed and scrupulously followed development processes. Games with bugs just get shoved out the door because scope creep and featuritis are given more importance than good project management. And for one-off, traditional single-player games, it wasn’t so bad, especially when the game developers were also designers and a four person development team was big. Check out High Moon Studios’ “Day in the Life” seminal article on SCRUM and Unit Testing a modern console game.

An MMO is more like a corporate ERP system than a Pac-Man or Tetris clone, and cutting corners to hit deadlines or out of sheer laziness (and believe me, programmers are lazy–it’s a virtue) helps create emergent behavior or bugs. Strong, comprehensive Unit Testing at the cost of adding dubious features to still meet the development schedule is the best defense against this. The Unit Test becomes a kind of document, an artifact that demonstrates how the developer believed the code was to be invoked and what it should return, and future changes against the code can be verified with execution against the entire suite of Unit Tests. The designer, developer, and producer will sleep well at night knowing that the vision has been translated to code or scripts accurately.
(more…)

Mockup in progress

Posted by Chris Jones
On December 28th, 2007 at 17:49

Permalink | Trackback | Links In |

Comments Off
Posted in Design Journal, Tech

Demo in progressAn iPhone web app mockup

Supposedly (I’ll have to test this at home) it’ll display without the iPhone graphic framing the content on a real iPhone. I’m not sure that I understand logic in CSS files well enough to guarantee that.

Does anyone have a lead on good tilesets for demos or mockups, game oriented (I don’t care about the theme, as long as people look distinctive and there’s a little bit of furniture or props available), around 20×20 pixels? I don’t want to make a smiley demo.

Note that I don’t have any of the Javascript hooked up for this, and I’ve only tested it under Firefox (so far).

Edit: The media tag didn’t work as I needed it to–I could restructure the CSS and probably fix it under the iPhone so that the fake iPhone frame won’t show up. Internet Explorer 6, on the other hand, can’t render it properly in any case: problems with DIV tags, or so it looks.

Designing for the iPhone could be a full time job

Posted by Chris Jones
On December 28th, 2007 at 12:36

Permalink | Trackback | Links In |

Comments Off
Posted in Design Journal, Tech

Check out Apple’s iPhone Safari Web Content guidelines (PDF, 6.1 MB) for some ideas about why iPhone web page development is different from typical web page development. A lot is the same: CSS, layout and positioning, XHTML and standards, etc. Some is different, like a META tag that defines the viewport size. And some new page events are generated, like onorientationchange–and there’s a hell of a lot you simply can’t do. It makes you, as a web application designer or developer, think hard about the interactions you plan on using and consider if they’re necessary or other ways that they can be done. And as a web app developer, you’re suddenly thinking about minimizing content sizes again and keeping an entire page under 30 MB, stripping unnecessary whitespace, and optimizing for a relatively slow 100 Kbps EDGE connection with 500 ms latency (since your users won’t always be using WiFi).

onorientationchange is going to require an additional 30% or more work for designing the page layout.

Here’s a thought for budding iPhone web app developers to mull on:

The finger and tap interface isn't the same as using a mouse

Debugging and missed my bus

Posted by Chris Jones
On August 22nd, 2007 at 15:59

Permalink | Trackback | Links In |

Comments Off
Posted in Tech, Work

Too much debugging leads to missed buses.

Edit: It turns out that my bus broke down anyway, so being a little late didn’t matter. It was standing room only, overfull bus (one of the passengers was riding in the front entrance) but I eventually made it home.

Updated Bloglines Blogroll

Posted by Chris Jones
On June 11th, 2007 at 11:29

Permalink | Trackback | Links In |

Comments (1) |
Posted in General, Tech

I updated the Bloglines Blogroll so that it’s a widget (compatible with Wordpress 2.2 sidebars and themes).

bloglinesblogroll.1.2.zip

It could probably do with a few tweaks to make it display better in the Newspress theme.

Bug in my WordPress theme

Posted by Chris Jones
On May 25th, 2007 at 11:02

Permalink | Trackback | Links In |

Comments (2) |
Posted in General, Tech

Anyone see the bug in my WordPress theme? I should update it if a new one is available.

Hint: check the post times . . .

Fixed the blogroll

Posted by Chris Jones
On May 23rd, 2007 at 12:37

Permalink | Trackback | Links In |

Comments Off
Posted in General, Tech

Thanks to Cindy at Digital Ramble for releasing her BloglinesBlogroll plug-in. I made some modifications to improve the appearance (stripped out

tags and rebuilt it as a set of nested lists) and now the blogroll appears properly in any theme.

It stopped working because when I changed hosts last summer from my own box to Dreamhost, I lost access to opening URLs as files using PHP include (see below). It would have been easy to fix by using CURL, like Cindy did, but it never bugged me enough to research the problem.

ob_start();
include $blogroll_url;
$blogroll_in = ob_get_contents();
ob_end_clean();

Using CURL instead:

$ch = curl_init();
$timeout = 5; // set to zero for no timeout
curl_setopt ($ch, CURLOPT_URL, $blurl);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$file_contents = curl_exec($ch);
curl_close($ch);

My version of the BloglinesBlogroll plug-in is available for download. Installation and use is identical to Cindy’s version, although the appearance is different.