Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:75353 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 74942 invoked from network); 10 Jul 2014 09:15:37 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Jul 2014 09:15:37 -0000 Authentication-Results: pb1.pair.com header.from=julienpauli@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=julienpauli@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.220.180 as permitted sender) X-PHP-List-Original-Sender: julienpauli@gmail.com X-Host-Fingerprint: 209.85.220.180 mail-vc0-f180.google.com Received: from [209.85.220.180] ([209.85.220.180:62031] helo=mail-vc0-f180.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 6B/51-65406-7B95EB35 for ; Thu, 10 Jul 2014 05:15:36 -0400 Received: by mail-vc0-f180.google.com with SMTP id im17so10023274vcb.11 for ; Thu, 10 Jul 2014 02:15:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=nwB1UgniXSnpgwhj1EJ+JBrcWptTcCguCDj54jridwo=; b=C2xF6SnReiHQQ/o17SqFC3bOaQw3D1N84EboQLWVLRhPOzJdG9nx7fD1p4i0J4MB4K b7Hmh8a8dtllMncJZyFN0MjjALfeEFWEavHGcJcPGgf2lYD94kd3wqWhxX1kGVwBiW79 H2UJTP8YHiRhWi0vDWMec/Zz3sP8SPdSlt+RWbUwCguy02CsFCc60qkzjRg/wmc5zh2h q3ir1vPVepgEv5PR4fWIhWp2Cp9xUufFIyGrG46aIFpsPLUg767UtbcERIlZtiWv0gXZ haJqirpY3pvaHUbSnGHFzio67Yf7fnvQ7jEveHfSghg8F9uTnMNCOa87sfBLTWAE0z0I swzg== X-Received: by 10.220.17.199 with SMTP id t7mr44532311vca.1.1404983733356; Thu, 10 Jul 2014 02:15:33 -0700 (PDT) MIME-Version: 1.0 Sender: julienpauli@gmail.com Received: by 10.220.81.68 with HTTP; Thu, 10 Jul 2014 02:14:53 -0700 (PDT) In-Reply-To: <39a433499b80ad70849e642f9e355167.squirrel@webmail.klapt.com> References: <39a433499b80ad70849e642f9e355167.squirrel@webmail.klapt.com> Date: Thu, 10 Jul 2014 11:14:53 +0200 X-Google-Sender-Auth: SNSvfcP2309OVhzjgGiq7k2HyAo Message-ID: To: Anatol Belski Cc: PHP Internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] Implemented fallocate() syscall in streams From: jpauli@php.net (Julien Pauli) On Tue, Jul 8, 2014 at 8:42 AM, Anatol Belski wrote: > Hi Julien, > > On Fri, June 13, 2014 16:20, Julien Pauli wrote: >> Hi, >> >> >> I just wrote a patch to add fallocate() syscall support for streams. >> It relies on posix_fallocate(), so that it should support many Unixes. >> Linux's got a specification with a fallocate() function, more powerful >> than the posix call. >> >> fallocate() does write blocks to the underlying filesystem (not so many >> are supported, but the ones not supported should proxy to ftruncate()) and >> prevents sparse file creation whereas ftruncate() just updates inode >> information, leading to possible future out of space errors. >> >> I got a POC showing the diffs between both calls here : >> https://gist.github.com/jpauli/8afec7c4fc2b38f8ff27 >> >> >> I propose two APIs for PHP : >> - One that adds a function : fallocate() >> https://github.com/jpauli/php-src/tree/fallocate >> >> >> - One that relies on ftruncate() , and adds a $use_fallocate >> flag https://github.com/jpauli/php-src/tree/fallocate_flag >> >> Please, note that the latest proposal requires patches in different >> extensions, as I changed a PHP_API function signature. >> >> I don't know if Windows can support that. Pierre, Anatol ? :-) >> >> >> Tests are beeing written at the moment. >> >> >> I didn't implement this is user stream handlers, as this really is a >> low level implementation design that is kind of useless for usage in user >> streams. >> >> Thoughts ? >> > I've found this code > > http://hg.mozilla.org/mozilla-central/file/3d846420a907/xpcom/glue/FileUtils.cpp#l61 > > On windows there's no such syscalls. All the data is however buffered, as > usual. An emulation could be of course implemented for Windows and other > unsupported platforms. However it probably wouldn't mimic the exact > behavior. > > But besides writing in blocks (fallocate) and fast truncating - there are > some other useful things i see on the man page. I mean checking for the > free space or all those flags like zeroing file space. Actually, maybe > it'd be even more useful to put it into user space, maybe as normal > functions? Otherwise, if you think it's too low level, one could go two > ways - ether implement an emulation, or just use HAVE_FALLOCATE and a > configure switch to activate it manually. > > Regards > > Anatol Hey Anatol ;-) Would you mind working with me finalizing this patch so that we could merge it in master for a 5.7 and Next eventually ? I'll update the PR next week with tests, then we'll be able to talk about the implementation to use for crossplatform. Thank you Julien.P