⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 3.t

📁 早期freebsd实现
💻 T
📖 第 1 页 / 共 2 页
字号:
.\" Copyright (c) 1985 The Regents of the University of California..\" All rights reserved..\".\" Redistribution and use in source and binary forms, with or without.\" modification, are permitted provided that the following conditions.\" are met:.\" 1. Redistributions of source code must retain the above copyright.\"    notice, this list of conditions and the following disclaimer..\" 2. Redistributions in binary form must reproduce the above copyright.\"    notice, this list of conditions and the following disclaimer in the.\"    documentation and/or other materials provided with the distribution..\" 3. All advertising materials mentioning features or use of this software.\"    must display the following acknowledgement:.\"	This product includes software developed by the University of.\"	California, Berkeley and its contributors..\" 4. Neither the name of the University nor the names of its contributors.\"    may be used to endorse or promote products derived from this software.\"    without specific prior written permission..\".\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION).\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF.\" SUCH DAMAGE..\".\"	@(#)3.t	5.1 (Berkeley) 4/17/91.\".ds RH Results of our observations.NHResults of our observations.PPWhen 4.2BSD was first installed on several large timesharing systemsthe degradation in performance was significant.Informal measurements showed 4.2BSD providing 80% of the throughputof 4.1BSD (based on load averages observed under a normal timesharing load).Many of the initial problems found were because of programs that werenot part of 4.1BSD.  Using the techniques described in the previoussection and standard process profiling several problems were identified.Later work concentrated on the operation of the kernel itself.In this section we discuss the problems uncovered;  in the nextsection we describe the changes made to the system..NH 2User programs.PP.NH 3Mail system		.PPThe mail system was the first culprit identified as a majorcontributor to the degradation in system performance.At Lucasfilm the mail system is heavily usedon one machine, a VAX-11/780 with eight megabytes of memory.\**.FS\** During part of these observations the machine had only fourmegabytes of memory..FEMessagetraffic is usually between users on the same machine and ranges fromperson-to-person telephone messages to per-organization distributionlists.  After conversion to 4.2BSD, it wasimmediately noticed that mail to distribution lists of 20 or more peoplecaused the system load to jump by anywhere from 3 to 6 points.The number of processes spawned by the \fIsendmail\fP program andthe messages sent from \fIsendmail\fP to the system loggingprocess, \fIsyslog\fP, generated significant load both from theirexecution and their interference with basic system operation.  Thenumber of context switches and disk transfers often doubled while\fIsendmail\fP operated; the system call rate jumped dramatically.System accounting information consistentlyshowed \fIsendmail\fP as the top cpu user on the system..NH 3Network servers.PPThe network services provided in 4.2BSD add new capabilities to the system,but are not without cost.  The system uses one daemon process to acceptrequests for each network service provided.  The presence of manysuch daemons increases the numbers of active processes and files,and requires a larger configuration to support the same number of users.The overhead of the routing and status updates can consumeseveral percent of the cpu.Remote logins and shells incur more overheadthan their local equivalents.For example, a remote login uses three processes and apseudo-terminal handler in addition to the local hardware terminalhandler.  When using a screen editor, sending and echoing a singlecharacter involves four processes on two machines.The additional processes, context switching, network traffic, andterminal handler overhead can roughly triple the load presented by onelocal terminal user..NH 2System overhead.PPTo measure the costs of various functions in the kernel,a profiling system was run for a 17 hourperiod on one of our general timesharing machines.While this is not as reproducible as a synthetic workload,it certainly represents a realistic test.This test was run on several occasions over a three month period.Despite the long period of time that elapsedbetween the test runs the shape of the profiles,as measured by the number of times each system callentry point was called, were remarkably similar..PPThese profiles turned up several bottlenecks that arediscussed in the next section.Several of these were new to 4.2BSD,but most were caused by overloading of mechanismswhich worked acceptably well in previous BSD systems.The general conclusion from our measurements was thatthe ratio of user to system time had increased from45% system / 55% user in 4.1BSD to 57% system / 43% userin 4.2BSD..NH 3Micro-operation benchmarks.PPTo compare certain basic system operationsbetween 4.1BSD and 4.2BSD a suite of benchmarkprograms was constructed and run on a VAX-11/750 with 4.5 megabytesof physical memory and two disks on a MASSBUS controller.Tests were run with the machine operating in single user modeunder both 4.1BSD and 4.2BSD.   Paging was localized to the drivewhere the root file system was located..PPThe benchmark programs were modeled after the Kashtan benchmarks,[Kashtan80], with identical sources compiled under each system.The programs and their intended purpose are described brieflybefore the presentation of the results.  The benchmark scriptswere run twice with the results shown as the average ofthe two runs.The source code for each program and the shell scripts used duringthe benchmarks are included in the Appendix..PPThe set of tests shown in Table 1 was concerned withsystem operations other than paging.  The intent of mostbenchmarks is clear.  The result of running \fIsignocsw\fP isdeducted from the \fIcsw\fP benchmark to calculate the contextswitch overhead.  The \fIexec\fP tests use two different jobs to gaugethe cost of overlaying a larger program with a smaller oneand vice versa.  The``null job'' and ``big job'' differ solely in the size of their datasegments, 1 kilobyte versus 256 kilobytes.  In both cases thetext segment of the parent is larger than that of the child.\**.FS\** These tests should also have measured the cost of expanding thetext segment; unfortunately time did not permit running additional tests..FEAll programs were compiled into the default load format that causesthe text segment to be demand paged out of the file system and sharedbetween processes..KF.DS L.TScenter box;l | l.Test	Description_syscall	perform 100,000 \fIgetpid\fP system callscsw	perform 10,000 context switches using signalssignocsw	send 10,000 signals to yourselfpipeself4	send 10,000 4-byte messages to yourselfpipeself512	send 10,000 512-byte messages to yourselfpipediscard4	send 10,000 4-byte messages to child who discardspipediscard512	send 10,000 512-byte messages to child who discardspipeback4	exchange 10,000 4-byte messages with childpipeback512	exchange 10,000 512-byte messages with childforks0	fork-exit-wait 1,000 timesforks1k	sbrk(1024), fault page, fork-exit-wait 1,000 timesforks100k	sbrk(102400), fault pages, fork-exit-wait 1,000 timesvforks0	vfork-exit-wait 1,000 timesvforks1k	sbrk(1024), fault page, vfork-exit-wait 1,000 timesvforks100k	sbrk(102400), fault pages, vfork-exit-wait 1,000 timesexecs0null	fork-exec ``null job''-exit-wait 1,000 timesexecs0null (1K env)	execs0null above, with 1K environment addedexecs1knull	sbrk(1024), fault page, fork-exec ``null job''-exit-wait 1,000 timesexecs1knull (1K env)	execs1knull above, with 1K environment addedexecs100knull	sbrk(102400), fault pages, fork-exec ``null job''-exit-wait 1,000 timesvexecs0null	vfork-exec ``null job''-exit-wait 1,000 timesvexecs1knull	sbrk(1024), fault page, vfork-exec ``null job''-exit-wait 1,000 timesvexecs100knull	sbrk(102400), fault pages, vfork-exec ``null job''-exit-wait 1,000 timesexecs0big	fork-exec ``big job''-exit-wait 1,000 timesexecs1kbig	sbrk(1024), fault page, fork-exec ``big job''-exit-wait 1,000 timesexecs100kbig	sbrk(102400), fault pages, fork-exec ``big job''-exit-wait 1,000 timesvexecs0big	vfork-exec ``big job''-exit-wait 1,000 timesvexecs1kbig	sbrk(1024), fault pages, vfork-exec ``big job''-exit-wait 1,000 timesvexecs100kbig	sbrk(102400), fault pages, vfork-exec ``big job''-exit-wait 1,000 times.TE.ceTable 1. Kernel Benchmark programs..DE.KE.PPThe results of these tests are shown in Table 2.  If the 4.1BSD resultsare scaled to reflect their being run on a VAX-11/750, theycorrespond closely to those found in [Joy80].\**.FS\** We assume that a VAX-11/750 runs at 60% of the speed of a VAX-11/780(not considering floating point operations)..FE.KF.DS L.TScenter box;c s s s s s s s s sc || c s s || c s s || c s sc || c s s || c s s || c s sc || c | c | c || c | c | c || c | c | cl || n | n | n || n | n | n || n | n | n.Berkeley Software Distribution UNIX Systems_Test	Elapsed Time	User Time	System Time\^	_	_	_\^	4.1	4.2	4.3	4.1	4.2	4.3	4.1	4.2	4.3=syscall	28.0	29.0	23.0	4.5	5.3	3.5	23.9	23.7	20.4csw	45.0	60.0	45.0	3.5	4.3	3.3	19.5	25.4	19.0signocsw	16.5	23.0	16.0	1.9	3.0	1.1	14.6	20.1	15.2pipeself4	21.5	29.0	26.0	1.1	1.1	0.8	20.1	28.0	25.6pipeself512	47.5	59.0	55.0	1.2	1.2	1.0	46.1	58.3	54.2pipediscard4	32.0	42.0	36.0	3.2	3.7	3.0	15.5	18.8	15.6pipediscard512	61.0	76.0	69.0	3.1	2.1	2.0	29.7	36.4	33.2pipeback4	57.0	75.0	66.0	2.9	3.2	3.3	25.1	34.2	29.7pipeback512	110.0	138.0	125.0	3.1	3.4	2.2	52.2	65.7	57.7forks0	37.5	41.0	22.0	0.5	0.3	0.3	34.5	37.6	21.5forks1k	40.0	43.0	22.0	0.4	0.3	0.3	36.0	38.8	21.6forks100k	217.5	223.0	176.0	0.7	0.6	0.4	214.3	218.4	175.2vforks0	34.5	37.0	22.0	0.5	0.6	0.5	27.3	28.5	17.9vforks1k	35.0	37.0	22.0	0.6	0.8	0.5	27.2	28.6	17.9vforks100k	35.0	37.0	22.0	0.6	0.8	0.6	27.6	28.9	17.9execs0null	97.5	92.0	66.0	3.8	2.4	0.6	68.7	82.5	48.6execs0null (1K env)	197.0	229.0	75.0	4.1	2.6	0.9	167.8	212.3	62.6execs1knull	99.0	100.0	66.0	4.1	1.9	0.6	70.5	86.8	48.7execs1knull (1K env)	199.0	230.0	75.0	4.2	2.6	0.7	170.4	214.9	62.7execs100knull	283.5	278.0	216.0	4.8	2.8	1.1	251.9	269.3	202.0vexecs0null	100.0	92.0	66.0	5.1	2.7	1.1	63.7	76.8	45.1vexecs1knull	100.0	91.0	66.0	5.2	2.8	1.1	63.2	77.1	45.1vexecs100knull	100.0	92.0	66.0	5.1	3.0	1.1	64.0	77.7	45.6execs0big	129.0	201.0	101.0	4.0	3.0	1.0	102.6	153.5	92.7execs1kbig	130.0	202.0	101.0	3.7	3.0	1.0	104.7	155.5	93.0execs100kbig	318.0	385.0	263.0	4.8	3.1	1.1	286.6	339.1	247.9vexecs0big	128.0	200.0	101.0	4.6	3.5	1.6	98.5	149.6	90.4vexecs1kbig	125.0	200.0	101.0	4.7	3.5	1.3	98.9	149.3	88.6vexecs100kbig	126.0	200.0	101.0	4.2	3.4	1.3	99.5	151.0	89.0.TE.ceTable 2. Kernel Benchmark results (all times in seconds)..DE.KE.PPIn studying the measurements we found that the basic system calland context switch overhead did not change significantlybetween 4.1BSD and 4.2BSD.  The \fIsignocsw\fP results were caused bythe changes to the \fIsignal\fP interface, resultingin an additional subroutine invocation for each call, notto mention additional complexity in the system's implementation..PPThe times for the use of pipes are significantly higher under4.2BSD because of their implementation on top of the interprocesscommunication facilities.  Under 4.1BSD pipes were implementedwithout the complexity of the socket data structures and withsimpler code.  Further, while not obviously a factor here,4.2BSD pipes have less system buffer space provided them than4.1BSD pipes..PPThe \fIexec\fP tests shown in Table 2 were performed with 34 bytes ofenvironment information under 4.1BSD and 40 bytes under 4.2BSD.To figure the cost of passing data through the environment,the execs0null and execs1knull tests were rerun with1065 additional bytes of data.  The results are show in Table 3..KF.DS L.TScenter box;c || c s || c s || c sc || c s || c s || c sc || c | c || c | c || c | cl || n | n || n | n || n | n.Test	Real	User	System\^	_	_	_\^	4.1	4.2	4.1	4.2	4.1	4.2=execs0null	197.0	229.0	4.1	2.6	167.8	212.3execs1knull	199.0	230.0	4.2	2.6	170.4	214.9.TE.ceTable 3. Benchmark results with ``large'' environment (all times in seconds)..DE.KEThese results show that passing argument data is significantlyslower than under 4.1BSD: 121 ms/byte versus 93 ms/byte.  Even usingthis factor to adjust the basic overhead of an \fIexec\fP systemcall, this facility is more costly under 4.2BSD than under 4.1BSD..NH 3Path name translation.PPThe single most expensive function performed by the kernelis path name translation.This has been true in almost every UNIX kernel [Mosher80];we find that our general time sharing systems do about500,000 name translations per day..PPName translations became more expensive in 4.2BSD for several reasons.The single most expensive addition was the symbolic link.Symbolic linkshave the effect of increasing the average number of componentsin path names to be translated.As an insidious example,consider the system manager that decides to change /tmpto be a symbolic link to /usr/tmp.A name such as /tmp/tmp1234 that previously required two componenttranslations,now requires four component translations plus the cost of reading the contents of the symbolic link..PPThe new directory format also changes the characteristics ofname translation.The more complex format requires more computation to determinewhere to place new entries in a directory.Conversely the additional information allows the system to onlylook at active entries when searching,hence searches of directories that had once grown largebut currently have few active entries are checked quickly.The new format also stores the length of each name so thatcostly string comparisons are only done on names that are thesame length as the name being sought..PPThe net effect of the changes is that the average time totranslate a path name in 4.2BSD is 24.2 milliseconds,representing 40% of the time processing system calls,that is 19% of the total cycles in the kernel,or 11% of all cycles executed on the machine.The times are shown in Table 4.  We have no comparable timesfor \fInamei\fP under 4.1 though they are certain tobe significantly less..KF.DS L.TScenter box;l r r.part	time	% of kernel_self	14.3 ms/call	11.3%child	9.9 ms/call	7.9%_

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -