A dynamic timer and VirtIO GPU performance optimization method

By introducing dynamic timers into VirtIO GPUs, the timeout time is calculated dynamically, which solves the problem of untimely feedback on the rendering request completion status, and significantly improves the graphics performance of VirtIO GPUs, making it close to the performance level of physical graphics cards.

CN114820275BActive Publication Date: 2025-05-13KYLIN CORP
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202210440354.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-25
Publication Date
2025-05-13
Estimated Expiration
2042-04-25

AI Technical Summary

Technical Problem

The problem of untimely feedback on the graphics rendering request completion status of the VirtIO GPU, resulting in low rendering request processing speed and low overall graphics performance.

Method used

A dynamic timer is introduced, and the timeout time is calculated through a dynamic algorithm, so that the timeout time can be changed dynamically, replacing the fixed time interval state polling timer in VirtIO GPU.

Benefits of technology

It improves the processing speed of rendering requests, significantly improves the overall graphics performance of VirtIO GPU, and enables the virtual machine's 3D graphics performance rendering capabilities to reach 60%-95% of the host.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114820275B_ABST
    Figure CN114820275B_ABST
Patent Text Reader

Abstract

This invention relates to a dynamic timer and a VirtIO GPU performance optimization method based on the dynamic timer. The dynamic timer is used to poll the completion status of rendering requests in the VirtIO GPU and calculates the timeout using a dynamic algorithm. The performance optimization method is as follows: The VirtIO GPU device receives a rendering request; the VirtIO GPU forwards the rendering request to the physical graphics card; the VirtIO GPU queries the completion status of all rendering requests in the physical graphics card and notifies the application of completed requests; if the current request has also been completed, the current rendering ends; otherwise, proceed to step S4; the VirtIO GPU starts the dynamic timer, and after the dynamic timer times out, proceed to step S3 again. This invention solves the problem of untimely feedback on the completion status of rendering requests in the VirtIO GPU, improving the processing speed of rendering requests and overall graphics performance.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This patent application belongs to the technical field of VirtIO GPU performance optimization, and more specifically, relates to a dynamic timer and a VirtIO GPU performance optimization method based on the dynamic timer. Background Art

[0002] Before introducing the background of the present invention, relevant abbreviations and key terms in this industry are first introduced.

[0003] Cloud desktop: Cloud desktop, also known as desktop virtualization, is a typical application in the era of virtualization and cloud computing. Cloud desktop uses cloud computing technology to build a server cluster in the cloud data center and create multiple virtual machines to provide remote computing, storage, applications and other personalized content remote services. Users can connect to the remote cloud desktop through the network through various cloud terminal devices to obtain their own computing, storage, personalized applications and data content, and achieve the same user experience as the local PC. Cloud desktop is delivered to users through the cloud desktop transmission protocol. The cloud desktop transmission protocol is one of the core technologies of cloud desktop, which determines the efficiency and display effect of cloud desktop.

[0004] QEMU: The full name is Quick Emulator, which is a powerful, open source simulator and virtual machine. When used as a simulator, it can run applications of different architectures directly on the operating system by dynamically translating instructions; when used as a virtual machine, it can simulate a fully functional computer device. In the Linux environment, QEMU is usually used in conjunction with KVM, where KVM is responsible for the virtualization of the CPU, memory, etc., and QEMU is responsible for the virtualization of peripherals such as hard disks, network cards, graphics cards, etc.

[0005] KVM: The full name is Kernel-based Virtual Machine, which is a kernel-based virtual machine. It is a full virtualization solution that uses hardware virtualization technology.

[0006] VirtIO GPU: The full name is Virtual I / O GPU, also written as virtio-gpu, which is a semi-virtualized graphics card based on virtio technology. Virtio and related device specifications are maintained by the organization OASIS, aiming to provide a general and efficient virtual device mechanism for virtual environments. Currently, QEMU and the Linux kernel both support VirtIO GPU devices. Compared with fully virtualized graphics cards such as QXL, VirtIO GPU can be used with tools such as VirGL to perform hardware acceleration with the help of the host's physical graphics card, thereby greatly improving the graphics performance of the virtual machine.

