473,396 Members | 1,864 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.

about pollsys and dtrace.

I have a single-threading implemented program (written by somebody else). In this program, one server listens and accepts connection set up request from multiple clients, puts client information in data base, and provides this information to other processes.

Here is the problem: although the tasks the server are doing are very simple (as I just mentioned), the CPU of the server was quickly used up when the number of clients goes up. My task is to find out if the program has some bugs which leads to the CPU exhaustion; or if some implementation of the program is not efficient.

By using dtrace, I found most of the CPU was consumed by the following system calls: pollsys, recvfrom, sendto. I know the recvfrom, sendto are used to receive data from remote clients and send data to clients, but I am not familiar with pollsys and did not find enough information from internet. It seems like The pollsys syscall is normally used
for checking whether there is any data that can be read from or write to a file descriptor. Then how do I know who call pollsys and in which case the pollsys is called. Is it called periodically or called by signal interrupt, or due to some events?

I am a newbi in unix and its tracing tools. I wonder if anybody can answer my questions and also give me some suggestion like how to narrow down my focus and dig out the reason of the problem.

Thanks.
Feb 18 '08 #1
6 8944
gpraghuram
1,275 Expert 1GB
Its better to use select call instead of pollsys.
Try using select


Raghuram
Feb 18 '08 #2
but I saw a select() call with a timeout was included in a while loop.

Do you mean pollsys will not be called if select() mode is used?

Thanks.
Feb 19 '08 #3
gpraghuram
1,275 Expert 1GB
but I saw a select() call with a timeout was included in a while loop.

Do you mean pollsys will not be called if select() mode is used?

Thanks.
select calls last parameter is the timeout value.
I dont think so that pollsys will be called inside select.


