Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.perl.misc > #8744
| From | Rainer Weikusat <rweikusat@mssgmbh.com> |
|---|---|
| Newsgroups | comp.lang.perl.misc |
| Subject | Re: the fastest way to create a directory |
| Date | 2013-07-17 22:22 +0100 |
| Message-ID | <87vc48yj8x.fsf@sapphire.mobileactivedefense.com> (permalink) |
| References | <ks0l7j$9j4$1@news.ntua.gr> <kbaeba-dfc1.ln1@anubis.morrow.me.uk> <slrnkubflf.ef9.hjp-usenet3@hrunkner.hjp.at> <87mwplo6sj.fsf@sapphire.mobileactivedefense.com> <slrnkue03v.dn8.hjp-usenet3@hrunkner.hjp.at> |
"Peter J. Holzer" <hjp-usenet3@hjp.at> writes:
> On 2013-07-17 09:49, Rainer Weikusat <rweikusat@mssgmbh.com> wrote:
>> "Peter J. Holzer" <hjp-usenet3@hjp.at> writes:
>>> On 2013-07-15 22:40, Ben Morrow <ben@morrow.me.uk> wrote:
>>>> Quoth George Mpouras <nospam.gravitalsun.noadsplease@hotmail.noads.com>:
>>>>> sub Mkdir_recursive
>>>>> {
>>>>> return 1 if $_[0] eq '' || -d $_[0];
>>>>> Mkdir_recursive( $_[0] =~/^(.*?)[\\\/][^\\\/]+$/ ) || return undef;
>>>>> mkdir $_[0] || return undef
>>>>> }
>>>>
>>>> You'd be better off calling mkdir blind and keying off $! if it fails.
>>>> That way you save a stat in the case where the creation succeeds.
>>>
>>> That shouldn't make a noticeable difference. If the stat does cause any
>>> disk accesses, those would also have been caused by the mkdir, and if it
>>> doesn't (i.e. everything is already in the cache) the time for the stat
>>> calls is completely swamped by the mkdir's.
>>
>> Both stat and mkdir are system calls and 'one system call' is going to
>> be faster than 'two system calls'.
>
> As stated, that's trivially untrue ('one call to exec(2)' will *not* be
> faster than 'two calls to time(2)' except under pathological
> circumstances),
Yes. And a single call to pause(2) will take forever except 'under
pathological circumstances'. Another interesting (Linux-)system call would be
reboot because not only doesn't it ever return, it might even cause
the system to be powered down!
Morale: Thanks to inherent vagueness in natural language and the
sloppy ways people usually use it, anything can be interpreted in a
way which doesn't make sense.
> but even if I translate that into 'an additional system
> call will take additional time', it's not necessarily true.
What about trying the intended meaning: Calling stat and mkdir is
going to take more time than calling stat and not mkdir or mkdir and
not stat (the two system calls in question).
BTW: Should I immediately supply a fresh round of nonsensical
interpretations?
[...]
> Each successful mkdir call will cause at least 5 disk accesses on a
> typical Linux file system: 1 for the journal, 2 for the inode and
> content of the parent directory and 2 for the inode and content of the
> new directory (Oh, I forgot the bitmaps, add another 2 or 4 ...). These
> will happen *after* mkdir returns because of the writeback cache, and
> the kernel will almost certainly succeed in coalescing at least some and
> maybe many of those writes, but if you create a lot of directories
> (George wrote about "thousands", in my tests I created about 150000)
> these writes will eventually dominate.
[more of this]
As I already tried to communicate in the earlier posting: 'Disk I/O'
is in itself a pathological situation or at least one the kernel tries
very hard to avoid. Since it is going to be slower than pretty much
everything else, talking about the execution speed of different
algorithms becomes completely meaningless then. Consequently, it
should be disregarded when doing this.
Back to comp.lang.perl.misc | Previous | Next — Previous in thread | Next in thread | Find similar
the fastest way to create a directory George Mpouras <nospam.gravitalsun.noadsplease@hotmail.noads.com> - 2013-07-15 14:09 +0300
Re: the fastest way to create a directory Henry Law <news@lawshouse.org> - 2013-07-15 15:44 +0100
Re: the fastest way to create a directory "George Mpouras" <nospam.gravitalsun.antispam@spamno.hotmail.anispam.com.nospam> - 2013-07-15 18:45 +0300
Re: the fastest way to create a directory Charlton Wilbur <cwilbur@chromatico.net> - 2013-07-15 15:36 -0400
Re: the fastest way to create a directory "George Mpouras" <nospam.gravitalsun.antispam@spamno.hotmail.anispam.com.nospam> - 2013-07-16 00:07 +0300
Re: the fastest way to create a directory "Peter J. Holzer" <hjp-usenet3@hjp.at> - 2013-07-15 23:55 +0200
Re: the fastest way to create a directory tmcd@panix.com (Tim McDaniel) - 2013-07-15 20:27 +0000
Re: the fastest way to create a directory "George Mpouras" <nospam.gravitalsun.antispam@spamno.hotmail.anispam.com.nospam> - 2013-07-16 00:04 +0300
Re: the fastest way to create a directory "Peter J. Holzer" <hjp-usenet3@hjp.at> - 2013-07-16 00:02 +0200
Re: the fastest way to create a directory "George Mpouras" <nospam.gravitalsun.antispam@spamno.hotmail.anispam.com.nospam> - 2013-07-18 00:16 +0300
Re: the fastest way to create a directory tmcd@panix.com (Tim McDaniel) - 2013-07-15 22:16 +0000
Re: the fastest way to create a directory Charlton Wilbur <cwilbur@chromatico.net> - 2013-07-18 15:49 -0400
Re: the fastest way to create a directory Henry Law <news@lawshouse.org> - 2013-07-18 21:47 +0100
Re: the fastest way to create a directory "Peter J. Holzer" <hjp-usenet3@hjp.at> - 2013-07-19 15:25 +0200
Re: the fastest way to create a directory Rainer Weikusat <rweikusat@mssgmbh.com> - 2013-07-19 14:51 +0100
Re: the fastest way to create a directory Keith Keller <kkeller-usenet@wombat.san-francisco.ca.us> - 2013-07-19 08:39 -0700
Re: the fastest way to create a directory Charlton Wilbur <cwilbur@chromatico.net> - 2013-07-21 23:19 -0400
Re: the fastest way to create a directory Henry Law <news@lawshouse.org> - 2013-07-22 07:10 +0100
Re: the fastest way to create a directory Charlton Wilbur <cwilbur@chromatico.net> - 2013-07-22 17:31 -0400
Re: the fastest way to create a directory Rainer Weikusat <rweikusat@mssgmbh.com> - 2013-07-19 16:40 +0100
Re: the fastest way to create a directory Ben Morrow <ben@morrow.me.uk> - 2013-07-15 23:40 +0100
Re: the fastest way to create a directory "Peter J. Holzer" <hjp-usenet3@hjp.at> - 2013-07-16 23:44 +0200
Re: the fastest way to create a directory George Mpouras <nospam.gravitalsun.noadsplease@hotmail.noads.com> - 2013-07-17 11:09 +0300
Re: the fastest way to create a directory "Peter J. Holzer" <hjp-usenet3@hjp.at> - 2013-07-17 10:24 +0200
Re: the fastest way to create a directory George Mpouras <nospam.gravitalsun.noadsplease@hotmail.noads.com> - 2013-07-17 11:10 +0300
Re: the fastest way to create a directory Rainer Weikusat <rweikusat@mssgmbh.com> - 2013-07-17 10:49 +0100
Re: the fastest way to create a directory "Peter J. Holzer" <hjp-usenet3@hjp.at> - 2013-07-17 22:37 +0200
Re: the fastest way to create a directory Rainer Weikusat <rweikusat@mssgmbh.com> - 2013-07-17 22:22 +0100
Re: the fastest way to create a directory Ben Morrow <ben@morrow.me.uk> - 2013-07-19 16:21 +0100
Re: the fastest way to create a directory "Peter J. Holzer" <hjp-usenet3@hjp.at> - 2013-07-19 22:11 +0200
Re: the fastest way to create a directory "George Mpouras" <nospam.gravitalsun.antispam@spamno.hotmail.anispam.com.nospam> - 2013-07-18 00:14 +0300
Re: the fastest way to create a directory tmcd@panix.com (Tim McDaniel) - 2013-07-17 21:21 +0000
Re: the fastest way to create a directory Rainer Weikusat <rweikusat@mssgmbh.com> - 2013-07-17 22:31 +0100
Re: the fastest way to create a directory "George Mpouras" <nospam.gravitalsun.antispam@spamno.hotmail.anispam.com.nospam> - 2013-07-19 00:02 +0300
Re: the fastest way to create a directory Rainer Weikusat <rweikusat@mssgmbh.com> - 2013-07-19 10:46 +0100
Re: the fastest way to create a directory Rainer Weikusat <rweikusat@mssgmbh.com> - 2013-07-19 10:51 +0100
Re: the fastest way to create a directory Rainer Weikusat <rweikusat@mssgmbh.com> - 2013-07-19 12:09 +0100
Re: the fastest way to create a directory Keith Keller <kkeller-usenet@wombat.san-francisco.ca.us> - 2013-07-17 22:37 -0700
Re: the fastest way to create a directory Justin C <justin.1303@purestblue.com> - 2013-07-18 09:15 +0100
Re: the fastest way to create a directory "George Mpouras" <nospam.gravitalsun.antispam@spamno.hotmail.anispam.com.nospam> - 2013-07-19 01:01 +0300
Re: the fastest way to create a directory "George Mpouras" <nospam.gravitalsun.antispam@spamno.hotmail.anispam.com.nospam> - 2013-07-19 01:07 +0300
Re: the fastest way to create a directory "George Mpouras" <nospam.gravitalsun.antispam@spamno.hotmail.anispam.com.nospam> - 2013-07-23 09:33 +0300
csiph-web