[0007] The background of the present invention is introduced as follows:

[0008] Desktop virtualization is an important branch of virtualization technology, among which remote desktop virtualization is the most critical. Remote virtualization is usually called cloud desktop, which often adopts the client-server architecture mode. Users build server clusters in cloud data centers, create multiple virtual machines, and then remotely connect to the virtual machines through cloud terminal devices.

[0009] In this way, cloud desktop can provide users with the same experience as local PC. Cloud desktop technology allows administrators to only need to perform centralized system maintenance in the cloud data center, greatly reducing the workload of administrators. At the same time, users do not need to worry about data loss due to local PC failures, so it is becoming more and more popular among enterprises and individuals.

[0010] Currently, most cloud desktop vendors use the QEMU / KVM architecture to implement virtualization, and use virtual graphics cards such as VirtIOGPU and QXL for image output. Among them, the QXL virtual graphics card uses a CPU-based software rendering mechanism with low performance, and is mainly used in scenes with low requirements for graphics performance, such as office work. VirtIO GPU currently supports back-end hardware acceleration and can forward the graphics rendering requests of the virtual machine to the physical graphics card on the host for processing. With the powerful rendering capabilities of the physical graphics card, the current performance of the VirtIO GPU is much higher than that of the QXL graphics card.

[0011] But even so, there is still a big performance gap between VirtIO GPU and physical graphics card, that is, QXL graphics card << VirtIO << GPU physical graphics card. After testing, under Kunpeng server and AMD Radeon RX550 graphics card, the 3D graphics performance of the virtual machine is only about 30% of that of the host machine. Obviously, this level of graphics performance can only be used in light-load scenarios such as office, and cannot be applied to large-scale 3D applications and games. Therefore, in order to further improve the graphics performance of VirtIO GPU and expand its application scope, we need to continue to improve its rendering capabilities through some technical means and methods.

[0012] Advantages and disadvantages of existing technologies:

[0013] (1) Chinese invention patent "Method and system for optimizing the utilization of virtual graphics processing units" (patent number: CN102446114B). The invention provides a method, system and computer program product for optimizing the utilization of virtual graphics processing units. The embodiments include specifying a computing density level for each virtual machine in a plurality of virtual machines; specifying a priority level for each virtual machine in a plurality of virtual machines; determining for each server in a plurality of servers whether the server includes a virtual machine graphics processing unit (VGPU) that can be used to perform computing-intensive tasks for a plurality of virtual machines; and specifying one or more VGPUs for a virtual machine in a plurality of virtual machines based on the computing density level and priority level of the virtual machine and the data of the VGPU that can be used to perform computing-intensive tasks. The invention mainly focuses on the optimization of VGPUs, and improves the utilization of physical GPUs by optimizing the resource scheduling of VGPUs. Therefore, its method is not applicable to VirtIO GPUs, etc.

[0014] (2) Chinese invention patent "A multi-level fine-grained virtualized GPU scheduling optimization method" (patent number: CN108710536B). This invention discloses a multi-level fine-grained virtualized GPU scheduling optimization method, which uses three methods to optimize the scheduling strategy: time-based and event-based scheduling, pipeline-based seamless scheduling, and hybrid ring-based and virtual machine-based scheduling. These three scheduling strategies respectively use the overhead caused by switching between two virtual machines, the virtual machine operation is divided into multiple stages and runs simultaneously, and multiple virtual machines use different rings to work simultaneously as optimization methods. This invention greatly reduces the overhead of the switching process by modifying the scheduler and scheduling strategy, and supports parallel execution between multiple virtual GPUs. Therefore, the performance of multiple virtual GPUs shared by a physical GPU can be significantly improved, thereby improving the overall performance. However, this invention mainly focuses on the performance improvement of vGPU, and is deeply bound to Intel's GVT-g technology, and is not applicable to VirtIO GPU. In addition, this invention mainly optimizes the scheduling of vGPU, which is equivalent to optimizing resource allocation, and does not involve the internal implementation of vGPU, so the room for improvement is limited.

[0015] (3) Chinese invention patent "A GPU virtualization optimization method based on deferred submission" (patent number: CN103955394B). This invention discloses a GPU virtualization optimization method based on deferred submission. The specific steps are: 1) The GPU virtualization framework front end on the client reads a binary file of a CUDA application to be executed, finds and marks the loop that can be deferred; 2) When the front end executes the part of the loop that can be deferred, it caches all CUDA function call information and its dependencies until the end of the loop, skips the execution of the function call, and then sends the cache information to the GPU virtualization framework back end on the host machine at one time after the end of the loop; 3) The back end reconstructs the function call based on the cache information and executes it, and then packages all the task execution results and sends them back to the front end; the loop that can be deferred means that the CUDA function call in the loop is not executed, and the loop can still be executed correctly. This invention reduces the number of front-end and back-end communications, and optimizes the performance of GPU virtualization. However, this invention mainly focuses on CUDA high-performance computing and does not involve the optimization of graphics performance. In addition, this invention mainly improves the general computing efficiency of the virtual machine by modifying the vCUDA library, and does not involve the underlying virtual GPU, so it cannot be regarded as a GPU virtualization optimization in the strict sense.

[0016] Current development status

[0017] Currently, VirtIO GPU supports hardware acceleration, which can forward the rendering request of the virtual machine to the physical graphics card of the host machine, and the physical graphics card will render it on its behalf. This method can greatly improve the image performance of VirtIO GPU, but due to the implementation mechanism and other reasons, there is still a large performance gap between VirtIO GPU and physical graphics card.

[0018] To further improve the performance of VirtIO GPU, we first need to analyze the implementation principle of VirtIO GPU. Figure 1 This is a diagram of the image data flow when the virtual machine uses the VirtIO GPU (with hardware acceleration turned on). Figure 1 , you can have a preliminary understanding of the functions, implementation principles and relationship of VirtIO GPU with other modules.

[0019] Reference Figure 1 ,The image rendering and output process of the virtual machine is mainly divided into the following steps:

[0020] Step 1: The application in the virtual machine (including the window system and user programs, etc.) sends an image rendering request to the VirtIO GPU driver;

[0021] Step 2: The VirtIO GPU driver aggregates the rendering requests and forwards them to the VirtIO GPU device (created by QEMU on the host side).

[0022] Step 3: The VirtIO GPU device continues to forward the rendering request to the physical graphics card;

[0023] Step 4: The physical graphics card processes each rendering request and generates the final desktop image;

[0024] Step 5: VirtIO GPU obtains the desktop image from the physical graphics card;

[0025] Step 6: VirtIO GPU forwards the desktop image to the SPICE server, etc.

[0026] Step 7: The SPICE server sends the desktop image to the SPICE client through the SPICE protocol;

[0027] Step 8: The SPICE client receives the desktop image and displays it to the user.

[0028] Obviously, in the whole process, steps 3 to 5 are the core part of VirtIO GPU and the key to improving its performance. We will analyze this part in detail below to understand the performance bottleneck.

[0029] Figure 2 This is a diagram of how a VirtIO GPU processes a single rendering request. The steps are as follows:

[0030] 1. The VirtIO GPU device receives a rendering request;

[0031] 2. VirtIO GPU forwards the rendering request to the physical graphics card;

[0032] 3. VirtIO GPU queries the completion status of all rendering requests in the physical graphics card and notifies the application of completed requests. If the current request has also been processed, the rendering ends, otherwise it goes to step 4.

[0033] 4. VirtIO GPU starts a status polling timer with a timeout period of 10 milliseconds, and then goes to step 3 again after the timer times out;

[0034] It should be noted that the query in step 3 is the completion status of all requests forwarded to the physical graphics card, not just the current request. Because it takes a certain amount of time for the physical graphics card to process a request, in general, when the status is queried immediately after VirtIOGPU forwards a request, the current request is unfinished, and the completed requests are all previous requests. Figure 3Conduct specific analysis:

[0035] Here we will focus on analyzing rendering requests N and N+1. Their processing processes represent two situations:

[0036] For request N: Soon after the physical graphics card processes request N, the VirtIO GPU receives and forwards request N+1, and then immediately queries the completion status. Therefore, the VirtIO GPU promptly finds that request N has been processed and notifies the application.

[0037] As for request N+1: After the physical graphics card processed request N+1, the VirtIO GPU did not receive any new requests for a long time, so it was unable to query the completion status in time. It was not until the status polling timer (10 milliseconds) expired that the VirtIO GPU discovered that request N+1 had already been completed, and then notified the application.

[0038] By comparing the processing of requests N and N+1, we found that the status feedback of request N is more timely, while the status feedback of request N+1 is greatly delayed. As a result, when the physical rendering time of the two is similar, the virtual rendering time of request N+1 (reflected on the VirtIO GPU) is much longer than that of request N (up to nearly 10 milliseconds).

[0039] Obviously, the main reason for this performance problem is that the polling timer timeout is too long. At present, the performance of physical graphics cards is rapidly improving, and most rendering requests can be completed in a very short time. After testing, under Kunpeng servers and AMD Radeon RX550 graphics cards, the processing time of most VirtIO GPU rendering requests is in the microsecond level. Therefore, when the status query is performed here with a cycle of 10 milliseconds, the physical graphics card will have been processed long ago, but the VirtIO GPU is still unknown, which will lead to a long virtual rendering time at the VirtIO GPU level, which will eventually manifest as poor performance. Summary of the invention

[0040] The technical problem to be solved by the present invention is to provide a dynamic timer and a VirtIO GPU performance optimization method based on the dynamic timer. The timeout period of the dynamic timer can be changed dynamically to replace the state polling timer with a fixed time interval in the VirtIO GPU, which can solve the problem of untimely feedback on the completion status of rendering requests in the VirtIO GPU, thereby improving the processing speed of rendering requests and ultimately improving its overall graphics performance.

[0041] In order to solve the above problems, the technical solution adopted by the present invention is:

[0042] A dynamic timer calculates the timeout period through a dynamic algorithm so that the timeout period can change dynamically.

[0043] Furthermore, the dynamic algorithm includes but is not limited to an exponential increasing algorithm, a dynamic approximation algorithm, and a moving average algorithm. The exponential increasing algorithm is an exponential increasing algorithm within a specified interval.

[0044] Furthermore, the exponential increasing algorithm within the specified interval is:

[0045] This timeout time = last timeout time × multiplication factor;

[0046] The initial value of the timeout period is 100 microseconds, the maximum value is 10 milliseconds, and the multiplication factor is ≥ 2.

[0047] Furthermore, the dynamic approximation algorithm is as follows: the initial (i.e., the first) timeout of the dynamic timer of each rendering task changes dynamically, and is affected by the completion of the previous task; if the previous task is completed within the initial timeout, the current rendering task will try to shorten the initial timeout; if the previous task is not completed within the initial timeout, the current task will try to increase the initial timeout; the second and subsequent timeouts are not affected by the previous task and are fixed at 100 microseconds.

[0048] Furthermore, the dynamic approximation algorithm is specifically:

[0049] Define the rendering task as n, and the initial timeout of the dynamic timer of the current rendering task as t n , the initial timeout of the dynamic timer for the next rendering task is defined as t n+1 , then:

[0050]

[0051] Where: the time unit is microsecond, n is the rendering task, R n Indicates the number of restarts of the dynamic timer when rendering task n is completed. The minimum value of all initial timeouts is 100;

[0052]

[0053]

