Faster JavaScript with Safari/WebKit SquirrelFish
In 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/
05:59 AM, 24 Aug 2008 by Mark Aufflick Permalink | Comments (0)
Testing database deadlock retry logic
I 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 = <from_CHILD>;
chomp($child_retries);
close(FROM_CHILD);
waitpid $child_pid, 0;
# we don't know which spid was aborted & retried, but one was
ok($parent_retries + $child_retries > 0, 'there were deadlock retries');
is($parent_retries, 0, 'only the child had to retry') if $child_retries;
is($child_retries, 0, 'only the parent had to retry') if $parent_retries;
}Of course the exact code will depend on your database and database abstraction layer.
05:35 AM, 20 Aug 2008 by Mark Aufflick Permalink | Comments (0)
5 years and still 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!
05:52 AM, 09 Aug 2008 by Mark Aufflick Permalink | Comments (4)
August == Skiing
Well 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:
05:44 AM, 09 Aug 2008 by Mark Aufflick Permalink | Comments (0)
Archive
| August 2008 | ||||||
| S | M | T | W | T | F | S |
| 1 | 2 | |||||
| 3 | 4 | 5 | 6 | 7 | 8 | 9 |
| 10 | 11 | 12 | 13 | 14 | 15 | 16 |
| 17 | 18 | 19 | 20 | 21 | 22 | 23 |
| 24 | 25 | 26 | 27 | 28 | 29 | 30 |
| 31 | ||||||
February 2012
November 2011
October 2011
April 2011
March 2011
January 2011
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
February 2009
January 2009
December 2008
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
Blog Categories
software (40)..cocoa (21)
..heads up 'tunes (5)
..ruby (6)
..lisp (4)
..perl (4)
..openacs (1)
mac (21)
embedded (2)
..microprocessor (2)
..avr (1)
electronics (3)
design (1)
photography (26)
..black and white (6)
..A day in Sydney (18)
..The Daily Shoot (6)
food (2)
Book Review (2)
Notifications
Request notifications











