473,320 Members | 1,845 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

php mmap and munmap

Looking at the php manual site, I don't see where php
supports memory mapped file IO.
Is that right? Or are mmap and munmap called something else?
Aug 14 '08 #1
6 9963
On Aug 14, 2:18*pm, osnot <davidos...@not.netwrote:
Looking at the php manual site, I don't see where php
supports memory mapped file IO.
Is that right? Or are mmap and munmap called something else?
Even if it had memory mapped file I/O, how would you access the
memory?

C and PHP are on different levels altogether. Use fread() or
file_get_contents() to read a file. Why would you want mmap()?
Aug 14 '08 #2
Sjoerd wrote:
On Aug 14, 2:18 pm, osnot <davidos...@not.netwrote:
>Looking at the php manual site, I don't see where php
supports memory mapped file IO.
Is that right? Or are mmap and munmap called something else?

Even if it had memory mapped file I/O, how would you access the
memory?

C and PHP are on different levels altogether. Use fread() or
file_get_contents() to read a file. Why would you want mmap()?
....."The primary benefit of memory mapping a file is increased I/O
performance, especially when used on small files. Accessing memory
mapped files is faster than using direct read and write operations for
two reasons."
Aug 14 '08 #3
On Aug 14, 3:14*pm, osnot <davidos...@not.netwrote:
...."The primary benefit of memory mapping a file is increased I/O
performance, especially when used on small files. Accessing memory
mapped files is faster than using direct read and write operations for
two reasons."
Maybe you can tell us about your performance problem, so that we can
offer suggestions to increase performance with methods that are
available in PHP.
Aug 14 '08 #4
osnot wrote:
Sjoerd wrote:
>On Aug 14, 2:18 pm, osnot <davidos...@not.netwrote:
>>Looking at the php manual site, I don't see where php
supports memory mapped file IO.
Is that right? Or are mmap and munmap called something else?

Even if it had memory mapped file I/O, how would you access the
memory?

C and PHP are on different levels altogether. Use fread() or
file_get_contents() to read a file. Why would you want mmap()?

...."The primary benefit of memory mapping a file is increased I/O
performance, especially when used on small files. Accessing memory
mapped files is faster than using direct read and write operations for
two reasons."
Chances are if the data are used often enough, they'll already be in
memory (the OS's file system cache). And if they're used less often,
they'll be taking up memory all the time (a minimum 4K per file, even if
it's only a 2 byte file). In this case, while access to the data itself
would be faster, not being able to use the memory for other things could
actually slow system performance.

In over 20 years of C programming, I've seldom found a good use for
memory mapped files. And most of the uses I've seen are unnecessary.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Aug 14 '08 #5
Sjoerd wrote:
On Aug 14, 3:14 pm, osnot <davidos...@not.netwrote:
>...."The primary benefit of memory mapping a file is increased I/O
performance, especially when used on small files. Accessing memory
mapped files is faster than using direct read and write operations for
two reasons."

Maybe you can tell us about your performance problem, so that we can
offer suggestions to increase performance with methods that are
available in PHP.
....I had a vague, fuzzy idea about how to handle interative manipulation
of a file. I thought I'd mmap it once, manipulate it many times, and
then write it out to disk only at the end of a long series of
manipulations. But the more I think about it, the less I like that idea
anyway. I get these ideas sometimes--they pop up like weeds, and then
go away. Sometimes they turn into flowers. But usually not.
Aug 14 '08 #6
osnot wrote:
Looking at the php manual site, I don't see where php
supports memory mapped file IO.
PHP supports it since 5.1.* with 'php://memory' Stream.

e.G.: fopen('php://memory', 'wb')

PHP-Manual contains a description for it. see here ↓

PHP input/output streams:
http://de.php.net/wrappers.php

So long, Ulf
Aug 14 '08 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Hao Xu | last post by:
Hi everyone! I found that if you want to write to the memory got by mmap(), you have to get the file descriptor for mmap() in O_RDWR mode. If you got the file descriptor in O_WRONLY mode, then...
1
by: Hao Xu | last post by:
Hi everyone! I found that if you want to write to the memory got by mmap(), you have to get the file descriptor for mmap() in O_RDWR mode. If you got the file descriptor in O_WRONLY mode, then...
2
by: sr | last post by:
I have this kind of a code. It is from a book Linux programming, unleashed. I am not able to make to work so that, when it is run in two different xterm windows, the two different processes would...
4
by: Fabiano Sidler | last post by:
Hi folks! I created an mmap object like so: --- snip --- from mmap import mmap,MAP_ANONYMOUS,MAP_PRIVATE fl = file('/dev/zero','rw') mm = mmap(fl.fileno(), 1, MAP_PRIVATE|MAP_ANONYMOUS) ---...
1
by: James T. Dennis | last post by:
I've been thinking about the Python mmap module quite a bit during the last couple of days. Sadly most of it has just been thinking ... and reading pages from Google searches ... and very little...
1
by: koara | last post by:
Hello all, i am using the mmap module (python2.4) to access contents of a file. My question regards the relative performance of mmap.seek() vs mmap.tell(). I have a generator that returns...
2
by: Neal Becker | last post by:
On linux, I don't understand why: f = open ('/dev/eos', 'rw') m = mmap.mmap(f.fileno(), 1000000, prot=mmap.PROT_READ|mmap.PROT_WRITE, flags=mmap.MAP_SHARED) gives 'permission denied', but...
0
by: Kris Kennaway | last post by:
If I do the following: def mmap_search(f, string): fh = file(f) mm = mmap.mmap(fh.fileno(), 0, mmap.MAP_SHARED, mmap.PROT_READ) return mm.find(string) def mmap_is_in(f, string): fh =...
0
by: Gabriel Genellina | last post by:
En Thu, 29 May 2008 19:17:05 -0300, Kris Kennaway <kris@FreeBSD.org> escribió: Looks like you should define the sq_contains member in mmap_as_sequence, and the type should have the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.