[0054] Furthermore, the moving average algorithm is as follows: the timeout period of the dynamic timer of each rendering task (including the first time and thereafter) changes dynamically, and the specific timeout period is the moving average of the total timeout periods when the previous tasks are completed.

[0055] Furthermore, the specific timeout time is a moving average of the total timeout times when the first 10 tasks are completed.

[0056] Furthermore, the rendering task is defined as n, and the single timeout time of the dynamic timer of the current rendering task is defined as t n , the single timeout of the next rendering task is defined as t n+1 , the total timeout when rendering task n is completed is defined as T n , the total timeout when the previous rendering task is completed is defined as T n-1 , and so on, we have:

[0057]

[0058] Where: the time unit is microseconds, p is the completion rate of the last 10 tasks within the first timeout (i.e. p = the number of the last 10 tasks completed within the first timeout ÷ 10), T n =t n *(1+R n ), R n Indicates the number of restarts of the dynamic timer when rendering task n is completed. The minimum value of all timeouts is 100;

[0059]

[0060] A VirtIO GPU performance optimization method based on a dynamic timer utilizes the above-mentioned dynamic timer, and the specific steps are as follows:

[0061] Step S1, the VirtIO GPU device receives a rendering request;

[0062] Step S2: VirtIO GPU forwards the rendering request to the physical graphics card;

[0063] Step S3, VirtIO GPU queries the completion status of all rendering requests in the physical graphics card, and notifies the application of the completed requests; if the current request has also been processed, the current rendering ends, otherwise if the current request has not been processed, proceed to step S4;

[0064] Step S4: VirtIO GPU starts a dynamic timer, and after the dynamic timer times out, the process goes to step S3 again.

[0065] Furthermore, the rendering capability of the 3D graphics performance of the virtual machine of the present method is 60%-95% of that of the host machine.

[0066] Due to the adoption of the above technical solution, the beneficial effects achieved by the present invention are:

[0067] 1. Solved the problem of untimely feedback of rendering request completion status in VirtIO GPU, thereby improving the processing speed of rendering requests and ultimately improving the overall graphics performance of VirtIO GPU.

[0068] 2. The core logic of QEMU has not been changed, maintaining good software compatibility.

[0069] 3. Previously, the 3D graphics performance of the virtual machine was only about 30% of that of the host machine. After adopting this method, the rendering capability can reach a stronger level: (1) In the environment of Kunpeng 920 server and AMD Radeon RX550 graphics card, the 3D graphics performance test tool glmark2 was used to test the VirtIO GPU in the virtual machine, and its performance score was 4093, which was equivalent to 61% of the host machine (6663 points), and it was about 200% higher than before (about 30%); (2) In the environment of Intel i5-9500 CPU and IntelUHD Graphics 630 graphics card, the virtual machine glmark2 score was 2641, which was equivalent to 92% of the host machine (2869 points), and it was about 300% higher than before (about 30%). Therefore, compared with the previous virtual machine 3D graphics performance, the method of the present invention has improved 2-3 times, and the performance improvement is extremely high. BRIEF DESCRIPTION OF THE DRAWINGS

[0070] Figure 1 Image data flow graph for a virtual machine with VirtIO GPU hardware acceleration enabled;

[0071] Figure 2 Graph of the process of processing a single rendering request for a VirtIO GPU;

[0072] Figure 3 A diagram of the process of continuously processing multiple rendering requests for a VirtIO GPU;

[0073] Figure 4 This is a diagram of the process of a VirtIO GPU processing a single rendering request using a dynamic timer introduced in Example 1. DETAILED DESCRIPTION

[0074] The present invention is further described in detail below with reference to the embodiments.

[0075] The present invention discloses a dynamic timer, the dynamic nature of which is mainly reflected in the dynamic calculation of the timeout time. The timeout time is calculated by a dynamic algorithm so that the timeout time can be changed dynamically. The dynamic timer of the present invention does not focus on the dynamic timer itself, but introduces a variable timeout time mechanism to replace the original fixed timeout time mechanism to improve the response speed of the VirtIO GPU and achieve performance improvement.

