473,396 Members | 2,039 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,396 software developers and data experts.

Linux, Perl, and Memory problem

I'm not sure whether this question belongs entirely here or in a perl
group--but probably it requires knowledge of both.

I've written a perl module, currently in use, which does asynchronous
searches of library databases anywhere in the world. It forks off a
separate process for each database which it contacts. In the past
I've had it search successfuly through more than 1000 databases,
reporting back one one record from each.

The processes are forked out 5 at a time, every 25 seconds. The
forked processes are controlled by Event timers, so that they time
out after 20 seconds, if they can't connect to the server they are
supposed to query. But if they do connect, they are left in play.
This means that a backlog of forked processes cand build up while
waiting to get the records they've requested, especially when querying
large numbers.

Each record averages about 1k . There is, in addition, about 5k
overhead for each forked process. Recently, I've wanted to use this
module to again query upwards of 1000 databases but to bring back
between 10 and 25 records. So, we now have as much as 30k devoted to
each forked process. The result was a great deal of disk thrashing
and repeated reports to the terminal from the operating system that it
it was out of memory and had killed one of the forked processes.
During this time the terminal was essentially locked and wouldn't
respond to the keyboard, so there was nothing I could do but wait or
reboot. The disk thrashing I assuming was a sign of memory swapping.
I tried to solve the problem by running a copy of top from the main
program before forking off each batch of 5 forked processes. I
examined the outupt from top to determined whether the main process
had gone above 60% of memory capacity. If so, I implement a 5 minute
timeout period. This worked like a charm. But when I looked at what
was really hapening, it turned out that the sleep period never had to
be set. Memory never exceeded about 5% of the total memory resources.

So, I thought, maybe it just needs the extra time between each batch
of 5 forks. Instead of using the call to top, I implemented a 60
second timeout between each batch of 5 forks. This was better than
nothing but there was nevertheless a significant memory drain and
eventually the terminal froze. By using the ps command I could see
that there was a huge backlog of forked processes in memory--this was
not the case when I used top. And the access to top took only 6
seconds.

So, it seems that there something soothing to the operating system in
running the external program--top--which has nothing to do with giving
the system more time to processes the forks.

Myron Turner
www.room535.org
Jul 19 '05 #1
3 2729
On Mon, 22 Mar 2004 16:11:10 GMT, mt*****@ms.umanitoba.ca (Myron
Turner) wrote:
Sorry, I left of the last point-which is that I'd like to know what is
happening here so that I can address the problem without just blindly
insert a call to linux's top command between each 5 forked processes.

Myron Turner
www.room535.org
Jul 19 '05 #2
Myron Turner wrote:
By using the ps command I could see
that there was a huge backlog of forked processes in memory


You've clearly got a logic-flow error; too may process are being
created all at once. Fix that first.

Try outputting debugging messages before and after each fork.

warn "Process $$ about to fork\n";
$child_pid = fork();
if ($child_pid) {
warn "Parent process $$ created child $child_pid\n";
} else {
warn "New child process $$ created\n";
}

Check the messages going to STDERR to verify that the expected
number of child processes are being created in the proper order.
-Joe

P.S. Please post to comp.lang.perl.misc next time.
Jul 19 '05 #3
On Mon, 22 Mar 2004 20:26:38 GMT, Joe Smith <Jo*******@inwap.com>
wrote:
Myron Turner wrote:
By using the ps command I could see
that there was a huge backlog of forked processes in memory


You've clearly got a logic-flow error; too may process are being
created all at once. Fix that first.

That wasn't the case. I was able to fix the problem by monitoring
disk activity and allowing the user to tailor throughput to his/her
own memory resources.

Myron Turner
Myron Turner
www.room535.org
Jul 19 '05 #4

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

Similar topics

9
by: I Report, You Decide | last post by:
A hosting service lungcapage has banned yabb, because it takes too much CPU/memory, but phpBB is fine. Is that perl/php or the script itself? why perl sucks more resource of a server than php? i...
2
by: bouchia.nazha | last post by:
Hello I have encountered a problem using tomcat, linux and ssl. My problem seem to be a JVM memory deallocation problem on Linux. This is my configuration: OS: Redhat7.2 Tomcat: 4.0 Jdk:...
1
by: J-miami | last post by:
I am just starting to learn Perl. I had an idea that there should be free open-source Internet Cafe management software for Linux. I searched around online but couldn't find anything. The...
4
by: Jonah Olsson | last post by:
Dear All, I'm currently developing a solution where large amounts of personalised emails are being created (and no, this is not spam...) on the ASP.NET platform and being delivered by a Debian...
10
by: stylecomputers | last post by:
Hey guys, I am absolutely new to Linux programming, with no w######s programming experience except a small amount of C++ console apps. Reasonably new to Linux, BSD etc, got good sound networking...
9
by: 8anos | last post by:
Hello, I am new at the community and newbie at programming :) As you may know rapidshare provides a perl script for linux, to upload files at their servers. You can find the original scripts at...
6
by: surfivor | last post by:
I may be involved in a data migration project involving databases and creating XML feeds. Our site is PHP based, so I imagine the team might suggest PHP, but I had a look at the PHP documentation...
4
by: skyy | last post by:
Hi anybody got tried installing perl in arm-linux? installed perl 5.8.8 on arm-linux and i got some problem running it. command such as perl -V perl -e "use strict" gives me error such...
0
by: xiangni330 | last post by:
Hi anybody got tried installing perl in arm-linux? installed perl 5.8.8 on arm-linux and i got some problem running it. command such as perl -V perl -e "use strict" gives me error such...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.