US 6,647,441 B1Grant
Method of maximizing servicing capability of large numbers of I/O descriptors
Issue Date:2003-11-11
•13 Claims
•3 Drawing Sheets
Abstract
The present invention comprises an efficient and portable method and algorithm module for servicing large numbers of IO descriptors which may interface to a large network environment or to a large number of IO devices and services. The method and algorithm module queries those descriptors that are most likely to have activity, but also reliably queries all descriptors over time, and dynamically adjusts the frequency of queries to maintain maximum efficiency as conditions change. It also queries all descriptors within a reasonable time, and has minimal overhead and uses standard system interfaces.
Metadata
Assignee
- Hewlett-Packard Development Company, L.P.
Inventor
- Charles J. Courey, Jr.
Application Information
Application Number:US 09/663,061
Filing Date:2000-09-15
Priority Date:2000-09-15
Art Unit:7
Classifications
IPC:
G06F 300
Field of Search:
710 40710 41709103709105707 3707 2707 10
Patent Drawings (3 sheets)
Description
[0002] The present invention generally relates to computer software and more particularly to an improved method of efficiently servicing large numbers of simultaneous IO descriptors that are mapped to IO devices or services such as network interfaces or interprocess communication.
[0003] Software modules that must service large numbers of IO descriptors1at once traditionally query each descriptor and then process the descriptor if there are actions that can be performed. (In this regard, descriptors can be read from or written to and such actions are referred to as activity herein.) This approach is optimal if there is maximum activity (or close to maximum) on all descriptors or if not, descriptor queries are very fast. Servicing large numbers of descriptors efficiently becomes more challenging however if there is maximum activity on relatively few and querying a descriptor for activity takes a relatively significant period of time and resources.
[0004] A descriptor is generally defined as an integer, string or other small data value, which refers to one of several objects allocated to a program by the operating system, usually the kernel.
[0005] Traditionally, prior implementations have not had these concerns since PCs and workstations are extremely fast and have adequate resources. However, two things have recently changed, i.e., the Internet has made much larger numbers of independent IO (input/output) points much more likely and network connectivity is becoming a much larger part of the embedded systems environment. As a result, implementations must now address these developments in the form of utilizing an algorithm module that maximizes efficiency and portability.
[0006] More specifically, an efficient algorithm must attempt to query the descriptors that are likely to have activity more often than those that do not. This insures that expensive queries that are made will more often result in descriptor activity being encountered. It also means that time and resources that might otherwise be used to discover no activity on potentially large numbers of descriptors be made available for the processing of busy descriptors. It must also recognize when descriptors change in their activity level relatively quickly, i.e., if a particular descriptor begins to have increased activity, it must be queried more often and if activity decreases, it must be queried less often. This dynamic adjustment must be performed continually to maintain maximum efficiency regardless of changing conditions. The algorithm also must eventually (within a reasonable period of time) query all descriptors, regardless of activity to insure that there is no starvation (lack of servicing) among descriptors. Lastly, it must have relatively minimal overhead and use standard, well known system interfaces, which facilitate portability, rather than specialized ones.
Objects of the Invention
[0007] Accordingly, it is a primary object of the present invention to provide a method and algorithm module for servicing large numbers of IO descriptors which may include a large network environment that may include the Internet, which method and algorithm module achieves optimum efficiency and superior portability.
[0008] More particularly, it is an object of the present invention to provide an improved method and algorithm module which queries those descriptors that are most likely to have activity, but which also reliably queries all descriptors over time, and which dynamically adjusts the frequency of queries to optimize efficiency as conditions change, which results in faster movement of data through the system.
[0009] Yet another object of the present invention is to provide such an improved method and algorithm that can be used without significantly increasing overhead and without using specialized system interfaces.
[0010] Still another object of the present invention is to provide such an improved method and algorithm that can be easily installed and thereafter function as the interface between a software application and the standard IO interface facility known as select in a manner which does not require specialized help from the system environment or any conscious effort.
[0011] Other objects and advantages will be apparent from the following discussion in connection with the attached drawings.
Summary of the Invention
[0012] The present invention comprises an efficient and portable method and algorithm module for servicing large numbers of IO descriptors which may interface to a large network environment or to a large number of IO devices and services. The method and algorithm module queries those descriptors that are most likely to have activity, but also reliably queries all descriptors over time, and dynamically adjusts the relative frequency of queries of each descriptor to maintain maximum efficiency as conditions change.
[0013] To satisfy portability requirements, the algorithm module becomes the interface between the application code processing the IO and the standard select facility and associated macros. This module allows an application to manage several IO points efficiently without specialized help from the system environment and without requiring any modification of methodology.
Description of the Drawings
[0014] FIG. 1 is a table illustrating a number of priority select system calls that are used to replace standard system calls used to allow an application to simultaneously query multiple IO points.
[0015] FIG. 2 is a table illustrating a plurality of descriptors.
[0016] FIG. 3 is a priority array table.
[0017] FIG. 4 is a priority array table illustrating an example configuration.
[0018] FIG. 5 is a chart illustrating an iteration through a value array utilizing the example configuration shown in FIG. 4.
Detailed Description of the Preferred Embodiment
[0019] Broadly stated, the present invention comprises a method and algorithm module that efficiently and simultaneously services large numbers of IO descriptors. As previously stated, an efficient algorithm attempts to query descriptors that are likely to have activity, and dynamically adjusts to changing activity levels. It must also query all descriptors within a reasonable time, and it is desirable that it has minimal overhead and use standard system interfaces. As an example, the method and algorithm module of present invention can be used in a web server to communicate with dozens or even hundreds of computers on a network that may require data exchange. The module will interface the web server with the computers and operate to have the data exchange carried out quickly.
[0020] To successfully satisfy the previously discussed algorithmic requirements, a basic heuristic approach is necessary since it cannot be known whether a descriptor can have activity prior to querying it. If successive queries all show activity, then it is likely that the next query will also show activity. Conversely, if successive queries show no activity, then it is likely that the next query will also show no activity. Therefore, descriptors are grouped into priorities based on their previous activity, with each priority grouping having an upper and lower threshold. When consecutive positive queries on a descriptor reach the upper threshold, the descriptor is moved to the next higher priority until it is at the highest priority. Likewise, when consecutive negative queries on a descriptor reach the lower threshold, the descriptor is moved down in priority until it is at the lowest priority. Since there is constant dynamic adjustment, descriptors will migrate quickly to the appropriate priority for their activity level, even if that activity level is constantly changing.
[0021] Priority levels must determine directly the relative amount of times that a descriptor is queried. Since an IO task is driven by the activity on its descriptors, a driver loop of descriptor queries and resulting actions will insure that there are successive iterations of queries. The highest priority that a descriptor can have results in a query on that descriptor each time through this loop. Lower priorities determine the number of loops that must be iterated through between each query. Therefore, a descriptor with priority n will get queried every n times through this driver loop. In the highest priority case, n=1. All other priority values are determined relative to the highest priority case and can have any value n>1 meaning that priority value is inversely proportional to priority. A minimum priority (maximum n=N) must be insured for all descriptors to prevent starvation and this N value will determine the relative speed at which an inactive descriptor can react to new activity. The number of intermediate priorities ip (1<ip<N) determine the response to descriptors with both varying degrees of activity as well as the speed at which a descriptor can reach the highest or lowest priority. A system that attempts to maximize potential throughput across the busiest descriptors with less regard for immediate response to less active descriptors will use minimal intermediate priorities since they will result in more descriptor queries at the expense of throughput. Similarly, a higher N would query minimal activity descriptors less frequently, resulting in greater potential throughput on active descriptors. Some implementations however may choose to sacrifice a degree of maximum throughput to have a faster response to descriptors with moderate to minimal activity.
[0022] Since it is also possible that high priority descriptors may all cease to have activity, the algorithm must be careful not to block indefinitely until all descriptors have been queried. To prevent such blocking, it is preferred that the module allow for queries that wait for success on IO points for a determinate period of time called a time out. This causes the application/task making the query to suspend until either the time out period is reached, or activity occurs on one of the IO points queried. The time out values should be minimal for higher priorities and can change for lower priorities, but should not be infinite until the lowest priority is reached. It can then be maximum or infinite. Since high priority descriptors are likely to have activity anyway, the timeout can be very minimal. As priority decreases, the timeouts may increase or stay the same depending on the desired behavior. Longer timeouts may result in activity at higher priority levels as well as reduced migration to other priority levels and shorter timeouts may result in the lowest priority query being reached more quickly and greater opportunity for priority migration.
[0023] In the preferred embodiment discussed herein, queries are made to descriptors using the select system call. This call uses read and write masks well known to those of ordinary skill in the art to determine which descriptors to query. This call also takes a time out value that causes the select to return after the given time expires regardless of descriptor activity. The preferred embodiment implementation replaces all calls and supporting calls/macros for the system select facility with new calls and are shown in FIG. 1. The present invention works well with the BSD Socket interface, which is commonly used in large scale networks and in the Internet. The BSD Socket interface supports the TCP/IP protocol that is commonly used on the Internet. The masks are tracked internally to the implementation so only the descriptor number needs to be provided. There are four internal masks that are used:
[0024] readNow—filled with descriptors having the current priority or higher and is passed to the system select as the read mask.
[0025] writeNow—filled with descriptors having the current priority or higher and is passed to the system select as the write mask.
[0026] readLater—all descriptors set using Fd_ReadSet are tracked here.
[0027] writeLater—all descriptors set using Fd_WriteSet are tracked here.
[0028] When Fd13ReadSet/Fd_WriteSet is called with a descriptor, the priority is looked up and if its priority is at least as high as the current priority, it is placed in the readNow/writeNow mask. Regardless of priority, it is placed in the readLater/writeLater mask. When prioritySelect.Select is called, the readNow and writeNow masks are used with the timeout value for that priority. If the select at the current priority shows no activity, then the current priority drops to the next lower priority and the descriptors in the readLater/writeLater masks are examined. Any descriptors which have a priority as least as high as the new priority are then placed in the readNow/writeNow masks and another select is performed with the timeout value of the new priority. This continues until the lowest priority is reached and processed using select. At this point, if the timeout for the lowest priority is not infinite or activity is found, the prioritySelect.Select call returns.
[0029] There are additional internal data structure and operations that are used in the preferred embodiment. Referring to FIG. 2, this is a table of all the descriptors in use. However, it should be understood that other descriptors may be added to the table, and are within the scope of the present invention. When a descriptor is first created, it is placed in this table twice—once for reading and once for writing, unless it is a read only or write only type of descriptor. The table is subsequently used to update and retrieve information in constant time. If the descriptor is set in the mask prior to the actual select and remains set afterward, then the hits variable is incremented and the misses is set to zero. If the descriptor is set in the mask prior to the select and is not set afterward, then the misses variable is incremented and the hits variable is set to zero. The priorityTableIndex variable is set to the index of the Priority Array that contains the descriptor's priority. The variable hits is compared with the corresponding priority table entry hitsToAdvance and misses is compared to missesToDrop to determine priority change. If the priority changes, then priorityTableIndex is updated to the index of the new priority.
[0030] The priority array contains the information about all the priorities. Each element in the array shown in FIG. 3 has the following information:
[0031] priority—An integer value priority that corresponds to the number of iterations of the driver loop between actual selects.
[0032] hitsToAdvance—The number of successive hits to move up in priority.
[0033] missesToDrop—The number of successive misses to move down in priority.
[0034] selectWidth—Used to track the select width (max. descriptor+1) for that priority.
[0035] The preferred embodiment also utilizes a value array to determine the current priority and is shown in FIGS. 4 and 5, with an example configuration of priority table shown in FIG. 4 and an example of iterating through a value array being shown in FIG. 5. The Value array shown in FIG. 5 is used to determine the current priority and is configured in the beginning based on the priorities given as shown in FIG. 4. FIG. 5 illustrates an example of how an index into this array is used to get the given priority through 10 iterations of prioritySelect.Select.
[0036] More particularly, this array contains the indices into the priority table that represent the current priority. A pointer moves across this array, advancing on each Select. In this example, the priorities are 1,3, and 10. This means that in the priority table, index 0 has priority 1, index 1 has priority 3, and index 2 has priority 10. At the time of each prioritySelect. Select call, the current position of the pointer contains the index into the priority table for the current priority. The Value table is constructed such that priority n becomes the current priority every nth Select. Once the end of the table is reached, the index returns to 0. Note that the priority is 3 every 3rditeration and the priority is 10 on the 10th.
[0037] The general usage model and implementation steps that are used in the preferred embodiment are set out below in pseudo code. It should be understood that languages such as Java, C, C++ will typically be used in the actual implementation.
| Driver Loop |
| For each descriptor for read D |
| prioritySelect.Fd_ReadSet(D) |
| For each descriptor for write D |
| PrioritySelect.Fd_WriteSet(D) |
| prioritySelect.Select() |
| For each descriptor for read D matched with write E |
| EvalAndService D E |
| Fd_ReadSet |
| Set descriptor in readLater mask |
| if(descriptor.priority >= current priority) |
| set descriptor in readNow mask |
| Fd_WriteSet |
| Set descriptor in writeLater mask |
| if(descriptor.priority >= current priority) |
| set descriptor in writeNow mask |
| Select |
| nextPriorityIndex = get next iteration priority from the Value table and |
| increment pointer |
| loop |
| system select using readNow and writeNow masks and the current |
| priority |
| timeout |
| if any descriptor succeeded or currentPriorityIndex == |
| maxPriorityIndex |
| then break loop else currentPriorityIndex++ |
| for each descriptor D in the Descriptor Table |
| if D is set in the readLater mask |
| if priority of D >= current priority |
| Set D in readNowMask |
| if D is set in the writeLater mask |
| if priority of D >= current priority |
| Set D in writeNowMask |
| currentPriorityIndex = nextPriorityIndex |
| EvalAndService |
| if prioritySelect.Fd_ReadIsSet D and prioritySelect.Fd_WriteIsSet E |
| read from D and Write to E |
| if prioritySelect.Fd_WriteIsSet D and prioritySelect.Fd_ReadIsSet E |
| read from E and Write to D |
| Fd_ReadIsSet |
| if D is set in readNow mask (this mask was passed to the select call) |
| misses = 0 |
| hits++ |
| if hits == hitsToAdvance && priority < maxPriority |
| hits = 0 |
| priorityIndex -- // raise priority |
| return TRUE |
| else |
| misses ++ |
| hits = 0 |
| if misses == missesToDrop && priority > minPriority |
| misses = 0 |
| priorityIndex ++ // lower priority |
| return FALSE |
| Fd_WriteIsSet |
| if D is set in writeNow mask (this mask was passed to the select call) |
| misses = 0 |
| hits++ |
| if hits == hitsToAdvance && priority < maxPriority |
| hits = 0 |
| priorityIndex -- // raise priority |
| return TRUE |
| else |
| misses++ |
| hits = 0 |
| if misses == missesToDrop && priority > minPriority |
| misses = 0 |
| priorityIndex ++ // lower priority |
| return FALSE |
| . . . |
[0038] From the foregoing description, it should be understood that an improved method of efficiently servicing large numbers of simultaneous IO descriptors used in a computer operating system which has many desirable attributes and advantages. The method and algorithm module queries those descriptors that are most likely to have activity, but also reliably queries all descriptors over time, and dynamically adjusts the frequency of queries to maintain maximum efficiency as conditions change. As a result, more efficient processing speed is achieved.
[0039] While various embodiments of the present invention have been shown and described, it should be understood that other modifications, substitutions and alternatives are apparent to one of ordinary skill in the art. Such modifications, substitutions and alternatives can be made without departing from the spirit and scope of the invention, which should be determined from the appended claims.
[0040] The full implementation of the algorithm module of the present invention is set forth in the attached Appendix A.
[0041] Various features of the invention are set forth in the appended claims.
| APPENDIX A |
|---|
Claims
What is claimed is:
1. A method of efficiently querying and processing individual descriptors of a group of descriptors by a processing means operating with a large set of devices or processes, said method comprising the steps of:
querying said plurality of descriptors and processing said descriptors that have activity;
assigning individual descriptors to a predetermined priority level of a hierarchical set of priority levels that are proportional to the amount of activity that individual descriptors are demonstrating;
successively querying said individual descriptors at various intervals that vary in accordance with the amount of activity demonstrated by active descriptors and the assigned priority level of said individual descriptors by executing a driver loop which queries a plurality of descriptors of said predetermined sized group of descriptors and processes the descriptors that have activity, said plurality of descriptors including those descriptors which are in the highest priority level;
changing the priority level of individual descriptors when the amount of activity of said individual descriptors changes from that which is expected in a particular level, wherein said priority levels vary from higher priority levels to lower priority levels, said higher priority levels having a higher amount of activity, the frequency of querying being higher for higher priority levels.
2. A method as defined in claim 1 wherein said step of changing the priority level comprises changing the level of an individual descriptor to a higher level when said descriptor activity exceeds that which is expected for its assigned priority level and changing to a lower priority level when the activity is lower than that which is expected for its assigned priority level.
3. A method as defined in claim 2, wherein each priority level has a range of values of activity, the lowest priority level insuring a query within a predetermined time period.
4. A method as defined in claim 1 wherein said large area network comprises a network that includes the Internet.
5. A method of efficiently querying and processing individual descriptors of a group of descriptors by a processing means operating with a large set of devices or processes, said method comprising the steps of:
querying said plurality of descriptors and processing said descriptors that have activity;
assigning individual descriptors to a predetermined priority level of a hierarchical set of priority levels that are proportional to the amount of activity that individual descriptors are demonstrating;
successively querying said individual descriptors at various intervals that vary in accordance with the amount of activity demonstrated by active descriptors and the assigned priority level of said individual descriptors;
changing the priority level of individual descriptors when the amount of activity of said individual descriptors changes from that which is expected in a particular level, wherein said priority levels vary from higher priority levels to lower priority levels, said higher priority levels having a higher amount of activity, the frequency of querying being higher for higher priority levels
wherein each descriptor of said predetermined sized group of descriptors is queried during multiple successive executions of a driver loop which queries a plurality of descriptors of said predetermined sized group of descriptors and processes the descriptors that have activity, each descriptor being queried at an interval n that varies between 1 and N, where n represents the number of executions of said driver loop that are required to query an individual descriptor and N represents a large number of iterations of executions of said driver loop and 1 represents every execution of said driver loop.
6. A method as defined in claim 1 further including the step of reinitiating said querying step after a time out value in the event no descriptors have activity.
7. A method as defined in claim 6 wherein said time out value represents a variable duration that is inversely proportional to said priority level.
8. A method of querying and processing individual descriptors of a group of descriptors by a processing means operating with a large set of devices or processes, said method comprising the steps of:
iteratively querying said plurality of descriptors by executing a driver loop which queries a plurality of descriptors of said predetermined sized group of descriptors and processing said descriptors, including those descriptors which are in the highest priority level, that have activity a sufficient number of times to determine the level of activity of individual descriptors;
grouping individual descriptors in predetermined priority levels in a hierarchical set of priority levels based upon the amount of activity that is occurring for each individual descriptor, wherein said priority levels vary from higher priority levels to lower priority levels, said higher priority levels having a higher amount of activity, the time duration between successive queries being shorter for higher priority levels;
changing the priority level of individual descriptors during successive querys when the amount of activity of said individual descriptors changes from that which is expected at a particular level.
9. A method as defined in claim 8 wherein said step of changing the priority level comprises changing the level of an individual descriptor to a higher level when said descriptor activity exceeds that which is expected for its assigned priority level and changing to a lower priority level when the activity is lower than that which is expected for its assigned priority level.
10. A method as defined in claim 9 wherein each priority level has a range of values of activity, the lowest priority level insuring a query within a predetermined time period.
11. A method as defined in claim 8 wherein each descriptor of said group of descriptors is queried during multiple successive executions of a driver loop which querys a plurality of descriptors of said group of descriptors and processes the descriptors that have activity, each descriptor being queried at an interval n that varies between 1 and N, where n represents the number of executions of said driver loop that are required to query an individual descriptor and N represents a large number of iterations of executions of said driver loop and 1 represents a query every execution of said driver loop.
12. A method as defined in claim 8 further including the step of reinitiating said querying step after a time out value in the event no queried descriptors have activity.
13. A method as defined in claim 12 wherein said time out value represents a variable duration that is inversely proportional to said priority level.
Patent Citations (14)
| Patent | Date | Inventor | Cited By |
|---|---|---|---|
| US5165021(A) | 1992-11-01 | Wu et al. | Examiner |
| US5428526(A) | 1995-06-01 | Flood et al. | Examiner |
| US5469571(A) | 1995-11-01 | Bunnell | Examiner |
| US5488724(A) | 1996-01-01 | Firoozmand | Examiner |
| US6108683(A) | 2000-08-01 | Kamada et al. | Examiner |
| US6202107(B1) | 2001-03-01 | Collier | Examiner |
| US6295553(B1) | 2001-09-01 | Gilbertson et al. | Examiner |
| US6298410(B1) | 2001-10-01 | Jayakumar et al. | Examiner |
| US6393503(B2) | 2002-05-01 | Fishler et al. | Examiner |
| US6408277(B1) | 2002-06-01 | Nelken | Examiner |
| US6412048(B1) | 2002-06-01 | Chauvel et al. | Examiner |
| US6457097(B1) | 2002-09-01 | Tamura | Examiner |
| US6515681(B1) | 2003-02-01 | Knight | Examiner |
| US6545999(B1) | 2003-04-01 | Sugita | Examiner |