Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

I candidly agree with Anonymous.   Just use a temporary-file, using something like File::Temp or Data::TemporaryBag.   Then, let the filesystem’s caching mechanism do the rest of the work for you.   There are actually compelling reasons to do this.

“RAM disks” were a great idea in the old days, when a program’s memory was real and disks were slow.   You could manually carve out a chunk of memory and use it as a disk.   There was no concept that the memory you carved-out could be paged-out.   But today’s OSes do not allow you to do that.   User-space memory is virtual, period.

If you simply use a temporary file, the OS knows that it is a file and may even know that it is temporary.   Systems like Linux will carve out buffer pages as the least-important use of available RAM and will fill-up unused memory with it, “lazy writing” only when necessary.   This works because the OS knows that this memory is being used for file-buffer purposes.   Whereas, if you instead use a ram-disk, one of two things may happen and neither one of them is good:

  1. You will seize a fixed amount of real storage from the operating system, denying it to all other uses, effectively managing itself ... as though your app actually knew how or deserved such expensive privilege.
  2. You will allocate a large chunk of what the OS simply sees as “your process’s virtual memory,” which it may well page-out.   It does not know that you think of that memory as a file or disk.


In reply to Re: Sys::Ramdisk as regular user on Linux by sundialsvc4
in thread Sys::Ramdisk as regular user on Linux by szabgab

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2022-05-27 06:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (94 votes). Check out past polls.

    Notices?