CC: | <gisle [...] ActiveState.com> |
Subject: | SOAP::Lite affects native LWP::UserAgent Performance |
Date: | Tue, 8 May 2007 13:56:47 -0700 |
To: | <bug-SOAP-Lite [...] rt.cpan.org> |
From: | "Milton Ngan" <milton [...] valvesoftware.com> |
Debian 4.0 install of
perl (5.8.8)
libsoap-lite-perl (0.69)
libwww-perl (5.805)
I have a script I am using against Bugzilla's (3.0rc1) web service. It
logs in and creates a bug, but then it uses the CGI interface to upload
attachments to the bug. When I upload the attachments I am seeing very
poor performance (64kBps) over the loopback network. If I write a script
to just upload the attachments it works fine. The key thing I noticed
was the difference in the system calls being used. The good instance
looks like this:
0.000487 write(1, "------\nPOST /bugzilla/test.cgi H"..., 321) =
321
0.000107 write(3, "POST /bugzilla/test.cgi HTTP/1.1"..., 306) = 306
0.000088 select(8, [3], [3], NULL, {180, 0}) = 1 (out [3], left
{180, 0})
0.000091 write(3, "--xYzZY\r\nContent-Disposition: fo"..., 3100896)
= 194180
0.000204 select(8, [3], [3], NULL, {180, 0}) = 1 (out [3], left
{179, 996000})
0.003467 write(3,
"\4\0\340\t\363\34\n\0\4\0\250\16p=\"\301\4\0J\16\\\375"..., 2906716) =
128480
0.000160 select(8, [3], [3], NULL, {180, 0}) = 1 (out [3], left
{179, 996000})
0.001952 write(3,
"M\f\t\0\200\200ACT_IDLE\0\4\0\360\f\1\0\0\0008\0\21\16"..., 2778236) =
64240
0.000112 select(8, [3], [3], NULL, {180, 0}) = 1 (out [3], left
{180, 0})
0.001009 write(3,
"\304\4\0h\6\0\0\200?\f\0\250\3=\236\304\305{\0LE\0\0\255"..., 2713996)
= 128480
The bad instance look more like this:
0.182372 write(1, "------\nPOST /bugzilla/test.cgi H"..., 322) =
322
0.000147 write(3, "POST /bugzilla/test.cgi HTTP/1.1"..., 307) = 307
0.000092 select(8, [3], [3], NULL, {180, 0}) = 1 (out [3], left
{180, 0})
0.000099 mmap2(NULL, 66113536, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x98176000
1.932848 write(3, "--xYzZY\r\nContent-Disposition: fo"...,
47566699) = 195640
0.000320 munmap(0x98176000, 66113536) = 0
0.004664 select(8, [3], [3], NULL, {180, 0}) = 1 (out [3], left
{180, 0})
0.000106 mmap2(NULL, 66113536, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x98176000
1.931552 write(3,
"w?\0\0\0\0u\360UE\4\0\0\0\0\0\0\0\267\334\177\277^a\6="..., 47371059) =
197100
0.000298 munmap(0x98176000, 66113536) = 0
0.004622 select(8, [3], [3], NULL, {180, 0}) = 1 (out [3], left
{180, 0})
0.000125 mmap2(NULL, 66113536, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x98176000
1.939358 write(3,
"\0\0\0\0\0\0\0\200\177\305\0\0\0\0\0\0\200\277\0\0\0\0"..., 47173959) =
197100
The bug is quite subtle. I have narrowed it down to me accessing the
return values from the soap result object. If I don't touch the result
object it all works fine. This piece of code here triggers the problem.
$self->{_cookie_jar} = new HTTP::Cookies(ignore_discard=>1);
$self->{_soap_proxy} =
XMLRPC::Lite->proxy("$self->{bz_url_base}/xmlrpc.cgi");
$self->{_soap_proxy}->transport->cookie_jar($self->{_cookie_jar});
...
my $soapresult = $self->{_soap_proxy}->call('Bug.create',
$soap_bug);
my $result = $soapresult->result;
my $bug_id = $result->{id};
The code for uploading the attachment looks like this:
my $form = [
bigfile => 1,
bugid => $bug_id,
action => 'insert',
description => $file,
ispatch => 0,
addcomment => 0,
contenttypemethod => 'autodetect',
comment => "$bug_id - $file",
create => "Submit",
data => [ $file ],
];
print "Uploading file\n";
my $response =
$self->{_user_agent}->post("$self->{bz_url_base}/test.cgi",
$form, 'Content-Type' =>
'multipart/form-data');
The user agent in this last piece of code can be either the transport
object from the soap proxy object, or it can be a native LWP::UserAgent
object. Both are equally affected. I even tried recreating the user
agent immediately before uploading, and this still didn't work. So some
global state is being affected.
Let me know if you need more information
Milton