Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:43228 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 45959 invoked from network); 2 Mar 2009 16:47:44 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Mar 2009 16:47:44 -0000 Authentication-Results: pb1.pair.com header.from=jbondc@openmv.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=jbondc@openmv.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain openmv.com from 64.15.152.204 cause and error) X-PHP-List-Original-Sender: jbondc@openmv.com X-Host-Fingerprint: 64.15.152.204 mail.ca.gdesolutions.com Received: from [64.15.152.204] ([64.15.152.204:61038] helo=mail.ca.gdesolutions.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 62/3F-00495-DAD0CA94 for ; Mon, 02 Mar 2009 11:47:42 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.ca.gdesolutions.com (Postfix) with ESMTP id 7BE195C4F for ; Mon, 2 Mar 2009 11:47:39 -0500 (EST) X-Virus-Scanned: amavisd-new at gdesolutions.com Received: from mail.ca.gdesolutions.com ([127.0.0.1]) by localhost (mail.ca.gdesolutions.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id silzdYndu5lF for ; Mon, 2 Mar 2009 11:47:37 -0500 (EST) Received: from djbondc (modemcable158.97-203-24.mc.videotron.ca [24.203.97.158]) by mail.ca.gdesolutions.com (Postfix) with ESMTP id 7B5365C4D for ; Mon, 2 Mar 2009 11:47:37 -0500 (EST) To: "'PHP Developers Mailing List'" Date: Mon, 2 Mar 2009 11:47:36 -0500 Message-ID: <002a01c99b56$97b7fd00$c727f700$@com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_002B_01C99B2C.AEE1F500" X-Mailer: Microsoft Office Outlook 12.0 Thread-Index: AcmbVpXRvcgBz3lWRwWZQb1SjgaG2w== Content-Language: en-ca Subject: Stream chunk size From: jbondc@openmv.com ("Jonathan Bond-Caron") ------=_NextPart_000_002B_01C99B2C.AEE1F500 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi everyone, I have a question about streams and the maximum =91chunk = size=92 of 8192.=20 =20 I=92ve read README.STREAMS and found these slides by Wez: http://netevil.org/blog/2008/07/slides-php-streams =20 While trying to write an Amazon S3 stream wrapper and I ran into an = issue with large files:=20 =20 $fp =3D fopen('s3://mvtest/large.html', 'r'); // 30 mb =20 // This is OK fseek($fp, 10); echo fread($fp, 100) . "\n"; // 100 bytes echo fread($fp, 100) . "\n"; // 100 bytes =20 // This is OK (according to documentation, max 8192 bytes)=20 echo fread($fp, 65536) . "\n"; // 8192 bytes =20 My issue is I would like to request larger =91chunks=92, something like: stream_set_chunk_size($fp, 65536); =20 echo fread($fp, 65536) . "\n"; // 65536 bytes echo fread($fp, 100000) . "\n"; // 65536 bytes echo fread($fp, 15) . "\n"; // 15 bytes =20 Then copying to a file and avoiding memory issues: =20 $wfp =3D fopen(=91/tmp/large.html=92); stream_copy_to_stream($fp, $wfp); // read 65536 byte chunks, write = default 8192 byte chunks =20 stream_set_chunk_size($wfp, 65536); stream_copy_to_stream($fp, $wfp); // read & write 65536 byte chunks copy('s3://mvtest/large.html', '/tmp/large.html'); // read & write = default 8192 byte chunks =20 Going through the PHP 5.2 source, it looks like there=92s support for it = but at some places the 8192 =91chunk=92 is hardcoded: =20 #define CHUNK_SIZE 8192 =20 PHPAPI size_t _php_stream_copy_to_stream(php_stream *src, php_stream = *dest, size_t maxlen STREAMS_DC TSRMLS_DC) { char buf[CHUNK_SIZE]; =DF Is there any reason the = php_stream *src->chunk_size isn=92t used? =20 stream_set_chunk_size($fp, 65536); // Would mean src->chunk_size =3D = 65536; =20 I=92d like to try to write a patch for it, anything that I should know = about streams and why the limit is there? ------=_NextPart_000_002B_01C99B2C.AEE1F500--