📄 node61.html
字号:
<html><!DOCTYPE HTML PUBLIC "-//W3O//DTD W3 HTML 2.0//EN">
<!Converted with LaTeX2HTML 95.1 (Fri Jan 20 1995) by Nikos Drakos (nikos@cbl.leeds.ac.uk), CBLU, University of Leeds >
<HEAD>
<TITLE>5.10 Performance Issues</TITLE>
</HEAD>
<BODY>
<meta name="description" value="5.10 Performance Issues">
<meta name="keywords" value="book">
<meta name="resource-type" value="document">
<meta name="distribution" value="global">
<P>
<BR> <HR><a href="msgs0.htm#2" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/tppmsgs/msgs0.htm#2"><img ALIGN=MIDDLE src="asm_color_tiny.gif" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/asm_color_tiny.gif" alt="[DBPP]"></a> <A NAME=tex2html2667 HREF="node60.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node60.html"><IMG ALIGN=MIDDLE ALT="previous" SRC="previous_motif.gif" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/previous_motif.gif"></A> <A NAME=tex2html2675 HREF="node62.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node62.html"><IMG ALIGN=MIDDLE ALT="next" SRC="next_motif.gif" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/next_motif.gif"></A> <A NAME=tex2html2673 HREF="node51.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node51.html"><IMG ALIGN=MIDDLE ALT="up" SRC="up_motif.gif" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/up_motif.gif"></A> <A NAME=tex2html2677 HREF="node1.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node1.html"><IMG ALIGN=MIDDLE ALT="contents" SRC="contents_motif.gif" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/contents_motif.gif"></A> <A NAME=tex2html2678 HREF="node133.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node133.html"><IMG ALIGN=MIDDLE ALT="index" SRC="index_motif.gif" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/index_motif.gif"></A> <a href="msgs0.htm#3" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/tppmsgs/msgs0.htm#3"><img ALIGN=MIDDLE src="search_motif.gif" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/search_motif.gif" alt="[Search]"></a> <BR>
<B> Next:</B> <A NAME=tex2html2676 HREF="node62.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node62.html">5.11 Case Study: Channel Library</A>
<B>Up:</B> <A NAME=tex2html2674 HREF="node51.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node51.html">5 Compositional C++
</A>
<B> Previous:</B> <A NAME=tex2html2668 HREF="node60.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node60.html">5.9 Modularity</A>
<BR><HR><P>
<H1><A NAME=SECTION032100000000000000000>5.10 Performance Issues</A></H1>
<P>
<A NAME=secccperf> </A>
<P>
CC++
programs do not explicitly send and receive messages, but instead
<A NAME=7640> </A>
perform read and write operations on global pointers; make remote
<A NAME=7641> </A>
procedure calls; and use <tt> par</tt>, <tt> parfor</tt>, and <tt> spawn</tt>
statements to create new threads of control. Nevertheless, the
communication operations associated with a CC++
program can usually
be determined easily. Normally, a read operation on a global pointer,
a write operation on a global pointer, or an RPC all result in two
communications: one to send the remote request and one to receive an
acknowledgment or result. As noted in Chapter <A HREF="node26.html#chapperf" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node26.html#chapperf">3</A>, the
cost of each message can be specified with reasonable accuracy in
terms of a startup cost and a per-word cost. It is necessary to
distinguish between the communication costs incurred when
communicating CC++
processes are located on different processors
(<em> interprocessor
</em> communication) or on the same processor
(<em> intraprocessor
</em> communication). Both these costs can
depend significantly on implementation technology. Typically,
interprocessor communication costs are similar to those in
Table <A HREF="node29.html#tabmach" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node29.html#tabmach">3.1</A> in Chapter <A HREF="node26.html#chapperf" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node26.html#chapperf">3</A>, and intraprocessor
communication is cheaper. However, on some multicomputers with fast
interprocessor communication and relatively low memory bandwidth,
intraprocessor communication can actually be slower than
interprocessor communication.
<P>
The following issues must also be considered when examining the
performance of CC++
programs.
<P>
<A NAME=7651> </A>
<em> Reading and writing global pointers.</em> Reading or writing a global
pointer normally involves two communications: one to send the read or
write request, and one to return a result and/or signal completion.
Hence, global pointers must be used with caution, particularly on
computers where communication is expensive. If a data structure is
referenced often, it may be worthwhile to move that data structure to
where it is used most often, or to replicate it. If a task requires
many data items from the same processor object, it may be better to
use an RPC to transfer all the required data in a single message.
<P>
<em> Remote procedure calls.</em> An RPC normally involves two
communications: the first to transmit the procedure call
<A NAME=7655> </A>
and its data to the remote processor, and the second to signal
completion and to return any result. In many situations, the return
message is not required and hence represents overhead. This overhead
can be avoided by using the <tt> spawn</tt> statement to create an
asynchronous thread of control. For example, the performance of the
following code from Program <A HREF="node62.html#progccq" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node62.html#progccq">5.15</A> below, which sends a value
on a channel,
<P>
<PRE>void send(int val) { inport->enqueue(val); }
</PRE>
<P>
can be improved in cases where one does not care when the send
operation completes, by rewriting it to eliminate the reply, as
follows.
<P>
<PRE>void send(int val) { spawn inport->enqueue(val); }
</PRE>
<P>
<em> Fairness.</em> When two or more threads execute in the same processor
object, CC++
guarantees that execution is fair: that is, that no
<A NAME=7679> </A>
thread that is not blocked waiting for data will be prevented
indefinitely from executing. However, the time that a thread waits
before executing can vary significantly depending on characteristics
of both the application and a particular CC++
implementation.
Hence, care must be taken if application performance depends on
obtaining timely responses to remote requests.
<P>
<em> Remote operations.</em> As a general principle, operations involving
<tt> global</tt> objects (processor object creation, RPC, etc.) are more
expensive than operations involving only local objects. However, the
cost of these operations can vary significantly from
machine to machine. An RPC is typically less expensive than a
processor object creation, and a remote read or write operation is
typically less expensive than an RPC. The first processor object
creation on a processor is often significantly more expensive than
subsequent processor object creation operations on the same processor.
<P>
<em> Compiler optimization.</em> Because CC++
is a programming language
<A NAME=7685> </A>
rather than a library, a compiler may in some situations be able to
<A NAME=7686> </A>
reduce communication costs by eliminating replies, coalescing
messages, or otherwise reorganizing a program to improve performance.
<P>
<BR> <HR><a href="msgs0.htm#2" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/tppmsgs/msgs0.htm#2"><img ALIGN=MIDDLE src="asm_color_tiny.gif" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/asm_color_tiny.gif" alt="[DBPP]"></a> <A NAME=tex2html2667 HREF="node60.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node60.html"><IMG ALIGN=MIDDLE ALT="previous" SRC="previous_motif.gif" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/previous_motif.gif"></A> <A NAME=tex2html2675 HREF="node62.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node62.html"><IMG ALIGN=MIDDLE ALT="next" SRC="next_motif.gif" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/next_motif.gif"></A> <A NAME=tex2html2673 HREF="node51.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node51.html"><IMG ALIGN=MIDDLE ALT="up" SRC="up_motif.gif" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/up_motif.gif"></A> <A NAME=tex2html2677 HREF="node1.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node1.html"><IMG ALIGN=MIDDLE ALT="contents" SRC="contents_motif.gif" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/contents_motif.gif"></A> <A NAME=tex2html2678 HREF="node133.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node133.html"><IMG ALIGN=MIDDLE ALT="index" SRC="index_motif.gif" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/index_motif.gif"></A> <a href="msgs0.htm#3" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/tppmsgs/msgs0.htm#3"><img ALIGN=MIDDLE src="search_motif.gif" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/search_motif.gif" alt="[Search]"></a> <BR>
<B> Next:</B> <A NAME=tex2html2676 HREF="node62.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node62.html">5.11 Case Study: Channel Library</A>
<B>Up:</B> <A NAME=tex2html2674 HREF="node51.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node51.html">5 Compositional C++
</A>
<B> Previous:</B> <A NAME=tex2html2668 HREF="node60.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node60.html">5.9 Modularity</A>
<BR><HR><P>
<P><ADDRESS>
<I>© Copyright 1995 by <A href="msgs0.htm#6" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/tppmsgs/msgs0.htm#6">Ian Foster</a></I>
</ADDRESS>
</BODY>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -