Skip to content

Instantly share code, notes, and snippets.

View jzawodn's full-sized avatar

Jeremy Zawodny jzawodn

View GitHub Profile
@jzawodn
jzawodn / leak.t
Created September 7, 2012 23:26
Testing for leaks in AnyEvent::Redis::Federated with the poll() call
#!/usr/bin/perl -w
use strict;
use lib ('../lib','./lib');
use Test::More tests => 1;
use AnyEvent::Redis::Federated;
my %config = (
'nodes' => {
redis_0 => { address => 'localhost:63790' },
@jzawodn
jzawodn / leak-no-poll.t
Created September 7, 2012 23:23
Testing for leaks in AnyEvent::Redis::Federated witout the poll() call
#!/usr/bin/perl -w
use strict;
use lib ('../lib','./lib');
use Test::More tests => 1;
use AnyEvent;
use AnyEvent::Redis::Federated;
my %config = (
'nodes' => {
@jzawodn
jzawodn / hashfun.pl
Created September 7, 2012 22:42
Testing perl memory use on hash with many short lived keys
#!/usr/bin/perl
use strict;
use warnings;
my $h;
my $i = 0;
while (1) {
$h->{$i} = 1;
--- searchd.cpp.orig 2012-04-16 15:23:46.000000000 -0700
+++ searchd.cpp 2012-04-18 17:05:29.000000000 -0700
@@ -1298,6 +1298,10 @@
#endif
const int iShutWaitPeriod = 3000000;
+
+ ARRAY_FOREACH ( i, g_dListeners )
+ if ( g_dListeners[i].m_iSock>=0 )
+ sphSockClose ( g_dListeners[i].m_iSock );
@jzawodn
jzawodn / searchd.cpp.diff
Created April 16, 2012 22:26
remove sphinx shutdown race condition
--- searchd.cpp.orig 2012-04-16 15:23:46.000000000 -0700
+++ searchd.cpp 2012-04-16 15:24:45.000000000 -0700
@@ -1398,6 +1398,13 @@
ARRAY_FOREACH ( i, g_dListeners )
if ( g_dListeners[i].m_iSock>=0 )
sphSockClose ( g_dListeners[i].m_iSock );
+
+ // remove pid
+ if ( g_bHeadDaemon && g_sPidFile )
+ {
#!/usr/bin/perl
# Demonstrate handling of waiting for the exit values from multiple
# forked child processes. Code based on that in the perlipc man page.
use strict;
use warnings;
use feature "say";
use POSIX ":sys_wait_h"; # for waitpid
#!/usr/bin/perl
use strict;
use warnings;
use Getopt::Long;
# This script will generate the commands used to preshard a collection
# in mongodb.
#
# See:
# http://www.mongodb.org/display/DOCS/Splitting+Chunks
@jzawodn
jzawodn / ae_redis_blpop.pl
Created October 29, 2010 17:06
AnyEvent Perl BLPOP loop. Has memory leak.
#!/usr/bin/perl -w
$|=1;
use strict;
use lib '/home/jzawodn/code/AnyEvent-Redis/lib';
use AnyEvent::Redis;
my $host = 'localhost';
my $port = 6379;
my @chan = 'a'..'z'; # which queues/channels to check
my $command_timeout = 1; # how long to wait for a response
@jzawodn
jzawodn / ae_redis_get.pl
Created October 29, 2010 17:05
AnyEvent Perl GET loop. No memory leak.
#!/usr/bin/perl -w
$|=1;
use strict;
use lib '/home/jzawodn/code/AnyEvent-Redis/lib';
use AnyEvent::Redis;
my $host = 'localhost';
my $port = 6379;
my $key = 'foo';
#!/usr/bin/perl -w
$|++;
use strict;
use lib 'perl-Redis/lib';
use Redis;
my $r = Redis->new(server => 'localhost:63790') or die "$!";
## 2.5B values