An Optimal Resource Scheduler for Continuous Display of Structured Video Objects Martha L. Escobar-Molano, Shahram Ghandeharizadeh, Douglas Ierardi fmarthae, shahram,
[email protected] July 20, 1995 Abstract This study presents an optimal resource scheduler for continuous display of structured video. A structured video consists of a collection of background objects, characters and rendering features. Spatial constructs are used to place objects that constitute a scene in a rendering space while temporal constructs describe how the objects and their relationships evolve as a function of time. When a user requests the display of a video object, the system is provided with a display schedule of objects that must be retrieved by a certain time in order to support a display free of disruptions. Assuming a platform consisting of a xed amount of memory and a magnetic disk drive, this study describes an algorithm that supports such a retrieval while minimizing both the latency observed by a display and its required amount of memory. Keywords: Multi-media, Databases, Optimization, Resource Scheduling, Continuous Display, Structured Video.
This research was supported in part by the National Science Foundation under grants IRI-9222926, IRI-9258362 (NYI award), and CDA-9216321, and a Hewlett-Packard unrestricted cash/equipment gift.
1 Introduction An emerging area of database research is to investigate techniques that ensure a continuous display of video objects. Repositories supporting this data type are expected to play a major role in many applications including library information systems, entertainment industry, educational applications, etc. A repository may employ two alternative approaches to represent a video clip: 1. Stream-based: A video clip consists of a sequence of two dimensional frames. Its frames are displayed at a pre-speci ed rate (e.g., 30 frames a second for TV shows, 24 frames a second for most movies shown in a theater due to the dim lighting). If an object is displayed at a rate lower than its pre-speci ed bandwidth, its display will suer from frequent disruptions and delays, termed hiccups. 2. Structured: A video clip consists of a sequence of scenes. Each scene consists of a collection of background objects, actors (e.g., 3 dimensional representation of Mickey Mouse, dinosaurs, lions), light sources that de ne shading, and the audience's view point. Spatial constructs are used to place objects that constitute a scene in a rendering space while temporal constructs describe how the objects and their relationships evolve as a function of time. The rendering of a structured presentation is hiccup{free when it satis es the temporal constraints imposed on the display of each object. \Reboot" [Ber94] is an animated Saturday morning children's show created using this approach. The advantages of using this approach is that its content description captured in the structure can facilitate eective query processing techniques. Moreover, it supports re{usability of information because an object can be extracted from one scene and re{used in another. The focus of this study is on structured video objects. Our target hardware platform consists of a xed amount of memory (DRAM) and a mass storage device, a magnetic disk drive. The size 1
Term
t m Tp Time Interval i Instant i pmax Si RSi Pi Fi Ri
De nition
Duration of a time interval Duration of a movie in time intervals Time to retrieve a page Period [i; i + 1] The beginning of time interval i Maximum number of pages read during a time interval Pages in memory at instant i Pages that must be in memory at instant i Pages containing objects displayed during time interval i Pages retrieved from disk onto memory during time interval i Pages swapped out during time interval i
Table 1: Parameter De nitions. of memory is signi cantly smaller than that of the magnetic disk drive. All objects along with their complex relationships reside on the magnetic disk drive permanently. When a user requests the display of a video clip, the system is provided with a display schedule. The display schedule speci es when each participating object should be memory resident in order to support a hiccup{ free display. The objects are staged from disk into memory prior to their display. However, if an object is already memory resident then the system observes a memory hit and does not access the disk drive. This study presents an optimal resource scheduler that employs the information provided by the display schedule to construct a retrieval schedule for staging objects from the disk drive onto memory. It provides for a hiccup{free display while minimizing the following two criteria: 1) the latency observed by a display, i.e., time elapsed from the arrival of a request to the onset of the display, and 2) the amount of memory required for the display. These two goals are complementary, and in this case, the algorithm minimizes both simultaneously.
2
2 Model When a user requests the display of a structured video, the system has advanced knowledge of the identity of objects that should be memory resident at speci c times to support a hiccup{free display. To render the retrieval schedule from the disk drive regular, we partition time into units of xed size, termed time intervals (of duration t). Let m be the duration of the movie in time intervals. Assume that a disk page is the unit of transfer between the disk drive and memory. Without loss of generality, we assume that the size of an object is smaller than the size of a disk page. (When an object violates this assumption, we represent it as a sequence of x{sized pages.) The assignment of the objects to the pages is pre-determined 1 and the display of an object does not modify this assignment. If the time required to read a page is denoted as Tp, the system can read a maximum of pmax = b Tt c pages during a time interval. Objects displayed during time p
interval i must be memory resident during the entire interval i (for i from 0 to m ? 1). Let Pi denote the set of pages containing these objects. With these constraints, a display assigns a set of pages that must be memory resident at the beginning of time interval i, termed resident set (RSi ), to ensure a hiccup{free display. Henceforth, the beginning of a time interval i is termed instant
i. RSi includes pages containing objects displayed during time interval i ? 1 and those containing objects to be displayed during interval i, i.e., RSi =Pi [ Pi?1 for 1 i < m, RS0=P0 , RSm =Pm?1 . We interleave the display and the retrieval of disk pages to reduce both the latency time observed by a display and its memory requirements 2 . Ideally, Pi should be retrieved into memory during time interval i ? 1 as this minimizes the amount of required memory. However, this is not always possible because the number of pages that constitute Pi may exceed pmax. In this case, the The placement of objects across the pages does not constitute the focus of this study. It is an important research topic that deserves further investigation. 2 An alternative is to retrieve all disk pages from memory before initiating the display. However, this approach requires a signi cant amount of memory. Moreover, it delays the display until all objects become memory resident. 1
3
how long the page remains mem
Figure 1: In (b), arrows identi
(a) Example 2.1: Time table
a
b
c
d
S00
e 1
Request Display
1
c d
g b Time e Interval i 3 Si4 a
2
b 0
f
i
5
6
i+1
7 S8 8 7
e
8
Time Intervals Time
f b
Time Intervals
e
g
Display
objects displayed at each time interval residing in the following disk pages:
P0 = fa; b; cg P1 = fa; dg P2 = fa; eg P4 = fa; bg
P3 = fa; c; f g
P5 = fa; eg P6 = fa; f; gg P7 = fag
Figure 1(a) illustrates the time table of the display. The pages in S0 are retrieved during the period between the arrival of the request and the beginning of the display. The state of memory at the beginning of each time interval (Si ) must contain the pages in the resident sets (RSi ) to ensure a hiccup{free display:
RS0 = fa; b; cg RS1 = fa; b; c; dg RS2 = fa; d; eg RS3 = fa; c; e; f g RS4 = fa; b; c; f g RS5 = fa; b; eg RS6 = fa; e; f; gg RS7 = fa; f; gg RS8 = fag Of the quantities described above, both Pi and RSi are determined by the structured object. The system derives a valid retrieval schedule based on the available bandwidth of its disk drive to ensure a hiccup{free display. From a valid retrieval schedule, we can derive the pages retrieved from disk to memory (Fi ) and the pages discarded from memory (Ri) for each time interval i. These quantities are de ned as follows 3 : Fi = Si+1 ? Si and Ri =Si ? Si+1 . If Si exceeds the size of available memory for a time interval, then there is insucient memory to support a continuous display. This scenario does not constitute the focus of this study. (A straightforward solution might be to increase the amount of available memory.) For the rest of this paper, we describe an optimal algorithm that realizes these three objectives. Obviously, any other sequences fFi g and fRi g providing the same retrieval schedule must perform redundant work, e.g., retrieving a page that is already memory resident. 3
5
3 Optimal Resource Scheduler For each time interval i and page a, we de ne last(a; i) to be the most recent instant j (j i) at which page a was referenced. More formally, let last(a; 0) = ?1 and for each i > 0 de ne
8 >> >: last(a; i ? 1)
if a 2 Pi?1 otherwise
The goal of the resource scheduler is to minimize both the latency and the total amount of memory required to support continuous display. The greedy scheduler takes as input a request (hP0; : : :; Pm?1 i; pmax) and produces a complete retrieval schedule that speci es the sequence
S0 ; : : :; Sm.
Greedy Scheduler (hP0; : : :; Pm?1i; pmax) Sm = RSm .
for i = m ? 1 to 0 do Let Di be the sequence of pages in Si+1 ? RSi , sorted by last( ; i).
if jDij pmax then Fi = Di else Fi = fthe rst pmax pages in Dig Si = RSi [ (Di ? Fi )
end for The latency is djS0j=pmaxe time intervals. The memory requirement of the retrieval schedule is max0im jSij. The request is rejected if this quantity exceeds C , the maximum number of memory pages available. We demonstrate the scheduler using an example. Subsequently, we prove its optimality.
Example 3.1: Figure 1(b) illustrates the retrieval schedule computed by the algorithm for the 6
video object in Example 2.1 when pmax = 1. The memory required to display the video is 4 page frames (i.e., max0i8 jSij). And the latency is 3 time intervals. Consider the loop iteration when i = 5 (i.e., the schedule of retrievals for time interval 5). The state of the variables is as follows: S6 = fa; e; f; g g, RS5 = fa; b; eg, D5 = ff; g g. The system can only retrieve either f or g , but not both because pmax = 1. The scheduler retrieved g because
f must be retrieved prior to time interval 3 (f 2 P3 ), while g 62 Pj for j < 5. In other words,
?1 = last(g; 5) < last(f; 5) = 4. Therefore, f remains memory resident during three time intervals (from interval 3 to 6). If the scheduler retrieves f instead of g then the system must allocate some bandwidth to retrieve g at an earlier time interval. There are two alternative approaches: First, increase the latency and retrieve g prior to time interval 0. Second, retrieve g instead of b (e) during time interval 3 (4) and render b (e) memory resident from time interval 1 to 4 (3 to 5). The rst alternative increases latency to 4 time intervals while the second increases the memory requirement to 5 page frames because S2 (S4) now consists of fa; b; c; d; eg (fa; b; c; e; f g).
Theorem 3.2: The retrieval schedule produced by the greedy scheduler is optimal. Proof: Consider a request Rq = (hP0; : : :; Pm?1i; pmax). Let G = S0g; : : :; Smg denote the retrieval schedule produced by the greedy scheduler on Rq . It suces to prove that for any valid retrieval schedule S = S0 ; : : :; Sm for Rq , jSig j jSij for all i = 0; : : :; m. To prove this, we transform S into G , state by state, starting with Sm and ending with S0 . Speci cally, we show inductively that for each i, there is a way of transforming states S0 ; : : :; Sm into a sequence of states S00 ; : : :; Sm0 so that these transformations do not require extra memory, nor do they ever exceed the available bandwidth. More formally, for all j = 0; : : :; m, jSj0 j jSj j, and for all j i, Sj0 = Sjg . It will follow that the memory requirement of G at each instant is optimal. Therefore the total memory requirement (max0im jSig j) is minimized. Moreover, the latency is also minimized because it is 7
determined by jS0g j. For the basis of the induction consider Sm , then either Sm = Smg = RSm or Smg Sm . We can eliminate all pages in Sm ? Smg (i.e., Sm0 = Smg ) because they are not displayed during time interval m ? 1. For the induction step, suppose that we have transformed S so that Sj0 = Sjg for all
j = i +1; : : :; m. (To simplify notation, from now on we denote transformed sequences by S instead of S 0.) Consider the possible dierences between Si and Sig . If Si = Sig , then there is nothing to do. Suppose that Si ? Sig 6= ;. Hence there are pages a 2 Si ? Sig that S has resident, and G does not. Since a 62 Sig , then a 62 RSi . So these sets can be equated by removing a from Si , and propagating this change backwards. There are several cases needed to realize this backwards propagation. If a 62 Si+1 then eliminate it from Si . If a 2 Si+1 = Sig+1 , then a can be retrieved during time interval i in S as long as there is sucient bandwidth available to accommodate this retrieval. In this case a is eliminated from Si . Assume that there is insucient bandwidth to support the retrieval of a. Hence S is retrieving pmax pages during i. It follows that G retrieves a during i because a 2 Sig+1 and a 62 Sig . Moreover, it must be the case that there is some other page
b 6= a that is retrieved by S during i, but not retrieved by G . Because G retrieves at most pmax pages during every time interval. However, by the inductive hypothesis, Si+1 = Sig+1 , so b 2 Sig , thus b 62 RSi . Therefore, last(a; i) last(b; i). To equate Si and Sig , S will now exchange the intervals during which a and b were retrieved. There are two cases. First, if a is retrieved after last(b; i) then let j to be the interval when a was retrieved. In this case, one swaps the retrieval of
a with that of b, so that for k = j + 1; : : :; i; Sk = (Sk ? fag) [ fbg
(1)
If b was already present in memory when a was retrieved in S , then no retrieval is actually needed; 8
the modi cations maintain b memory resident until interval i. Second, if a is retrieved previous to or at last(b; i) then we set j = last(b; i). Since b is in Sj , maintain b in memory until i as in Equation 1. These transformations increase neither the memory nor the bandwidth requirement of a interval. Symmetrically, it may be the case that Sig ? Si 6= ;. Thus G has made some page b memory resident that is not resident in S at i. However, since S is a valid retrieval schedule, it must be the case that each such b is not in RSi . This implies that b 2 Sig+1 = Si+1 as well and G retrieved
pmax pages during i. Thus, there must be some page a that G retrieves during i that S does not retrieve. The nature of the greedy algorithm implies that last(a; i) last(b; i). But by the inductive hypothesis, S has a 2 Si+1 . Since S does not retrieve a during time i, it must have a 2 Si . To equate Si and Sig , modify S so that a is retrieved instead of b during i, and propagate the change through previous intervals as above. Note that, there are transformations for each possible dierence between Si and Sig . Therefore, the greedy algorithm produces an optimal retrieval schedule. Since the greedy schedule minimizes the memory requirement at each interval, it must be the case that whenever it is possible to schedule the request using memory C , such a schedule will be found. It is not dicult to see that an optimal retrieval schedule can be computed in time O(n lg n) where n = mi=0?1 jPij.
4 Discussion This paper describes an optimal resource scheduler that ensures a hiccup{free display of structured video while minimizing both the latency incurred by a display and its total memory requirements. One resource managed by our scheduler is memory. The previous studies of caching attempt 9
to minimize the number of misses scored by references to pages that are not resident in a x{ sized cache. Page replacement algorithms based on heuristics (e.g., LRU, MRU, LRU-K [OOW93] and FIFO) are widely used in applications where future page references are unknown. Optimal strategies have been presented for the case where the entire schedule of page references is known [CR93]; and competitive online algorithms have been studied for online variants of this problem in which an unknown sequence of references is generated by an adversary [ST85] or by a Markov process. In addition, these results have been generalized and elaborated to deal with data placement in distributed systems and le migration [MS91]. However, neither heuristic based nor optimal strategies have considered temporal constraints such as the one that supports a hiccup{free display. The resource scheduler described in this study does not aim to minimize the number of page faults. Instead, it strives to assure a hiccup{free display while minimizing the latency observed by the user. By minimizing the memory requirement of the system, it minimizes the observed latency. Several studies have investigated the retrieval of stream{based presentations [CL93, NY94, DPAG92]. However, they do not consider data sharing in memory. Kamath et al. [MKT95] introduced a data caching method that preserves buers in a controlled fashion for use by other active displays. This technique strives to reduce the total number of disk I/Os by maximizing memory hits. Conversely, our scheduler strives to utilize all available disk bandwidth to minimize both the latency and the amount of memory required for a single display of structured video. A number of studies have analyzed techniques to schedule tasks with real-time deadlines [HL88, CRS93, RS94]. These studies schedule the CPU with the objective to minimize the total cost to the system (the number of tasks that miss their real-time deadline and their associated cost). This study is novel because we focus on I/O scheduling and caching that are key processing components 10
of a data intensive application. There are no deadlines on when a display should start. Instead, once a display is started, the computed retrieval schedule supports the display schedule to provide for a hiccup{free display. We intend to extend this study in several ways. First, we plan to investigate the role of multiple disk drives and how their aggregate bandwidth can be used to minimize both the memory requirement and latency time of the system. In this environment, the placement of data across the disks is of paramount importance. Second, the proposed algorithm should be extended for an environment consisting of multiple users displaying structured video. Dierent presentations may share individual objects. In this case, we plan to investigate how multiple schedules (each schedule corresponding to one active display) can be coordinated to minimize the average latency. Finally, we intend to extend the algorithm to support dynamic presentations of structured displays. With a dynamic presentation, the user controls the display interactively. An example is a virtual representation of geographical data with a navigator controlling the display. Ensuring a continuous display might require reservation of resources (both disk bandwidth and memory).
References [Ber94] [CL93]
S. Bernstein. Techno{artists 'tooning up. Los Angeles Times, pages F1,F4, November 10, 1994. H-J. Chen and T.D.C. Little. Physical storage organizations for time-dependent multimedia data. In Proceedings of the 1993 Foundations of Data Organization and Algorithms (FODO) Conference, October 1993. [CR93] A. Choi and M. Ruschitzka. Managing locality sets: The model and xed{size buers. IEEE Transactions on Computers, 42(2):190{204, February 1993. [CRS93] C. Chen, K. Ramamritham, and J. Stankovic. Resource Reclaiming in Multiprocessor Real-Time Systems. IEEE Transactions on Parallel and Distributed Systems, 4(4):382{397, April 1993. [DPAG92] Y. Osawa D. P. Anderson and R. Govindan. A le system for continuous media. ACM Transactions on Computer Systems, 10(4):311{337, November 1992. [HL88] K. Hong and J. Leung. On-line Scheduling of Real-Time Tasks. In Real-Time Systems Symposium, December 1988.
11
[MKT95] K. RamamrithamM. Kamath and D. Towsley. Continuous media sharing in multimedia database systems. In Proceedings of the Fourth International Conference on Database Systems for Advanced Applications (DASFAA'95), 1995. [MS91] L. McGeoch and D. Sleator, editors. On-Line Algorithms, number 7. DIMACS Series in Discrete Mathematics and Theoretical Computer Science, AMS, Feb 1991. [NY94] R. T. Ng and J. Yang. Maximizing buer and disk utilization for news on demand. In proceedings of the International Conference on Very Large Databases, 1994. [OOW93] E. J. O'Neil, P. O'Neil, and G. Weikum. The LRU-K page replacement algorithm for database disk buering. In Proceedings of the ACM SIGMOD International Conference on Management of Data, pages 297{306, May 1993. [RS94] K. Ramamritham and J. Stankovic. Scheduling algorithms and operating systems support for real-time systems. Proceedings of the IEEE, 82(1):55{67, January 1994. [ST85] D. Sleator and R. Tarjan. Amortized eciency of list update and paging rules. Communications of the ACM, 28:202{208, 1985.
12