[0076] The dynamic timer can also support a variety of timeout dynamic calculation algorithms, and switch at any time according to user configuration. Currently supported algorithms are: exponential increase algorithm, dynamic approximation algorithm, moving average algorithm

[0077] The exponential increasing algorithm is an exponential increasing algorithm within a specified interval, specifically:

[0078] This timeout time = last timeout time × multiplication factor;

[0079] The initial value of the timeout period is 100 microseconds, the maximum value is 10 milliseconds, and the multiplication factor is ≥ 2. For example, the multiplication factor can be a natural number such as 2, 3, or 4.

[0080] For the exponential increase algorithm, the initial value, maximum value, and multiplication factor of the timeout period can be dynamically configured through the configuration file and take effect immediately.

[0081] In addition, the present invention also discloses a VirtIO GPU performance optimization method based on the dynamic timer. The dynamic timer calculates the timeout time through a dynamic algorithm, so that the timeout time can be changed dynamically.

[0082] The specific steps are as follows:

[0083] Step S1, the VirtIO GPU device receives a rendering request;

[0084] Step S2: VirtIO GPU forwards the rendering request to the physical graphics card;

[0085] Step S3, VirtIO GPU queries the completion status of all rendering requests in the physical graphics card, and notifies the application of the completed requests; if the current request has also been processed, the current rendering ends, otherwise if the current request has not been processed, proceed to step S4;

[0086] Step S4: VirtIO GPU starts a dynamic timer, and after the dynamic timer times out, the process goes to step S3 again.

[0087] The method of the present invention has excellent performance, and the rendering capability of the 3D graphics performance of the virtual machine using the method is 60%-95% of that of the host machine.

[0088] The following example explains this in detail.

[0089] Embodiment 1

[0090] The dynamic algorithm of this embodiment is an exponential increasing algorithm within a specified interval. For example, the setting rule is:

[0091] This timeout time = last timeout time × multiplication factor.

[0092] The initial value of the timeout is 100 microseconds and the maximum value is 10 milliseconds.

[0093] VirtIO GPU performance optimization method based on this dynamic timer can be found in Figure 4 , specifically including the following steps:

[0094] Step S1, the VirtIO GPU device receives a rendering request;

[0095] Step S2: VirtIO GPU forwards the rendering request to the physical graphics card;

[0096] Step S3: VirtIO GPU queries the completion status of all rendering requests in the physical graphics card and notifies the application of completed requests. If the current request has also been processed, the rendering ends; otherwise, if the current request has not been processed, proceed to step S4.

[0097] Step S4, VirtIO GPU starts the dynamic timer, and after the dynamic timer times out, it goes to step 3 again. The timeout period of the dynamic timer adopts an exponential increase algorithm within a specified interval, and the rules are as follows (also see Table 1): The multiplication coefficient is set to .

[0098] This timeout time = last timeout time × 2;

[0099] The initial value of the timeout is 100 microseconds and the maximum value is 10 milliseconds;

[0100] Table 1 Timeout of dynamic timer

[0101]

[0102]

[0103] After completing the above steps, the feedback delay of the rendering request completion status in the VirtIO GPU can be greatly improved (the feedback delay is maintained at 10 milliseconds for the 8th time and thereafter, and in most cases, the feedback delay will not exceed 100 microseconds), thereby increasing the processing speed of rendering requests and ultimately improving its overall graphics performance.

[0104] The dynamic timer of the present invention is used to poll the rendering request completion status in the VirtIO GPU. It dynamically calculates the timeout period of the timer through a specific algorithm. Although the embodiment adopts an exponential increasing algorithm within a certain interval, other dynamic calculation methods should belong to the scope of the present invention.

[0105] Example 2: Dynamic approximation algorithm:

