Faster JavaScript with Safari/WebKit SquirrelFishIn June, the project announced SquirrelFish, the oddly named next-gen JavaScript engine which includes bytecode compilation and a number of optimisations. The announcement indicates a 1.7 x speed increase over the engine in Safari 3.0. My perceptual testing on my (admittedly low baseline) G4 PPC powerbook suggests that startup time of JavaScript intensive applications such as Gmail improves only a little (saving 1 second off the 9 second startup time), but the ongoing performance is much snappier. Things like Flickr badges load in a snap. It is good to get closer to the performance Firefox 3.0 which has the maddening property that it starts out very fast (7 second Gmail startup), but a large amount of JavaScript intensive browsing brings it to its knees over time - something Safari suffers far less from. You can get a hold of the new engine by downloading the WebKit knightly build from http://webkit.org/ 07:59 PM, 24 Aug 2008 by Mark Aufflick Permalink | Comments (0) Testing database deadlock retry logicI just spent a *really* long time writing a test for automatic deadlock retry in a database api module I maintain. So you or I don't have to figure it out in the future, here's the recipe. So firstly you can't use transactions to build the deadlock situation. That would be easy, but it defeats our purpose since your auto-deadlock retry logic is not going to be able to retry intra-transaction statements (of course you could implement full transaction replay, but that's another story). So I did it using cursors. Here is a perl sub that builds Sybase TSQL. It returns two values only because Sybase requires the cursor declaration in a separate batch. sub deadlock_sql {
my ($table1, $table1_char_col, $table2, $table2_col) = @_;
"declare the_cursor cursor for select $table1_char_col from $table1 for update",
sprintf 'declare @col_value varchar(100)
open the_cursor
fetch the_cursor into @col_value
waitfor delay "00:00:04" -- wait 4 seconds
update %s set %s = %s
-- only need to go round once to cause deadlock
', $table2, $table2_col, $table2_col;
}
So we are taking out a write lock on the first table, waiting 4 seconds, then taking out a write lock on the second table. Do that
twice in opposite order and you have yourself a deadlock:
sub cause_a_deadlock {
my $child_pid;
my $parent_retries;
pipe(FROM_CHILD, TO_PARENT);
if ($child_pid = fork) {
# parent
close(TO_PARENT);
my $dbh = new_dbh();
my @sql = deadlock_sql('table1', 'a_char_col_from_table1', 'table2', 'any_col_from_table_2');
sleep 2; # sleep half of sql sleep to ensure overlap
$dbh->exec_sql($sql[0]);
lives_ok { $dbh->exec_sql($sql[1]) };
$parent_retries = $dbh->deadlock_retry_attempts;
} else {
# child
close(FROM_CHILD);
my $dbh = new_dbh();
my @sql = deadlock_sql('table2', 'a_char_col_from_table2', 'table1', 'any_col_from_table_1');
$dbh->exec_sql($sql[0]);
lives_ok { $dbh->exec_sql($sql[1]) };
print TO_PARENT $dbh->deadlock_retry_attempts . "\n";
exit;
}
my $child_retries =
Of course the exact code will depend on your database and database abstraction layer. 07:35 PM, 20 Aug 2008 by Mark Aufflick Permalink | Comments (0) 5 years and still blogging
August 2003 saw the start of this weblog. My first blog was in 2002 when I visited Denmark to do some work with my friend Lars, but when I shut that down after my travels I neglected to save the contents. So instead I will call this the fifth year of my blogging.
Who would have predicted that the SCO law suits I blogged about in that first month would still be going. Perhaps more predictably, the Be company, blogged about in my second month, would go under. Also predictably I have less time for blogging now that I have a "real" job and am also studying part time. Thanks to everyone who ever commented and all my regular readers (I count 3 - am I missing anyone?). I enjoy writing, so you'll be sure to keep hearing from me well into the future. I plan to list a few favourite posts a little later and thank some inspirations. Hey - any excuse! 07:52 PM, 09 Aug 2008 by Mark Aufflick Permalink | Comments (4) August == SkiingWell it's August and that means skiing :) Some of you will know that I had a day of blissful snow in NZ in June, but next week Kath and I head to Thredbo for nearly a full week of hounding powder - and there's stacks of it too! This was NZ - sounds like Thredbo will be just as good: 07:44 PM, 09 Aug 2008 by Mark Aufflick Permalink | Comments (0) |
Archive
November 2008 October 2008 September 2008 August 2008 July 2008 June 2008 May 2008 March 2008 February 2008 January 2008 December 2007 November 2007 October 2007 September 2007 August 2007 July 2007 June 2007 May 2007 April 2007 March 2007 February 2007 January 2007 December 2006 November 2006 October 2006 September 2006 August 2006 July 2006 June 2006 May 2006 April 2006 March 2006 February 2006 January 2006 December 2005 November 2005 October 2005 September 2005 August 2005 July 2005 June 2005 May 2005 April 2005 March 2005 February 2005 January 2005 December 2004 November 2004 October 2004 September 2004 August 2004 July 2004 June 2004 May 2004 April 2004 March 2004 February 2004 January 2004 December 2003 November 2003 October 2003 September 2003 August 2003 Notifications Request notifications
Recent Comments | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Request notifications