Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re: Safe to open+close for every write, without locking?

by sedusedan (Monk)
on Dec 21, 2012 at 03:58 UTC ( #1009849=note: print w/replies, xml ) Need Help??

in reply to Safe to open+close for every write, without locking?

BTW, the reason I'm investigating open+write+close instead of using flock is because I might have to reopen a new file at any time anyway due to automatic rotation, plus using flock will make performance suffer when there are lots of concurrent writers. For example, with open+write+close a single process performance is 40k lines/sec and for 100 concurrent processes the overall performance is 154k lines/sec. Using flock, single process performance is 68k lines/sec but with 100 concurrent processes overall performance drops to 23k lines/sec.
  • Comment on Re: Safe to open+close for every write, without locking?

Replies are listed 'Best First'.
Re^2: Safe to open+close for every write, without locking?
by BrowserUk (Pope) on Dec 21, 2012 at 04:32 UTC

    If performance is your primary criteria, you'd be much better off creating a demon that opens a fifo, have your processes write their lines to the fifo and have the demon write them to disk in 64k chunks.

    (Isn't that called a syslog under *nix?)

    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

    RIP Neil Armstrong

      Like Log::Dispatch::FileRotate, my module will/might be used by CGI scripts (multiple writers, potentially lots of concurrent writers, one-off processes, no daemon).

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1009849]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (7)
As of 2018-07-17 10:20 GMT
Find Nodes?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?

    Results (363 votes). Check out past polls.