[0106] In the dynamic approximation algorithm of this embodiment, the initial (i.e., first) timeout of the dynamic timer of each rendering task changes dynamically, which is affected by the completion of the previous task. If the previous task is completed within the first timeout, the current rendering task will try to shorten the initial timeout. If the previous task is not completed within the first timeout, the current task will try to increase the initial timeout. In addition, the second and subsequent timeouts are not affected by the previous task and are fixed at 100 microseconds.

[0107] Algorithm logic:

[0108] Define the initial timeout of the dynamic timer of the current rendering task n as t n , the initial timeout of the dynamic timer for the next rendering task is defined as t n+1 , then:

[0109]

[0110] Where: the time unit is microsecond, n is the rendering task, R n Indicates the number of restarts of the dynamic timer when rendering task n is completed. The minimum value of all initial timeouts is 100.

[0111]

[0112]

[0113] Specific steps:

[0114] Step 1. Start a dynamic timer for rendering task n and set the timeout to t n , the number of timer restarts R n Set to 0;

[0115] Step 2. The dynamic timer times out for the first time and checks the completion status of rendering task n. Depending on the situation:

[0116] (1) If completed, set t n+1 =t n -100, this rendering ends;

[0117] (2) If not completed, proceed to step 3;

[0118] Step 3. Restart the dynamic timer, set the timeout to 100 microseconds, and set the restart count to R. n Add 1;

[0119] Step 4. The dynamic timer times out again and checks the rendering task completion status. Depending on the situation:

[0120] (1) If not completed: go to step 3;

[0121] (2) If it is completed, then make t n+1 =t n +100×R n , this rendering is finished.

[0122] Example 3: Moving average algorithm:

[0123] In the moving average algorithm of this embodiment, the timeout period of the dynamic timer of each rendering task n (including the first and subsequent times) changes dynamically, and mainly refers to the moving average of the total timeout period when the first 10 tasks are completed.

[0124] Algorithm logic:

[0125] Define the rendering task as n, and define the single timeout period of the dynamic timer of the current rendering task n as t n , the single timeout of the next rendering task is defined as t n+1 , the total timeout when the current rendering task n is completed is defined as T n , the total timeout when the previous rendering task is completed is defined as T n-1 , and so on, we have:

[0126]

[0127] Where: the time unit is microseconds, p is the completion rate of the last 10 tasks within the first timeout (i.e. p = the number of the last 10 tasks completed within the first timeout ÷ 10), T n =t n *(1+R n ), R n Indicates the number of restarts of the dynamic timer when rendering task n is completed. The minimum value of all timeouts is 100.

[0128]

[0129] The specific steps are:

[0130] 1. Start a dynamic timer for rendering task n and set the timeout to t n , the number of timer restarts R n Set to 0;

[0131] 2. When the dynamic timer times out for the first time, check and save the completion status of rendering task n at the time of the first timeout, and then:

[0132] (1) If completed: proceed to step 5;

[0133] (2) If not completed, proceed to step 3;

[0134] 3. Restart the dynamic timer and set the timeout to t n , the number of restarts R n Add 1;

[0135] 4. The dynamic timer times out again and checks the completion status of the rendering task. Depending on the situation:

[0136] (1) If not completed: go to step 3;

[0137] (2) If completed, go to step 5;

[0138] 5. Calculate and save the total timeout time when task n is completed as T n , that is, T n =t n ×(1+R n );

[0139] 6. Count and analyze the completion status of the last 10 rendering tasks within the "first timeout", calculate the first completion rate p, and then calculate the timeout time t of the next rendering task according to the formula n+1 ;

[0140] 7. This rendering is finished.

[0141] Previously, the 3D graphics performance of the virtual machine was only about 30% of that of the host machine, but after adopting this method, the rendering capability can reach a stronger level: (1) In the environment of Kunpeng 920 server and AMD Radeon RX550 graphics card, the 3D graphics performance test tool glmark2 was used to test the VirtIO GPU in the virtual machine, and its performance score was 4093, which was equivalent to 61% of the host machine (6663 points), and it was about 200% higher than before (about 30%); (2) In the environment of Intel i5-9500 CPU and IntelUHD Graphics 630 graphics card, the virtual machine glmark2 score was 2641, which was equivalent to 92% of the host machine (2869 points), and it was about 300% higher than before (about 30%). Therefore, the method of the present invention improves the 3D graphics performance of the virtual machine by 2-3 times compared with the previous one, and the performance improvement is extremely high.

