The present invention relates to the field of computer graphics. More particularly, the present invention relates to the context-dependent caching of images in order to improve bandwidth.
Remote computing applications where screen information is generated on one computer (a “host”) and transmitted for display on another computer (“a display”) are growing in popularity. Examples of some display computers include multipurpose PCs, thin-clients, and Personal Digital Assistants (PDAs).
The X Windows System is a standard that utilizes X client software and X server software to enable the updating of displays at the requests of X client applications. The X server software runs on the host computer. An X client application, which may be running on a different computer, communicates with the X server software by utilizing a low-level library of routines known as Xlib. Xlib provides the functions required to connect to display servers, create windows, render graphics, respond to events, etc. The X server software then may interface with display drivers to actually render the graphics on the display.
X is frequently used as a “local display application”, where the X-server and display are both on the same computer. That is, the same computer is both the “host” and “display” computer. Examples of this usage include running an X-server on a workstation or on an X-terminal. An X-terminal typically has a computer processor, graphics subsystem and display, but no hard drive. Applications running on other computers use the Xlib routines to communicate with the X-server software running on the X-terminal.
While in some contexts it is advantageous to have the X server and the display on the same computer, this is not necessarily the case in other contexts. One specific context that will be discussed is a remote display application. In such a design, client applications make requests of a centralized server or servers (here known collectively as the “host computer”). The host computer then manages one or more “display computers”, which are typically simple terminal devices.
The Sun Ray™ appliance from Sun Microsystems, Inc. of Palo Alto, Calif. is an example of a thin client which serves as a “display computer” in a remote computing application. A Sun Ray™ appliance has a processor, graphics subsystem and display, but no hard drive. A Sun Ray™ appliance is a “display” computer and runs its own proprietary software. The Sun Ray™ server is the “host” computer and runs the X-server software. The full screen image is maintained both in RAM on the host computer as well as in the frame buffer of the Sun Ray™ appliance's video card. In order to synchronize the displays, the host computer sends screen update information to the Sun Ray™ appliance via a network protocol known as NewT. The Sun Ray™ appliance uses the protocol commands to update the state of its hardware frame buffer.
One way to reduce bandwidth and CPU usage is for the display computer to maintain a cache of images it has seen. If the images occur on the screen again, the server can direct the client to use the cached image rather than sending the image again from scratch. Due to limitations in the size of the image cache, however, older images must sometimes be removed (“flushed”) from the cache to make room for new images. If a flushed image subsequently recurs on the screen, a cache “miss” occurs and the image must be resent from scratch.
Prior art implementations typically use a least-recently used (LRU) algorithm to determine which image(s) to flush. Here, the image that has gone the longest without recurring on the screen is flushed. Unfortunately, this algorithm flushes images without regard for their contents or types. Some types of images are more likely to be re-used than others. What is needed is a solution that allows the system to make a more intelligent decision as to which image(s) to flush from the cache.
A mechanism is provided that identifies certain classes of images that are likely to be re-used, and utilizes this information to manage a cache better. This may include flushing certain classes of images that are less likely to be re-used before flushing the classes that are more likely to be reused. In addition, or alternatively, other factors regarding the image may be utilized to determine whether or not caching of the image should occur.
The accompanying drawings, which are incorporated into and constitute a part of this specification, illustrate one or more embodiments of the present invention and, together with the detailed description, serve to explain the principles and implementations of the invention.
In the drawings:
Embodiments of the present invention are described herein in the context of a system of computers, servers, and software. Those of ordinary skill in the art will realize that the following detailed description of the present invention is illustrative only and is not intended to be in any way limiting. Other embodiments of the present invention will readily suggest themselves to such skilled persons having the benefit of this disclosure. Reference will now be made in detail to implementations of the present invention as illustrated in the accompanying drawings. The same reference indicators will be used throughout the drawings and the following detailed description to refer to the same or like parts.
In the interest of clarity, not all of the routine features of the implementations described herein are shown and described. It will, of course, be appreciated that in the development of any such actual implementation, numerous implementation-specific decisions must be made in order to achieve the developer's specific goals, such as compliance with application- and business-related constraints, and that these specific goals will vary from one implementation to another and from one developer to another. Moreover, it will be appreciated that such a development effort might be complex and time-consuming, but would nevertheless be a routine undertaking of engineering for those of ordinary skill in the art having the benefit of this disclosure.
In accordance with the present invention, the components, process steps, and/or data structures may be implemented using various types of operating systems, computing platforms, computer programs, and/or general purpose machines. In addition, those of ordinary skill in the art will recognize that devices of a less general purpose nature, such as hardwired devices, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), or the like, may also be used without departing from the scope and spirit of the inventive concepts disclosed herein.
In the present application, an embodiment of the present invention is described in the context of a modification of traditional X Windows technology for use with remote computing applications. However, one of ordinary skill in the art will recognize that other embodiments are possible and the present invention should not be limited to X Windows, Sun Ray™, or remote computing technology.
In remote display applications based on an X server, the Device Dependent (DDX) layer of the X server may be modified to include possible compression of the screen data and transmission of remote display protocol commands to the display computer. The DDX provides a software interface to a conceptual hardware device. In a specific embodiment of the present invention, the desired results can be accomplished by modifying the DDX, without changing the DIX.
The present invention provides a mechanism that identifies certain classes of images that are likely to be re-used, and utilizes this information to manage a cache better. This may include flushing certain classes of images that are less likely to be re-used before flushing the classes that are more likely to be reused. However, one of ordinary skill in the art will recognize it could be modified in a way so as to simply not cache, or be less likely to cache, images that are less likely to be used, as that will have the same effect (i.e., the cache being filled with images that are more likely to be reused than those uncached).
In an embodiment of the present invention, the cache itself is located on the display computer but it is administered by the host computer. The host computer keeps a record of the size of the cache and how much of it is occupied at any point. The host computer can then determine whether an image can fit in the cache without first asking the display computer. This is done so that the cache management protocol commands do not need return values.
In the X-server, images that are more likely to be re-used include backing store pixmaps, non-backing-store pixmaps, tile images, and font character images. A backing store pixmap is used by the X-server to store a temporarily obscured portion of a window's image (e.g., when the window is obscured by another window being moved across it, or by a temporary window such as a menu). As the obscured portion is likely to be obscured only temporarily, there is a high likelihood that it will need to be re-used. In this application, it should be understood that “backing store pixmaps” describe pixmaps that are used to provide both backing store and save under images.
A non-backing store pixmap is often used by an X client application to store an image that it expects to re-use often (e.g., a browser might store the images of its navigation icons in pixmaps). This way, the client application can use a low-bandwidth XCopyArea X protocol command to repaint the image instead of having to use a high-bandwidth XPutImage command. An image drawn using XCopyArea from a pixmap is therefore more likely to be re-used than one drawn using XPutImage.
It may be useful to treat back buffer pixmaps separately from other non-backing store pixmaps, for example if these are found to have a different re-use probability. Back buffer pixmaps are typically used to construct complex images off-screen and then copy them on screen to give an “instantaneous” update. Factors indicating a likelihood that a pixmap is being used as a back buffer include:
1. The pixmap is large.
2. The pixmap is copied to the screen repeatedly.
3. The pixmap contains more than one type of image data (e.g., low- and high-color regions).
4. At least part of the pixmap is modified between copies
A tile image is typically used for a window background area. These images are typically reused any time the visible portion of the window is changed, and so have a high re-use probability. Sometimes such re-use may be provided for by the caching of backing store pixmaps. But in other circumstances the caching of tile images may be useful instead. Examples of such circumstances are:
1. Windows for which backing store and/or save unders are not enabled.
2. Changes in the visible portion of a window that do not trigger its backing store mechanism. Examples include a) restoring the window from an icon, b) unobscuring a window that was covered by another permanent window, and c) changing the size of the window.
In many X Windows window managers, an important example of case 1 is the workspace (or “desktop”) window. The visible portion of the workspace window changes very frequently in typical use, so it may be especially important to cache its background tile image if one is used. (If the workspace window is single-color rather than tiled, then there is no need to cache it.). This may be especially true if the tile size of the background image is very large (e.g., full-screen), and so would require a lot of bandwidth if it had to be transmitted from scratch. Candidates for the workspace window may be identified by various traits such as: a) its size is (nearly) full-screen, b) its background is tiled, c) the window is never drawn to (i.e., any images that occur on top of the background are actually in a different window), d) it has backing store and save unders disabled, e) it has no border, f) it is at some time at least partially visible, and g) its visible region changes frequently. Note some workspace managers provide multiple virtual workspaces, and so more than one workspace image may need to be cached.
The character images for a common font are also likely to be re-used many times and so are useful to cache. Because text tends to occur in strings of characters in the same font, it is useful to treat the entire font as an entity rather than as a set of unrelated character images. For simplicity, the caching of character images will not be discussed much in the present document. But one of ordinary skill in the art will recognize that the font cache can share the memory with the ordinary image cache, and that cached images in a font can be subjected to the same kind of quality level determinations as the other types of images.
Furthermore, there are some classes of images that have a low probability of re-use and thus may wish to flush more easily (or simply not cache). The first of these are images that were in a pixmap (backing store or otherwise) that has since been destroyed. Destruction of the pixmap implies that the X-server or X-application is done with the image. The second are images that were drawn with a PutImage directly to a realized window (as opposed to a pixmap). This implies that the X application program does not expect to use them again. The third are tile images that were drawn only in a window that no longer exists.
Roughly speaking, the cache effectiveness should be maximized if images are cached and flushed according to the product of the expected number of reuses and the bandwidth saved per reuse. The expected number of reuses may be approximately computed based on the number of uses so far, the time since the last use, and the re-use probability for the appropriate image class. The bandwidth saved per reuse can be determined by explicitly calling the compression routines that would be used to compress the image for sending. Or it can be determined approximately using such factors as the size of the image, the number of unique colors in the image, and the fraction of the image occupied by many-colored images. The bandwidth saved should also take into account what fraction of the pixmap is likely to be correct in the cache by the time re-use occurs. That is, little is gained by caching a pixmap whose image is extensively modified before reuse.
For pixmap images in the cache, additional benefits may be realized. A unique pixmap identifier (e.g., the pixmap ID or pointer value) can be used as the cache index, instead of the image hash value. This saves the hash-computation overhead. A “valid region” can be attached to each pixmap giving the region of the pixmap for which the display computer has an accurate copy in the image cache. This provides the advantage that the display computer can cache and access partial copies of a pixmap's image, something for which a hashing-based cache cannot be used. Lastly, when a pixmap to pixmap copy occurs on the host computer and the source pixmap is cached, the host computer can direct the display computer to perform the equivalent copy between cache entries (a new cache entry may need to be created for the destination pixmap). Such an optimization would be much more difficult in a prior-art image cache that did not associate cache entries with individual pixmaps.
In a hash-based cache, two occurrences of the same image will be thought to be completely unrelated if they contain different portions of the source image or if the source image has been modified at all. Thus, an embodiment of the present invention allows use of the cache in the following scenarios when a hash-based cache would not:
1. An entire pixmap image is copied to the screen. Later on, part of the image is copied to the screen again. The second occurrence comes from the cache.
2. Part of a pixmap image is copied to the screen. Later on the entire image is copied. At this point, the previously-seen portion—as determined by the valid region—comes from the cache and only the new portion needs to be sent from scratch.
3. A pixmap image is copied to the screen. Later on, part of the pixmap image is modified. Then the pixmap is copied to the screen again. At this point, the portion of the pixmap that was not modified—as determined by the valid region—comes from the cache. The rest is sent from scratch.
In these cases, the hashes of the new image and the cached image differ but the pixmap identifier is the same.
In the X server, tile images are typically specified using a pixmap. Thus, tile images may be treated the same way as backing store and non-backing store pixmaps. But in some cases a tile image may recur on the screen without an explicit reference to the tile image pixmap. Furthermore, tile images tend to be static, so there is no need for the “valid region” mechanism or for handling pixmap to tile copies. Thus it may also be useful to have the tile image cache entries be independent of the pixmap, in which case the image hash may be used instead of a pixmap identifier.
In an embodiment of the present invention, it may furthermore be useful to segregate the various image cache entries in the cache lookup table. That way the host computer need not spend time checking, for example, tile image cache entries, when it is looking for a backing store pixmap entry. However, the cache entries could still share a common memory pool for efficiency.
If at 400 it was determined that the class of the image is not a tile image, then at 404 it may be determined if the class of the image is a pixmap. If so, then at 406 it may be determined if the pixmap holding the image has been destroyed. If so, then at 408 a probability factor may be assigned to the image based on a destroyed pixmap probability. If the pixmap holding the image has not been destroyed, then at 410 it may be determined if the class of the image is a backing-store pixmap. If so, then at 412 a probability factor may be assigned to the image based on a backing-store pixmap probability. If not, then at 414 it may be determined if the non-backing-store pixmap is likely to be a back buffer.
Referring back to
If at 404 it is determined that the class of the image is not a pixmap, then at 428 it may be determined if the image was drawn with a PutImage to a realized window. If so, then at 430, a probability factor may be assigned to the image based on a PutImage to a realized window probability.
Once a probability factor has been assigned to the image, at 432 the number of times the image has been used (i.e., at least partially drawn to the screen) may be determined. Then at 434, the amount of time since the image was last used may be determined. Finally, at 436, a quality rating for the image may be calculated based on the number of times the image has been used, the amount of time since the image was last used, the area of the pixmap image, the area of the valid region divided by the area of the pixmap region, the ratio of the area of a constant region to the area of the image, and the probability factor assigned to the image. Other factors may also play a part, including a measure of the amount of bandwidth it would take to transmit the image (such as the number of unique colors), and whether or not the image is a workspace window image.
Referring back to
If at 600 it is determined that the image is not associated with a pixmap, or if at 602 it is determined that the pixmap identifier doesn't match a pixmap identifier corresponding to a pixmap in the cache, then at 618 it may be determined if the image hash value matches an image hash value corresponding to an image in the cache. If so, then the corresponding image from the cache may be retrieved at 620.
For simplicity the discussion up to this point has focused on caching as much of a pixmap's image as actually appears on screen. In one embodiment, however, only the many-colored portions of the pixmap are cached since these would require the most bandwidth to send. A separate pixmap entry may be used for each of one or more rectangles identified as containing a large number of unique colors. The lookup value into the cache table may be formed from the pixmap identifier plus an indicator of which many-colored rectangle is stored in the corresponding cache entry. The indicator may be an index number or a reference to the coordinates of the many-colored rectangle. One of ordinary skill in the art can see that further refinements are possible, such as storing the full image for images with a high re-use probability and only the many-colored portions for images with a low re-use probability.
If at 700 it is determined that the command is neither a SaveArea command or a CopyArea from a pixmap to a window command, then at 712, it may be determined if the command draws to the pixmap. If so, then at 714, the drawn-to region may be computed. Then at 716, the drawn-to region may be removed from the valid region of the pixmap. In principle, pixmap to pixmap copies could be treated more gracefully than as is depicted in
If at 800 it is determined that the command is neither a SaveArea command or a CopyArea from a pixmap to a window command, then at 806, it may be determined if the command draws to the pixmap. If so, then at 808, the drawn-to region may be computed. Then at 810, the drawn-to region may be removed from the constant region of the pixmap.
While embodiments and applications of this invention have been shown and described, it would be apparent to those skilled in the art having the benefit of this disclosure that many more modifications than mentioned above are possible without departing from the inventive concepts herein. The invention, therefore, is not to be restricted except in the spirit of the appended claims.
The present application is a continuation-in-part of application Ser. No. 10/622,956, filed on Jul. 18, 2003, by Jordan M. Slott and Thomas G. O'Neill, entitled “Transmitting And Displaying Composite Images” (Attorney Docket No. SUN-030102), which is a continuation-in-part of application Ser. No. 10/449,540, filed on May 29, 2003, by Jordan M. Slott and Thomas G. O'Neill, entitled “Caching Backing-Store Images To Reduce Bandwidth”, (Attorney Docket No. SUN-P9020), and of application Ser. No. 10/385,759, filed on Mar. 10, 2003, by Thomas G. O'Neill and Jordan M. Slott, entitled, “Tagging Repeating Images For Improved Compression”, (Attorney Docket No. SUN-P9199), which is a continuation-in-part of co-pending application Ser. No. 10/247,907, filed on Sep. 20, 2002, by Thomas G. O'Neill and Jordan M. Slott, entitled “Tagging Single-Color Images For Improved Compression”, (Attorney Docket No. SUN-P7083), which is a continuation in part of co-pending application Ser. No. 10/194,123, filed on Jul. 11, 2002, by Thomas G. O'Neill and Jordan M. Slott, entitled “Tagging Multicolor Images For Improved Compression”, (Attorney Docket No. SUN-P7082), and of application Ser. No. 10/623,058, filed on Jul. 17, 2003, by Jordan M. Slott and Thomas G. O'Neill, entitled “Caching Fonts For Improved Bandwidth of Transmitted Text”, (Attorney Docket No. SUN-P7932).
Number | Date | Country | |
---|---|---|---|
Parent | 10754681 | Jan 2004 | US |
Child | 11290926 | Nov 2005 | US |
Number | Date | Country | |
---|---|---|---|
Parent | 10622956 | Jul 2003 | US |
Child | 11290926 | Nov 2005 | US |
Parent | 10449540 | May 2003 | US |
Child | 10622956 | Jul 2003 | US |
Parent | 10385759 | Mar 2003 | US |
Child | 10622956 | Jul 2003 | US |
Parent | 10247907 | Sep 2002 | US |
Child | 10385759 | Mar 2003 | US |
Parent | 10194123 | Jul 2002 | US |
Child | 10247907 | Sep 2002 | US |