Raghuram
Feb 19 '08 #4
Since I found pollsys consumed most of the CPU, I want to see in which case it is called. To do that, I now used truss -t pollsys -T pollsys -p PID, and pstack PID to see how is the pollsys called. Here is the result:
(I do not understand what lwp# /thread # mean,but it seems pollsys is called by select() and something else I do not understand).
What does it mean? Thanks.

----------------- lwp# 1 / thread# 1 --------------------
fffffd7ffe76e3ca pollsys (fffffd7fffdfb7f0, 16, fffffd7fffdfbaf0, 0)
fffffd7ffe718ee4 pselect () + 154
fffffd7ffe7191b2 select () + 72
000000000046918d inf_man () + 53d
000000000046dbf4 main () + 234
000000000044bdcc ???????? ()
----------------- lwp# 2 / thread# 2 --------------------
fffffd7ffe76d85a sigtimedwait (fffffd7ffe3fdd10, fffffd7ffe3fdd20, fffffd7ffe3fdea0)
fffffd7fff0e71c9 sigtimedwait () + 9
fffffd7fff095307 signalRun () + 87
fffffd7ffe76b47b _thr_setup () + 5b
fffffd7ffe76b6b0 _lwp_start ()
----------------- lwp# 3 / thread# 3 --------------------
fffffd7ffe76d79a nanosleep (fffffd7ffe1fdf90, fffffd7ffe1fdf80)
0000000000458dea events_poller () + 1a
fffffd7ffe76b47b _thr_setup () + 5b
fffffd7ffe76b6b0 _lwp_start ()
----------------- lwp# 4 / thread# 4 --------------------
fffffd7ffe76d79a nanosleep (fffffd7fea1fdf70, fffffd7fea1fdf60)
0000000000470a75 brand_data_poller () + c5
fffffd7ffe76b47b _thr_setup () + 5b
fffffd7ffe76b6b0 _lwp_start ()
----------------- lwp# 5 / thread# 5 --------------------
fffffd7ffe76e3ca pollsys (fffffd7fe9ff9d10, 1, 0, 0)
fffffd7ffe718ee4 pselect () + 154
fffffd7ffe7191b2 select () + 72
000000000044ca44 resp_service_req () + 1a4
fffffd7ffe76b47b _thr_setup () + 5b
fffffd7ffe76b6b0 _lwp_start ()
----------------- lwp# 6 / thread# 6 --------------------
fffffd7ffe76e3ca pollsys (fffffd7fe9df7db0, 1, 0, 0)
fffffd7ffe718ee4 pselect () + 154
fffffd7ffe7191b2 select () + 72
fffffd7fff2ede79 process_snmp_request () + a9
fffffd7ffe76b47b _thr_setup () + 5b
fffffd7ffe76b6b0 _lwp_start ()
----------------- lwp# 7 / thread# 7 --------------------
fffffd7ffe76e3ca pollsys (fffffd7fe9bf7db0, 1, 0, 0)
fffffd7ffe718ee4 pselect () + 154
fffffd7ffe7191b2 select () + 72
000000000048be9e process_licensing_request () + ae
fffffd7ffe76b47b _thr_setup () + 5b
fffffd7ffe76b6b0 _lwp_start ()
----------------- lwp# 8 / thread# 8 --------------------
fffffd7ffe76e3ca pollsys (66edb0, 24, fffffd7fe99fdf10, 0)
fffffd7ffe714822 poll () + 52
fffffd7ffeee50b0 PollerInvokePoll () + 30
fffffd7ffeee4f4b PollerStep () + 17b
fffffd7ffeee5a32 _RunnerStart () + 62
fffffd7ffe76b47b _thr_setup () + 5b
fffffd7ffe76b6b0 _lwp_start ()
Feb 19 '08 #5
gpraghuram
1,275 Expert 1GB
Since I found pollsys consumed most of the CPU, I want to see in which case it is called. To do that, I now used truss -t pollsys -T pollsys -p PID, and pstack PID to see how is the pollsys called. Here is the result:
(I do not understand what lwp# /thread # mean,but it seems pollsys is called by select() and something else I do not understand).
What does it mean? Thanks.

----------------- lwp# 1 / thread# 1 --------------------
fffffd7ffe76e3ca pollsys (fffffd7fffdfb7f0, 16, fffffd7fffdfbaf0, 0)
fffffd7ffe718ee4 pselect () + 154
fffffd7ffe7191b2 select () + 72
000000000046918d inf_man () + 53d
000000000046dbf4 main () + 234
000000000044bdcc ???????? ()
----------------- lwp# 2 / thread# 2 --------------------
fffffd7ffe76d85a sigtimedwait (fffffd7ffe3fdd10, fffffd7ffe3fdd20, fffffd7ffe3fdea0)
fffffd7fff0e71c9 sigtimedwait () + 9
fffffd7fff095307 signalRun () + 87
fffffd7ffe76b47b _thr_setup () + 5b
fffffd7ffe76b6b0 _lwp_start ()
----------------- lwp# 3 / thread# 3 --------------------
fffffd7ffe76d79a nanosleep (fffffd7ffe1fdf90, fffffd7ffe1fdf80)
0000000000458dea events_poller () + 1a
fffffd7ffe76b47b _thr_setup () + 5b
fffffd7ffe76b6b0 _lwp_start ()
----------------- lwp# 4 / thread# 4 --------------------
fffffd7ffe76d79a nanosleep (fffffd7fea1fdf70, fffffd7fea1fdf60)
0000000000470a75 brand_data_poller () + c5
fffffd7ffe76b47b _thr_setup () + 5b
fffffd7ffe76b6b0 _lwp_start ()
----------------- lwp# 5 / thread# 5 --------------------
fffffd7ffe76e3ca pollsys (fffffd7fe9ff9d10, 1, 0, 0)
fffffd7ffe718ee4 pselect () + 154
fffffd7ffe7191b2 select () + 72
000000000044ca44 resp_service_req () + 1a4
fffffd7ffe76b47b _thr_setup () + 5b
fffffd7ffe76b6b0 _lwp_start ()
----------------- lwp# 6 / thread# 6 --------------------
fffffd7ffe76e3ca pollsys (fffffd7fe9df7db0, 1, 0, 0)
fffffd7ffe718ee4 pselect () + 154
fffffd7ffe7191b2 select () + 72
fffffd7fff2ede79 process_snmp_request () + a9
fffffd7ffe76b47b _thr_setup () + 5b
fffffd7ffe76b6b0 _lwp_start ()
----------------- lwp# 7 / thread# 7 --------------------
fffffd7ffe76e3ca pollsys (fffffd7fe9bf7db0, 1, 0, 0)
fffffd7ffe718ee4 pselect () + 154
fffffd7ffe7191b2 select () + 72
000000000048be9e process_licensing_request () + ae
fffffd7ffe76b47b _thr_setup () + 5b
fffffd7ffe76b6b0 _lwp_start ()
----------------- lwp# 8 / thread# 8 --------------------
fffffd7ffe76e3ca pollsys (66edb0, 24, fffffd7fe99fdf10, 0)
fffffd7ffe714822 poll () + 52
fffffd7ffeee50b0 PollerInvokePoll () + 30
fffffd7ffeee4f4b PollerStep () + 17b
fffffd7ffeee5a32 _RunnerStart () + 62
fffffd7ffe76b47b _thr_setup () + 5b
fffffd7ffe76b6b0 _lwp_start ()
lwp means light-weight-process.
I havent debugged in this way.
Raghuram
Feb 19 '08 #6
The result showed that pollsys is called by select() and another user function.
From Beej's tutorial on socket programming, I learned that CPU exhaustion
due to polling can be avoided by using select() mode.
But here I saw that select() also use pollsys.
Feb 19 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: eScrewDotCom | last post by:
eScrew Welcome to eScrew! eScrew is eScrew and this is eScrew story. eScrew will tell you eScrew story if you promise eScrew to consider eScrew story as joke. eScrew story is very funny. eScrew...
220
by: Brandon J. Van Every | last post by:
What's better about Ruby than Python? I'm sure there's something. What is it? This is not a troll. I'm language shopping and I want people's answers. I don't know beans about Ruby or have...
8
by: eScrewDotCom | last post by:
eScrew Welcome to eScrew! eScrew is eScrew and this is eScrew story. eScrew will tell you eScrew story if you promise eScrew to consider eScrew story as joke. eScrew story is very funny. eScrew...
0
by: Grzegorz Dostatni | last post by:
I am wondering if there is anyone else as excited about Sun's dtrace as I am. Having seen it in action, and actually used it a couple of times I am really impressed. Still, this is not meant as...
77
by: nospam | last post by:
Reasons for a 3-tier achitecture for the WEB? (NOTE: I said, WEB, NOT WINDOWS. DON'T shoot your mouth off if you don't understand the difference.) I hear only one reason and that's to switch a...
125
by: Sarah Tanembaum | last post by:
Beside its an opensource and supported by community, what's the fundamental differences between PostgreSQL and those high-price commercial database (and some are bloated such as Oracle) from...
5
by: eScrewDotCom | last post by:
www.eScrew.com eScrew Welcome to eScrew! eScrew is eScrew and this is eScrew story. eScrew will tell you eScrew story if you promise eScrew to consider eScrew story as joke. eScrew story is...
0
by: eScrewDotCom | last post by:
eScrew Welcome to eScrew! eScrew is eScrew and this is eScrew story. eScrew will tell you eScrew story if you promise eScrew to consider eScrew story as joke. eScrew story is very funny. eScrew...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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,...

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.