Claims

1. A dynamic timer for polling the completion status of a rendering request in a VirtIO GPU, characterized in that: The timeout time is calculated by a dynamic algorithm, so that the timeout time can be changed dynamically; Dynamic algorithms include dynamic approximation algorithms; The dynamic approximation algorithm is as follows: the initial timeout of the dynamic timer of each rendering task changes dynamically, which is affected by the completion of the previous task; if the previous task is completed within the initial timeout, the current rendering task will try to shorten the initial timeout; if the previous task is not completed within the initial timeout, the current task will try to increase the initial timeout; the second and subsequent timeouts are not affected by the previous task and are fixed at 100 microseconds; The dynamic approximation algorithm is as follows: Define the rendering task as n, and the initial timeout of the dynamic timer of the current rendering task as t n , the initial timeout of the dynamic timer for the next rendering task is defined as t n+1 , then: Where: the time unit is microsecond, n is the rendering task, R n Indicates the number of restarts of the dynamic timer when rendering task n is completed. The minimum value of all initial timeouts is 100.

2. A dynamic timer according to claim 1, characterized in that: The dynamic algorithm also includes an exponential increasing algorithm, which is an exponential increasing algorithm within a specified interval, specifically: This timeout time = last timeout time × multiplication factor; The initial value of the timeout period is 100 microseconds, the maximum value is 10 milliseconds, and the multiplication factor is ≥ 2.

3. A dynamic timer according to claim 1, characterized in that: The dynamic algorithm also includes a moving average algorithm. The moving average algorithm is as follows: the timeout period of the dynamic timer of each rendering task changes dynamically, and the specific timeout period is the moving average of the total timeout period when the previous tasks are completed.

4. A dynamic timer according to claim 3, characterized in that: The specific moving average algorithm is as follows: the specific timeout time is the moving average of the total timeout time when the first 10 tasks are completed.

5. A dynamic timer according to claim 4, characterized in that: The specific moving average algorithm is as follows: define the rendering task as n, and define the single timeout time of the dynamic timer of the current rendering task as t n , the single timeout of the next rendering task is defined as t n+1 , the total timeout when rendering task n is completed is defined as T n , the total timeout when the previous rendering task is completed is defined as T n-1 , and so on, we have: Where: the time unit is microsecond, p is the completion rate of the last 10 tasks within the first timeout, T n =t n *(1+R n ), R n Indicates the number of restarts of the dynamic timer when rendering task n is completed. The minimum value of all timeouts is 100.

6. A VirtIO GPU performance optimization method based on dynamic timer, characterized in that: The dynamic timer in any one of claims 1 to 5 is used, and the specific steps are as follows: Step S1, the VirtIO GPU device receives a rendering request; Step S2: VirtIO GPU forwards the rendering request to the physical graphics card; Step S3, VirtIO GPU queries the completion status of all rendering requests in the physical graphics card, and notifies the application of the completed requests; if the current request has also been processed, the current rendering ends, otherwise if the current request has not been processed, proceed to step S4; Step S4: VirtIO GPU starts a dynamic timer, and after the dynamic timer times out, the process goes to step S3 again.

7. The method for optimizing VirtIO GPU performance based on dynamic timer according to claim 6, characterized in that: The rendering capability of the 3D graphics performance of the virtual machine of the method is 60%-95% of that of the host machine.

Citation Information

Patent Citations

  • Method and system used for optimizing virtual graphics processing unit utilization

    CN102446114B

  • A GPU virtualization optimization method based on deferred commit

    CN103955394B

  • A multi-level, fine-grained virtualization GPU scheduling optimization method

    CN108710536B

  • Method and device for querying task status

    WO2017101701A1