Container memory bandwidth occupancy detection method and device and electronic equipment
By allocating memory bandwidth to the container to occupancy detection tags, automated and unified detection of processes in the container is realized, solving the problem of inefficient detection in the prior art, and improving detection efficiency and accuracy.
Patent Information
- Application Number
- CN202410175810.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-02-07
- Publication Date
- 2025-08-08
AI Technical Summary
The prior art cannot effectively detect memory bandwidth usage with container as granularity, resulting in low detection efficiency, especially when processes in containers change frequently.
Allocate memory bandwidth occupancy detection tags to the target container, and automatically manage the memory bandwidth detection of processes in the container tags to achieve unified detection of processes in the container.
It improves the efficiency of container memory bandwidth usage detection, and can maintain the accuracy and efficiency of detection results when the process changes frequently.
Smart Images

Figure CN120455331A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of cloud computing, and in particular to a method, device, and electronic device for detecting container memory bandwidth usage. Background Art
[0002] Cloud computing technology can allocate memory bandwidth to different application platforms based on computing needs. Current container technology in cloud computing packages an application and all its dependencies within a single container, creating a self-contained environment. Compared to traditional cloud computing, container technology allows for rapid deployment, scaling, and management of applications with greater flexibility. Allocating memory bandwidth to each container requires real-time monitoring of the memory bandwidth used by processes within the container. However, existing memory bandwidth detection methods cannot handle the frequent changes in processes within a container, resulting in low efficiency in detecting memory bandwidth usage within a container. Summary of the Invention
[0003] Embodiments of the present disclosure provide a method, apparatus, and electronic device for detecting the memory bandwidth usage of a container. The method can improve the detection efficiency of detecting the memory bandwidth usage of a container.
[0004] According to one aspect of the present disclosure, a method for detecting container memory bandwidth usage is provided, comprising:
[0005] In response to a memory bandwidth usage detection instruction for a target container, determining a container tag corresponding to the target container;
[0006] Allocating a memory bandwidth occupancy detection tag to the target container, and detecting the memory bandwidth occupied by the process in the target container based on the memory bandwidth occupancy detection tag;
[0007] Obtaining a memory bandwidth occupancy detection result of the process corresponding to the memory bandwidth occupancy detection tag;
[0008] A container memory bandwidth usage detection result of the process in the target container is determined from the memory bandwidth usage detection result based on the container tag.
[0009] According to one aspect of the present disclosure, a device for detecting container memory bandwidth usage is provided, comprising:
[0010] a response unit, configured to determine a container tag corresponding to the target container in response to a memory bandwidth usage detection instruction for the target container;
[0011] a first allocating unit, configured to allocate a memory bandwidth usage detection tag to the target container, and detect the memory bandwidth occupied by the process in the target container based on the memory bandwidth usage detection tag;
[0012] A first acquiring unit is configured to acquire a memory bandwidth usage detection result of a process corresponding to the memory bandwidth usage detection tag;
[0013] A first determining unit is configured to determine, based on the container tag, a container memory bandwidth usage detection result of the process in the target container from the memory bandwidth usage detection result.
[0014] Optionally, the memory management parameters of the target container include a first detection group label field;
[0015] The first allocation unit is specifically configured to:
[0016] Determine a target detection group corresponding to the target container in at least one detection group, where each detection group corresponds to a memory bandwidth usage detection tag;
[0017] Assign a first target memory bandwidth occupancy detection tag corresponding to the target detection group to the first detection group tag field.
[0018] Optionally, the target detection group includes a container tag set, where the container tag set includes container tags corresponding to containers for which memory bandwidth usage detection is performed using the first target memory bandwidth usage detection tag;
[0019] The first allocation unit is specifically configured to:
[0020] Writing the container tag corresponding to the target container into the container tag set;
[0021] The container assignment function corresponding to the container tag set is called to assign the first target memory bandwidth occupancy detection tag corresponding to the target detection group to the first detection group tag field.
[0022] Optionally, the container memory bandwidth usage detection device further includes:
[0023] a second acquiring unit, configured to acquire, in response to a detection group deletion instruction for a detection group to be deleted, a second target memory bandwidth usage detection tag corresponding to the detection group to be deleted;
[0024] a second determining unit, configured to determine a container having the same detection group tag field as the second target memory bandwidth usage detection tag as a container to be adjusted;
[0025] The first modifying unit is configured to modify the detection group label field of the container to be adjusted to a predetermined value.
[0026] Optionally, the first allocating unit is specifically configured to:
[0027] Determine a target subcontainer contained in the target container;
[0028] The memory bandwidth usage detection tag is assigned to the first detection group tag field and the second detection group tag field of the target sub-container.
[0029] Optionally, the container memory bandwidth usage detection device further includes:
[0030] A third acquiring unit, configured to acquire a container creation function in response to the container creation instruction;
[0031] The initialization unit is used to call the container creation function to initialize the detection group label field corresponding to the container to be created to a predetermined value.
[0032] Optionally, the container memory bandwidth usage detection device further includes:
[0033] A first detection unit, configured to detect a parent-child relationship between the container to be created and the created container;
[0034] An updating unit is configured to update a value of the detection group tag field of the container to be created based on a value of the detection group tag field of the target created container when the container to be created is a child container of a target created container.
[0035] Optionally, the container memory bandwidth usage detection device further includes:
[0036] a fourth acquiring unit, configured to acquire a container release function in response to a release instruction for a container to be released;
[0037] The second modifying unit is configured to call the container release function to modify the third detection group tag field of the container to be released to a predetermined value.
[0038] Optionally, the first allocating unit is specifically configured to:
[0039] Obtaining a container status of the target container, where the container status includes one of an online state and an offline state;
[0040] A memory bandwidth usage detection tag is allocated to the target container based on the container state of the target container.
[0041] Optionally, the container memory bandwidth usage detection device further includes:
[0042] a second detection unit, configured to detect changes in the container state of the target container;
[0043] The second allocating unit is configured to reallocate the memory bandwidth usage detection tag to the target container based on the changed container state when the container state of the target container changes.
[0044] The container memory bandwidth usage detection method in the embodiment of the present disclosure determines, in response to a memory bandwidth usage detection instruction for a target container, a container tag corresponding to the target container; assigns the memory bandwidth usage detection tag to the target container; obtains a memory bandwidth usage detection result of a process corresponding to the memory bandwidth usage detection tag; and determines, based on the container tag, a container memory bandwidth usage detection result of a process in the target container from the memory bandwidth usage detection result.
[0045] In this way, the container memory bandwidth occupancy detection method of the embodiment of the present disclosure assigns a memory bandwidth occupancy detection tag to the target container, so that the memory bandwidth occupied by all processes in the target container can be detected through a unified memory bandwidth occupancy detection tag. Therefore, when the processes in the target container frequently change, the processes in the target container will always use the memory bandwidth occupancy detection tag corresponding to the target container for memory bandwidth detection. In this way, the memory bandwidth occupancy of the process is automatically detected at the container granularity, thereby improving the detection efficiency of memory bandwidth detection for the container.
[0046] Other features and advantages of the present disclosure will be described in the following description, and in part will become apparent from the description, or will be understood by practicing the present disclosure. The purposes and other advantages of the present disclosure can be realized and obtained by the structures particularly pointed out in the description, claims and drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] The accompanying drawings are used to provide a further understanding of the technical solution of the present disclosure and constitute a part of the specification. Together with the embodiments of the present disclosure, they are used to explain the technical solution of the present disclosure and do not constitute a limitation to the technical solution of the present disclosure.
[0048] Figure 1 This is a system architecture diagram of an application of a container memory bandwidth usage detection method according to an embodiment of the present disclosure;
[0049] Figure 2A-2B This is a schematic diagram of a method for detecting memory bandwidth usage of a container according to an embodiment of the present disclosure, applied to a scenario where memory bandwidth usage is detected when a process fails within a container;
[0050] Figure 3 This is a flowchart of a method for detecting container memory bandwidth usage according to an embodiment of the present disclosure;
[0051] Figure 4 is a schematic diagram of printing a container label in a command window according to an embodiment of the present disclosure;
[0052] Figure 5 This is a schematic diagram of allocating memory bandwidth usage detection tags to containers according to an embodiment of the present disclosure;
[0053] Figure 6 is a schematic diagram of writing a container tag into a container tag set in a command window according to an embodiment of the present disclosure;
[0054] Figure 7A-7B is a schematic diagram of assigning a value to a first detection group label field in a target container according to an embodiment of the present disclosure;
[0055] Figure 8 is a schematic diagram of register parameters according to an embodiment of the present disclosure;
[0056] Figure 9 This is a schematic diagram of viewing memory bandwidth usage detection results in a command window according to an embodiment of the present disclosure;
[0057] Figure 10 is another flowchart of a method for detecting container memory bandwidth usage according to an embodiment of the present disclosure;
[0058] Figure 11 This is a structural diagram of a device for detecting container memory bandwidth usage according to an embodiment of the present disclosure;
[0059] Figure 12 is a diagram of a terminal structure for implementing various methods according to an embodiment of the present disclosure;
[0060] Figure 13 It is a server structure diagram for implementing various methods according to an embodiment of the present disclosure. DETAILED DESCRIPTION
[0061] In order to make the purpose, technical solutions and advantages of the present disclosure more clearly understood, the present disclosure is further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present disclosure and are not intended to limit the present disclosure.
[0062] Before further explaining the embodiments of the present disclosure in detail, the nouns and terms involved in the embodiments of the present disclosure are explained. The nouns and terms involved in the embodiments of the present disclosure are subject to the following interpretations:
[0063] Container: Software that virtually packages and isolates applications for deployment. Container technology effectively divides the resources of a single operating system into isolated groups, allowing for better balancing of conflicting resource usage demands between these groups. Each group is represented as a container, which packages the necessary components of a program, including files, environment variable dependencies, and libraries, and is isolated from other containers. The host operating system limits a container's access to physical resources, such as central processing units, storage, and memory, so a single container cannot consume all of the host operating system's physical resources.
[0064] Memory bandwidth: Memory bandwidth refers to the ability of a computer system's memory and processor to transfer data per unit time. It can be used to measure system performance, particularly in applications involving large amounts of data transfer and processing. Memory bandwidth is calculated by dividing the memory capacity during a memory access period by the memory access time. Memory bandwidth is typically expressed in units of data transferred per second, such as megabytes per second (MB / s) or gigabytes per second (GB / s). A higher memory bandwidth indicates better memory performance, allowing for greater amounts of data to be transferred, and ultimately, improved system performance.
[0065] Process: An independent unit for resource allocation and scheduling in the operating system. Each process has an independent address space and does not affect each other.
[0066] Thread: The basic unit of processor task scheduling and execution. A process has at least one thread, and resources between threads are shared.
[0067] A virtual machine is a complete computer system simulated by software, with full hardware system functionality, running in a completely isolated environment. Any tasks that can be performed on a physical computer can also be performed on a virtual machine. When creating a virtual machine on a computer, a portion of the physical computer's hard drive and memory capacity is used as the virtual machine's hard drive and memory capacity.
[0068] Resource Director Technology (RDT): This technology has the ability to detect and allocate memory bandwidth resource usage. It can detect the memory bandwidth resources occupied by each processor running thread in the operating system through a series of instructions and allocate memory bandwidth resources to each thread.
[0069] Resource Monitoring Identity Document (RMID): The operating system assigns a software-defined tag, called an RMID, to each application or virtual machine in the system. RMIDs enable simultaneous monitoring of independent threads running on multiple processors. Threads can be monitored individually or in groups.
[0070] Resource Control Filesystem (Resctrl Filesystem): A pseudo-filesystem used to configure resource allocation technology. It provides an interface that allows operating system administrators to interact with the background execution of resource allocation technology to view the results of memory bandwidth resource detection and allocation.
[0071] Quality of Service (QoS): refers to a network's ability to use various basic technologies to provide better service for specified network communications. It is a network security mechanism used to solve problems such as network delay and congestion.
[0072] In cloud computing technology, it is necessary to detect the amount of memory bandwidth occupied by each process in the system in order to achieve reasonable allocation of memory bandwidth for each process. In related technologies, resource director technology (RDT) can be used to detect the memory bandwidth usage of processes. In RDT technology, a resource monitoring identity document (RMID) can be assigned to a process. After a RMID is assigned to a process, the memory bandwidth usage of the corresponding process can be detected using the RMID. Each process can be detected independently, that is, each process corresponds to an RMID; or it can be detected in groups, that is, multiple processes are assigned the same RMID. The process of detecting each RMID using RDT technology can be managed using the resource control file system (Resctrl file system). The Resctrl file system contains multiple detection groups. The process tag of a process is added to a detection group, and processes in the same detection group can be assigned the same RMID. RDT technology can detect the memory bandwidth usage of the processes in the detection group based on the RMID corresponding to the detection group.
[0073] With the development of cloud computing technology, more and more transactions are beginning to be processed using container technology. Since a cloud computing system can contain multiple independent containers, different containers have different memory bandwidth usage requirements. Therefore, it is necessary to detect the memory bandwidth occupancy of each container. However, the related art cannot detect the memory bandwidth occupancy at the granularity of the container. This is because the processes in the container sometimes change frequently, and it is difficult to assign the same RMID to the frequently changing processes to achieve unified detection of the processes in the container. The speed of manually assigning the same RMID to the processes in the same container is slow, which leads to low efficiency of memory bandwidth detection for the container. In this regard, the embodiment of the present disclosure provides a method for detecting the memory bandwidth occupancy of a container, in order to improve the efficiency of detecting the memory bandwidth occupancy of a container.
[0074] System architecture and scenario description of the application of the embodiments of the present disclosure
[0075] Figure 1 This is a system architecture diagram for a method for detecting container memory bandwidth usage according to an embodiment of the present disclosure, including a terminal 140, the Internet 130, a gateway 120, a server 110, and the like.
[0076] Terminal 140 includes various forms, such as desktop computers, laptops, PDAs (personal digital assistants), mobile phones, in-vehicle terminals, home theater terminals, and dedicated terminals. Furthermore, it can be a single device or a collection of multiple devices. For example, multiple devices connected via a local area network and sharing a common display device can collectively constitute terminal 140. Terminal 140 can also communicate with Internet 130 via wired or wireless means to exchange data.
[0077] Server 110 is a computer system that provides certain services to terminal 140. Compared to ordinary terminal 140, server 110 has very high requirements in terms of stability, security, and performance. Server 110 can be a single high-performance computer in a network platform, a cluster of multiple high-performance computers, a portion of a single high-performance computer (e.g., a virtual machine), or a combination of portions of multiple high-performance computers (e.g., virtual machines).
[0078] Gateway 120, also known as a gateway or protocol converter, implements network interconnection at the transport layer and is a computer system or device that performs a conversion function. It acts as a translator between two systems using different communication protocols, data formats, languages, or even completely different architectures. Gateways can also provide filtering and security functions. Messages sent from terminal 140 to server 110 are sent through gateway 120 to the corresponding server 110. Messages sent from server 110 to terminal 140 are also sent through gateway 120 to the corresponding terminal 140.
[0079] The container memory bandwidth usage detection method of the embodiment of the present disclosure can be implemented entirely on the terminal 140 ; can be implemented entirely on the server 110 ; or can be implemented partially on the terminal 140 and the other partially on the server 110 .
[0080] The embodiments of the present disclosure can be applied in various scenarios, such as Figure 2A-2B The following figure shows the memory bandwidth usage detection scenario when a process in a container fails.
[0081] exist Figure 2A In the example, the memory bandwidth usage detection tag corresponding to container D1 is '03', which contains the running process P1. The memory bandwidth usage detection tag '03' is currently being detected, and the memory bandwidth occupied by container D1 is 4125MB / s. When process P1 fails, a new process will be created to replace process P1. Figure 2B As shown, the new process that replaced process P1 is process P2. The memory bandwidth usage detection tag currently being tested is still '03'. The memory bandwidth used by container D1 is the sum of the memory bandwidth usage before the process replacement (4125 MB / s) and the memory bandwidth usage after the process replacement (4403 MB / s), totaling 8528 MB / s.
[0082] If a different RMID is assigned to each process for memory bandwidth detection of the process, then process P1 and process P2 will be assigned different RMIDs. After the process is replaced by P1 to P2, the currently detected RMID will also change. Therefore, process P1 and process P2 cannot uniformly perform memory bandwidth detection, and the obtained detection results cannot reflect the memory bandwidth occupancy of the container. Manually assigning the same RMID to process P1 and process P2 is inefficient. The container memory bandwidth occupancy detection method of the embodiment of the present disclosure realizes that the changed processes in the container are uniformly and automatically detected using the memory bandwidth occupancy detection tag corresponding to the container. The detection result can reflect the memory bandwidth occupied by the process in the container, thereby improving the detection efficiency of memory bandwidth occupancy detection for the container.
[0083] General description of the embodiments of the present disclosure
[0084] According to an embodiment of the present disclosure, a method for detecting the memory bandwidth usage of a container is provided. The method can be used for Figure 2A-2B The following figure shows the memory bandwidth usage detection scenario when a process in a container fails.
[0085] The container memory bandwidth occupancy detection method of the embodiment of the present disclosure can be applied to a container memory bandwidth occupancy detection device. Figure 3 FIG. 1 is a flow chart of a method for detecting container memory bandwidth usage provided by the present disclosure. The method for detecting container memory bandwidth usage may include:
[0086] Step 310: In response to the memory bandwidth usage detection instruction for the target container, determine a container tag corresponding to the target container.
[0087] The target container is the container in the system that requires container-level memory bandwidth usage detection. The memory bandwidth usage detection instruction specifies the need to perform memory bandwidth usage detection on the target container. This instruction can be generated when the target container is created, allowing for rapid memory bandwidth usage detection of the container while processes within the container are running. Upon receiving the memory bandwidth usage detection instruction for the target container, the container tag corresponding to the target container can be determined. Each container is associated with a unique container tag.
[0088] In one embodiment, the container tag can be determined by a memory bandwidth usage detection instruction. The memory bandwidth usage detection instruction can include a container tag field of the target container, from which the container tag corresponding to the target object can be determined.
[0089] In another embodiment, the container label can be determined by a container label printing instruction. When the container label printing instruction is executed in the server 110 or the terminal 140, the container label of the target container can be obtained. Figure 4 As shown, a container label printing instruction is input in the command window, and the container label of the target container is obtained as '3'. The command window is used to input text instructions so that the operating system or application program runs or calls the corresponding program according to the text instructions.
[0090] After receiving the memory bandwidth usage detection instruction for the target container, the container label printing instruction can be manually input into server 110 or terminal 140, and the container label can be called in the directory corresponding to the target container. For example, the container label printing instruction is "memory.id". Entering the "memory.id" command in the target container directory will print the container label corresponding to the target container.
[0091] The container label printing instruction may also be included in the memory bandwidth usage detection instruction. In response to the memory bandwidth usage detection instruction, the container label printing instruction may be automatically retrieved from the instruction to obtain the container label of the target container.
[0092] Step 320: Allocate a memory bandwidth usage detection tag to the target container.
[0093] The memory bandwidth occupied by the process in the target container can be detected based on the memory bandwidth occupancy detection tag. Not only the threads and virtual machines contained in the process container can also be detected based on the memory bandwidth occupancy detection tag. Different containers can be assigned the same memory bandwidth occupancy detection tag. The container and threads, processes and virtual machines outside the container can also be assigned the same memory bandwidth occupancy detection tag. Threads, processes and virtual machines outside the container may not belong to any container, or the container to which they belong may not be assigned any memory bandwidth occupancy detection tag. For example Figure 5 As shown, the container and the threads, processes and virtual machines outside the container are assigned the same memory bandwidth occupancy detection label, and the memory bandwidth occupancy detection label can be RMID. When it is necessary to perform memory bandwidth occupancy detection on the processes inside the container or the threads, processes and virtual machines outside the container, the corresponding memory bandwidth occupancy detection label can be determined by using the mapping relationship between the container or the threads, processes and virtual machines outside the container and the memory bandwidth occupancy detection label. The memory bandwidth occupancy detection label is used to perform memory bandwidth occupancy detection on the threads, processes and virtual machines outside the container. When the memory bandwidth occupancy detection label is RMID, the memory bandwidth occupancy of the container corresponding to each RMID can be detected by the RDT hardware.
[0094] In one embodiment, allocating a memory bandwidth usage detection tag to a target container includes:
[0095] Get the container status of the target container;
[0096] A memory bandwidth usage detection label is assigned to the target container based on the container status of the target container.
[0097] The container state can include either an online state or an offline state. By assigning a memory bandwidth usage detection tag to the target container based on the container state, the same memory bandwidth usage detection tag can be assigned to containers with the same container state. For example, when the container state of the target container is online, the target container is assigned a memory bandwidth usage detection tag corresponding to an online container; when the container state of the target container is offline, the target container is assigned a memory bandwidth usage detection tag corresponding to an offline container.
[0098] Since the container state of the container may change, in one embodiment, after allocating the memory bandwidth usage detection tag to the target container based on the container state of the target container, the following steps are further included:
[0099] Perform change detection on the container status of the target container;
[0100] When the container state of the target container changes, the memory bandwidth usage detection label is reallocated to the target container based on the changed container state.
[0101] After assigning a memory bandwidth occupancy detection tag to the target container, the container status of the target container can also be detected for changes in real time. When a change in the container status of the target container is detected, the memory bandwidth occupancy detection tag corresponding to the target container is adjusted. For example, the memory bandwidth occupancy detection tag corresponding to the online container is '01', and the memory bandwidth occupancy detection tag corresponding to the offline container is '02'. When assigning a memory bandwidth occupancy detection tag to the target container, the container status of the target container is online, so the memory bandwidth occupancy detection tag assigned to the target container is '01'. After the process in the target container ends, the container status can be changed from online to offline, so the memory bandwidth occupancy detection tag of the target container is reallocated to '02'.
[0102] By detecting changes in the container status of the target container and adjusting the memory bandwidth usage detection tag according to the container status, the memory bandwidth usage detection tag of the target container can be adjusted in time according to the container status to perform memory bandwidth detection, thereby improving the allocation efficiency of the memory bandwidth usage detection tag for the target container and further improving the accuracy of memory bandwidth usage detection for containers in different container states.
[0103] Assigning memory bandwidth usage detection tags based on container status enables unified memory bandwidth usage detection for containers in the same state. For example, container D1 is online, container D2 is online, container D3 is offline, and container D4 is offline. Online containers are assigned the memory bandwidth usage detection tag '01', while offline containers are assigned the memory bandwidth usage detection tag '02'. Using the memory bandwidth usage detection tag '01' for online containers D1 and D2, the memory bandwidth usage detection result is 9562 MB / s. Using the memory bandwidth usage detection tag '02' for offline containers D3 and D4, the memory bandwidth usage detection result is 1025 MB / s. Since offline containers require less memory bandwidth, after obtaining these detection results, the memory bandwidth occupied by the offline containers can be transferred to the online containers, improving the data transmission efficiency of the online containers. This shows that detecting the memory bandwidth usage of different containers according to their container status can reflect the mutual interference of memory bandwidth usage between containers in different container states, so as to reasonably allocate memory bandwidth resources, avoid resource competition among containers in different container states, and improve the operating efficiency of the operating system.
[0104] In one embodiment, the memory management parameters of the target container include a first detection group tag field. Based on this, assigning a memory bandwidth usage detection tag to the target container includes:
[0105] determining a target detection group corresponding to the target container in at least one detection group;
[0106] Assign the first target memory bandwidth occupancy detection label corresponding to the target detection group to the first detection group label field.
[0107] The first detection group tag field can indicate the memory bandwidth occupancy detection tag assigned to the target container. When the memory bandwidth occupancy detection tag is RMID, the first detection group tag field can also be set to "RMID". For example, "RMID=01" can indicate that the memory bandwidth occupancy detection tag assigned to the target container is '01'. The first detection group tag field in the memory management parameters of the target container can be assigned an initial value when the target container is created. After responding to the memory bandwidth occupancy detection instruction for the target container and assigning the memory bandwidth occupancy detection tag to the target container, the value of the first detection group tag field can be changed to the memory bandwidth occupancy detection tag.
[0108] Therefore, in one embodiment, the method for detecting container memory bandwidth usage further includes:
[0109] In response to the container creation instruction, obtaining a container creation function;
[0110] The container creation function is called to initialize the detection group label field corresponding to the container to be created to a predetermined value.
[0111] The container creation function is used to create a container and initialize the memory management parameters of the container to be created. For example, the container creation function can be set to "mem_cgroup_css_alloc()".
[0112] After calling the container creation function, the container creation function can initialize the detection group tag field corresponding to the container to be created to a predetermined value. This predetermined value can be the default value of the container's detection group tag field, which is used to indicate that the container has not been assigned any memory bandwidth usage detection tags. For example, this predetermined value is -1. When the value of a container's target detection group tag field is equal to -1, it can indicate that the container has not been assigned any memory bandwidth detection tags.
[0113] In another embodiment, after calling the container creation function to initialize the detection group tag field corresponding to the container to be created to a predetermined value, the container memory bandwidth usage detection method further includes:
[0114] Detect the parent-child relationship between the container to be created and the container that has already been created;
[0115] When the container to be created is a child container of a target container that has been created, the value of the detection group tag field of the container to be created is updated based on the value of the detection group tag field of the target container that has been created.
[0116] Because the container to be created may be a child of an existing container in the operating system, the computing resources required by the child container can be allocated using its parent container. Therefore, when creating a container, a parent-child relationship check can be performed between the container to be created and the existing containers to determine whether the container to be created is a child of any existing container.
[0117] When the parent container of the container to be created does not exist in the created containers, the detection group tag field of the container to be created can remain at the initialized predetermined value. When the parent container of the container to be created exists in the created containers, the parent container is determined as the target created container, and the value of the detection group tag field of the container to be created is updated based on the value of the detection group tag field of the target created container. Specifically, the value of the detection group tag field of the target created container can be transferred to the detection group tag field of the container to be created, so that the value of the detection group tag field of the container to be created is consistent with that of the target created container.
[0118] For example, if the memory bandwidth usage detection tag pre-assigned to container D2 is '01', then the value of the detection group tag field of container D2 is '01'. When container D1 is created, the detection group tag field of container D1 is first initialized to -1. After determining that container D1 is a child container of container D2, the value of the detection group tag field of container D2 is passed to the detection group tag field of container D1, which means that the memory bandwidth usage detection tag assigned to container D1 is also '01'. The memory bandwidth usage detection tag '01' can be used to perform unified memory bandwidth usage detection on the processes in containers D1 and D2.
[0119] In the above embodiment, the detection group tag field of the container to be created can be updated based on the value of the detection group tag field of the parent container of the container to be created. This allows the container to be created to be directly detected using the same memory bandwidth usage detection tag as the corresponding parent container, thereby improving the efficiency of allocating memory bandwidth usage detection tags to the container to be created. Furthermore, because the memory bandwidth usage of a child container affects the memory bandwidth usage of the parent container, using the same memory bandwidth usage detection tag for both the parent container and the child container can also improve the accuracy of memory bandwidth usage detection for the container.
[0120] Creating a new container by using a container creation function and initializing the detection group label field to a predetermined value can quickly determine the allocation status of memory bandwidth occupancy detection labels for the container to be created through the detection group label field.
[0121] When a container is no longer needed, the resources occupied by the container need to be released in order to save memory resources. Therefore, in one embodiment, the method for detecting the container memory bandwidth usage also includes:
[0122] In response to a release instruction for a container to be released, obtaining a container release function;
[0123] The container release function is called to modify the third detection group tag field of the container to be released to a predetermined value.
[0124] When resources occupied by a container need to be released, a release instruction can be issued for the container to be released. In response to the release instruction, a container release function is retrieved. The container release function is used to release the memory and other related resources occupied by the container. For example, a container release function is set to "mem_cgroup_free()".
[0125] The container release function may also modify the third detection group tag field corresponding to the container to be released to a predetermined value while releasing the resources occupied by the container, indicating that the container no longer needs to be tested for memory bandwidth usage.
[0126] When the container to be released contains sub-containers, the sub-containers of the container to be released can also be traversed, and the third detection group label field corresponding to the sub-container can also be modified to a predetermined value. The predetermined value can be the default value of the third detection group label field when the container is not assigned any memory bandwidth occupancy detection label. For example, when the container is not assigned any memory bandwidth occupancy detection label, the value of the third detection group label field of the container and its sub-containers is -1. After the memory bandwidth occupancy detection label is assigned to the container, the third detection group label field of the container and its sub-containers is assigned a value of 1. After the resources occupied by the container are released, the target detection group label field of the container and its sub-containers is restored to -1.
[0127] Using the container release function to release the resources occupied by the container can improve the efficiency of resource release.
[0128] When allocating a memory bandwidth usage detection tag to a target container, a target detection group corresponding to the target container may be determined in at least one detection group. Each detection group corresponds to a memory bandwidth usage detection tag.
[0129] A detection group can include containers monitored using corresponding memory bandwidth usage detection tags, as well as processes whose memory bandwidth usage needs to be detected. These processes may not belong to any container, or they may belong to a container but the container has not been assigned a memory bandwidth usage detection tag. Containers and processes in the same detection group have the same memory bandwidth usage detection tag, and their memory bandwidth usage can be detected together.
[0130] In one embodiment, determining a target detection group corresponding to the target container in at least one detection group includes:
[0131] Get the number of containers and processes included in each detection group;
[0132] A target detection group corresponding to the target container is determined in at least one detection group based on the number of containers and the number of processes.
[0133] Containers and processes detected using the same detection group can be stored in different files under the detection group directory. For example, the detection group directory contains a file named "cgroups," which stores the container labels of containers detected using the memory bandwidth usage detection label corresponding to the detection group; the detection group directory also contains a file named "tasks," which stores the process labels of processes detected using the memory bandwidth usage detection label corresponding to the detection group. Therefore, the number of containers included in each detection group can be obtained by determining the number of container labels stored in the "cgroups" file under each detection group directory; the number of processes included in each detection group can be obtained by determining the number of process labels stored in the "tasks" file under each detection group directory.
[0134] Since the containers and processes in the detection group are detected using the same memory bandwidth usage detection label, a target detection group can be determined for the target container based on the number of containers and processes that each detection group is responsible for detecting.
[0135] The ability of each detection group to perform memory bandwidth occupancy detection is limited, and the number of containers and processes that the detection group is responsible for detecting can indirectly reflect the remaining detection capacity of the detection group. The smaller the number of containers and processes that a detection group is responsible for detecting, the higher the remaining detection capacity of this detection group. Therefore, based on the number of containers and the number of processes, the target detection group corresponding to the target container in at least one detection group can be determined as the target detection group by determining the detection group with the smallest sum of the number of containers and the number of processes in at least one detection group. For example, the number of containers contained in detection group M1 is 2, and the number of processes is 3; the number of containers contained in detection group M2 is 1, and the number of processes is 2; the number of containers contained in detection group M3 is 0, and the number of processes is 2. The sum of the number of containers and the number of processes in detection group M3 is 2, which is the smallest among multiple detection groups, so detection group M3 is determined as the target detection group for the target container.
[0136] Determining the target detection group corresponding to the target container based on the number of containers and processes corresponding to each detection group can select the target detection group that can bring the best detection effect for the target container by evaluating the detection capability of each detection group, thereby improving the efficiency of memory bandwidth detection of the target container using the memory bandwidth occupancy detection label corresponding to the target detection group.
[0137] After obtaining the target detection group, the first target memory bandwidth occupancy detection tag corresponding to the target detection group is assigned to the first detection group tag field in the target container.
[0138] In one embodiment, the target detection group includes a container tag set, which includes the container tag corresponding to the container for which memory bandwidth usage detection is performed using the first target memory bandwidth usage detection tag. In the aforementioned embodiment, the "cgroups" file contained in the detection group directory can be considered a container tag set.
[0139] Assigning the first target memory bandwidth occupancy detection label corresponding to the target detection group to the first detection group label field includes:
[0140] Write the container label corresponding to the target container into the container label set of the target detection group;
[0141] The container assignment function corresponding to the container tag set is called to assign the first target memory bandwidth occupancy detection tag corresponding to the target detection group to the first detection group tag field.
[0142] After determining a target detection group for a target container, the container tag corresponding to the target container can be written to the container tag set corresponding to the target detection group. When memory bandwidth usage detection is required for a container corresponding to one of the container tags in the container tag set, the container tag set can be used to identify other containers that need to be detected.
[0143] The container tag corresponding to the target container is written into the container tag set corresponding to the target detection group. After obtaining the target detection group, the program can be automatically executed to write the container tag into the container tag set; or the container tag can be manually written into the container tag set in the command window of the server 110 or the terminal 140. Figure 6 As shown, after entering the "Show folders and files command in the directory" under the target detection group in the command window, the directory of the target detection group is displayed, which contains: container tag set, process tag set and detection data. The container tag set has been described in detail and will not be repeated here; the process tag set can store all process tags corresponding to processes that use the first target memory bandwidth occupancy detection tag corresponding to the target detection group to perform memory bandwidth occupancy detection; the detection data is used to store the detection data obtained by using the first target memory bandwidth occupancy detection tag corresponding to the target detection group to perform memory bandwidth occupancy detection. After entering the "Write container tag 3 to container tag set command" in the command window, the container tag '3' can be added to the container tag set. In order to verify whether the container is added to the container tag set, you can enter the "View container tag set command". The command window shows that the first target memory bandwidth occupancy detection tag corresponding to the target detection group is '1', and the container tag contained in the container tag set of the target detection group is '3'.
[0144] When the container tag set senses that a container tag has been written, the container assignment function corresponding to the container tag set can be automatically called. The container assignment function is an encapsulated function body that is used to assign the first target memory bandwidth occupancy detection tag corresponding to the target detection group to the first detection group tag field in the target container. The container assignment function can be stored in a specific function array under the target detection group directory. The function array can store multiple functions that can implement different tasks in the target detection group. When a task is triggered in the target detection group, the corresponding function can be called from the function array to execute the task. The function array can be named "res_common_files".
[0145] The specific process of writing the container tag of the target container into the container tag set of the target detection group and assigning the first target memory bandwidth usage detection tag to the first detection group tag field in the target container can be as follows: Figure 7A-7BAs shown in the figure, the container tag of the target container is '3'. Before the memory bandwidth usage detection tag is assigned to the target container, the value of the first detection group tag field of the container is '-1'. Figure 7A After writing the container label into the target detection group's container label set, call the container assignment function in the function array. Figure 7B As shown, the container assignment function assigns the first target memory bandwidth usage detection tag corresponding to the target detection group to the first detection group tag field of the target container. At this time, the value of the first detection group tag field is '1'.
[0146] The container tag corresponding to the target container is written into the container tag set of the target detection group, and the first target memory bandwidth occupancy detection tag is assigned to the first detection group tag field in the target container using the container assignment function. This helps the target detection group manage the containers detected using the first target memory bandwidth occupancy detection tag, thereby improving the detection efficiency of the target detection group.
[0147] In one embodiment, the method for detecting container memory bandwidth usage further includes:
[0148] In response to a detection group deletion instruction for the detection group to be deleted, obtaining a second target memory bandwidth usage detection tag corresponding to the detection group to be deleted;
[0149] Determine that the container having the same detection group tag field as the second target memory bandwidth usage detection tag is the container to be adjusted;
[0150] Modify the detection group label field of the container to be adjusted to a predetermined value.
[0151] When a detection group needs to be deleted, in response to a detection group deletion instruction for the detection group to be deleted, the second target memory bandwidth usage detection tag corresponding to the detection group to be deleted is obtained. All containers in the operating system are traversed and the detection group tag field of each container is identified. The container whose detection group tag field is equal to the second target memory bandwidth usage detection tag is determined as the container to be adjusted, and the detection group tag field of the container to be adjusted is modified to a predetermined value. The predetermined value can be the default value of the detection group tag field when the container is not assigned a memory bandwidth usage detection tag. For example, the predetermined value can be -1.
[0152] For example, the second target memory bandwidth occupancy detection tag corresponding to the detection group to be deleted is 1, and the detection group tag fields of multiple containers are: container D1 (detection group tag: -1), container D2 (detection group tag: 1), container D3 (detection group tag: 2), container D4 (detection group tag: 1), container D5 (detection group tag: 3) and container D6 (detection group tag: -1). Among them, the detection group tag of container D2 and container D4 is 1, which is the same as the second target memory bandwidth occupancy detection tag corresponding to the detection group to be deleted. When the container is not assigned a memory bandwidth occupancy detection tag, the default value of the detection group tag field is -1. Therefore, the detection group tag field of container D2 and container D4 is modified to -1.
[0153] After obtaining a container to be adjusted whose detection group tag field is equal to the second target memory bandwidth usage detection tag corresponding to the detection group to be deleted, modifying the detection group tag field of the container to be adjusted to a predetermined value can ensure that each container that uses the detection group to be deleted to perform memory bandwidth usage detection can be restored to a state where no memory bandwidth usage detection tag is assigned, thereby improving the accuracy of adjusting the container state after the detection group is deleted.
[0154] Since a container can contain sub-containers, in one embodiment, the first target memory bandwidth occupancy detection tag corresponding to the target detection group is assigned to the first detection group tag field, including:
[0155] Determine the target subcontainer contained in the target container;
[0156] The memory bandwidth usage detection tag is assigned to the first detection group tag field and the second detection group tag field of the target sub-container.
[0157] In this embodiment, while the first target memory bandwidth usage detection tag corresponding to the target detection group is assigned to the first detection group tag field of the target container, the first target memory bandwidth usage detection tag is also assigned to the second detection group tag field of the target sub-container contained in the target container. This allows the target container and its target sub-containers to be uniformly detected using the first target memory bandwidth usage detection tag, thereby improving the accuracy of memory bandwidth usage detection for the target container.
[0158] A target detection group label field is added to the memory management parameters of the target container, and the first target memory bandwidth detection label of the target detection group is assigned to the first detection group label field in the target container. This facilitates the rapid acquisition of the first target memory bandwidth usage detection label allocated to the target container directly through the first detection group label field when detecting the memory bandwidth usage of the process in the container, thereby improving detection efficiency.
[0159] Step 330: Obtain a memory bandwidth usage detection result of the process corresponding to the memory bandwidth usage detection tag.
[0160] When the memory bandwidth usage detection tag corresponding to the target container is used to perform memory bandwidth detection, the memory bandwidth detection can be performed on all containers corresponding to the memory bandwidth usage detection tag, and the memory bandwidth usage detection tag can be used to perform statistics uniformly.
[0161] In one embodiment, obtaining a memory bandwidth usage detection result of a process corresponding to a memory bandwidth usage detection tag includes:
[0162] In response to a process switching instruction for a target process in a target container, obtaining a memory bandwidth usage detection tag corresponding to the target container;
[0163] When the memory bandwidth usage detection tag meets a predetermined condition, a memory bandwidth usage detection is performed on the process corresponding to the memory bandwidth usage detection tag;
[0164] Get the memory bandwidth usage detection result.
[0165] When the processor receives a process switching instruction for a target process in a target container, it can obtain the memory bandwidth usage detection tag corresponding to the target container. The process switching instruction for the target process can indicate switching the running process A in the target container to the suspended process B and suspending process A, switching the running process C outside the target container to process B in the target container and suspending process C, or creating a new process in the target container and running it.
[0166] When the memory bandwidth occupancy detection tag meets a predetermined condition, memory bandwidth occupancy detection is performed on the process corresponding to the memory bandwidth occupancy detection tag.
[0167] The predetermined condition may refer to the target container bandwidth occupancy detection tag not being equal to a predetermined value. The predetermined value may be a default value when the target container is not assigned a memory bandwidth occupancy detection tag. For example, the default value is -1, then the predetermined condition may be that the memory bandwidth occupancy detection tag is not equal to -1. When the memory bandwidth occupancy detection tag does not meet this predetermined condition, it may mean that the corresponding container has not been assigned any memory bandwidth occupancy detection tag, and at this time, it is impossible to perform container-level memory bandwidth occupancy detection on the process in the container. If it is necessary to perform container-level memory bandwidth occupancy detection on the target process in the container, a memory bandwidth occupancy detection instruction for the container may be first proposed, and a memory bandwidth occupancy detection tag may be assigned to it, and the memory bandwidth occupancy detection tag may be directly detected. If it is not necessary to perform container-level memory bandwidth occupancy detection on the target process in the container, the process memory bandwidth occupancy detection tag corresponding to the target process may be obtained, and memory bandwidth occupancy detection may only be performed on the target process.
[0168] In one embodiment, when the target process is created, it will be automatically assigned a process memory bandwidth usage detection tag. Different processes can be assigned the same process memory bandwidth usage detection tag, and the process memory bandwidth usage detection tag of a process can also serve as the memory bandwidth usage detection tag corresponding to a container. Since RDT technology can perform memory bandwidth usage detection on processes, based on RDT technology, a process will be automatically assigned an RMID when it is created. If the process belongs to a container, then when the container is assigned an RMID, the process will use the RMID corresponding to the container to detect memory bandwidth usage; if the process does not belong to a specific container or the container to which the process belongs has not been assigned any RMID, then the process can use the RMID corresponding to the process to detect memory bandwidth usage.
[0169] Therefore, when the memory bandwidth occupancy detection tag does not meet the predetermined condition, the process memory bandwidth occupancy detection tag corresponding to the target process can be obtained, and the process memory bandwidth occupancy detection tag is used to perform memory bandwidth occupancy detection on the target process.
[0170] Memory bandwidth usage detection is performed on the process corresponding to the memory bandwidth usage detection tag. The memory bandwidth usage detection tag can be written into the memory bandwidth usage detection module in the central processing unit (CPU) to implement memory bandwidth usage detection on the container and process corresponding to the memory bandwidth usage detection tag in the processor.
[0171] The memory bandwidth usage detection module in the central processing unit can be a model-specific register (MSR). Using the MSR as an interface, the memory bandwidth usage detection of processes running in the CPU can be implemented. MSRs have different register numbers, including "IA32_PQR_ASSOC," "IA32_QM_EVTSEL," and "IA32_QM_CTR." The register numbered "IA32_PQR_ASSOC" is used for memory bandwidth usage detection. Figure 8The figure shows the writable parameters of the "IA32_PQR_ASSOC" register. The "IA32_PQR_ASSOC" register can be written to two parameters: the Class of Service (COS) and the Resource Detection Identifier (RMID). These parameters indicate the service class of the processor's currently running thread and the resource detection tag corresponding to the thread. COS is a set of resource control policies used to classify and prioritize network traffic. COS assigns different priorities and memory bandwidths to different threads based on their operational requirements. COS can be used to determine the importance and performance requirements of threads, enabling network traffic management and detection. RMID is the tag used for memory bandwidth usage detection. When using the RMID corresponding to the target container for memory bandwidth usage detection, the target container's RMID is written to the register. This allows the memory bandwidth usage detection of the process corresponding to that RMID to be performed while the processor is running.
[0172] When using the memory bandwidth occupancy detection module to perform memory bandwidth occupancy detection, the memory bandwidth occupied by the container corresponding to the indicated memory bandwidth occupancy detection tag can be counted to obtain the memory bandwidth occupancy detection result corresponding to the memory bandwidth occupancy detection tag. For example, the memory bandwidth occupancy detection module indicates that the memory bandwidth occupancy detection tag currently being detected is '01', and the containers corresponding to '01' are container D1, container D2, and container D3. Within a time period, the memory bandwidth occupancy corresponding to container D1 is detected to be 1250MB / s, the memory bandwidth occupancy corresponding to container D2 is 2410MB / s, and the memory bandwidth occupancy corresponding to container D3 is 1860MB / s. Therefore, the memory bandwidth occupancy detection result corresponding to the memory bandwidth occupancy detection tag '01' is 1250+2410+1860=5520MB / s.
[0173] If there are multiple processors, each processor contains a memory bandwidth usage detection module. In RDT technology, each processor contains an "IA32_PQR_ASSOC" register. The memory bandwidth usage detection module in each processor can detect the memory bandwidth usage of the containers running on that processor. Since processes and containers running on different processors can also be assigned the same memory bandwidth usage detection tag, the memory bandwidth usage detection tags detected in each processor can be the same or different. For a memory bandwidth usage detection tag, the corresponding memory bandwidth usage detection result is the sum of the detection results obtained by the corresponding processor.
[0174] For example, there are four processors: CPU 0, CPU 1, CPU 2, and CPU 3. The memory bandwidth usage detection tag for CPU 0 is '01', and the memory bandwidth usage detection result during time period T1 is 5520 MB / s. The memory bandwidth usage detection tag for CPU 1 is '02', and the memory bandwidth usage detection result during time period T1 is 4810 MB / s. The memory bandwidth usage detection tag for CPU 2 is '01', and the memory bandwidth usage detection result during time period T1 is 4630 MB / s. The memory bandwidth usage detection tag for CPU 3 is '02', and the memory bandwidth usage detection result during time period T1 is 3710 MB / s. Therefore, the memory bandwidth usage detection result corresponding to the memory bandwidth usage detection tag '01' is 5520 + 4630 = 10150 MB / s, and the memory bandwidth usage detection result corresponding to the memory bandwidth usage detection tag '02' is 4810 + 3710 = 5810 MB / s.
[0175] To view the memory bandwidth usage detection results, you can enter commands in the command window, such as Figure 9 As shown, based on the aforementioned embodiment, each target detection group corresponds to a memory bandwidth occupancy detection tag. The detection data directory under the target detection group directory stores the memory bandwidth occupancy detection results corresponding to the memory bandwidth occupancy detection tag. In the command window, under the detection result directory of the target detection group, you can enter the "View processor 0 memory bandwidth occupancy detection result instruction" to obtain the memory bandwidth occupancy detection result of CPU 0 among multiple processors for the memory bandwidth occupancy detection tag, which is 5520MB / s; enter the "View processor 2 memory bandwidth occupancy detection result instruction" to obtain the memory bandwidth occupancy detection result of CPU 2 among multiple processors for the memory bandwidth occupancy detection tag, which is 4630MB / s; enter the "View global memory bandwidth occupancy detection result instruction" to obtain the total memory bandwidth occupancy detection result of each CPU that performs memory bandwidth occupancy detection for the memory bandwidth occupancy detection tag, which is 10150MB / s.
[0176] When the target process is switched in the processor, the memory bandwidth occupancy detection result corresponding to the memory bandwidth occupancy detection tag corresponding to the target container where the target process is located is obtained, so that the memory bandwidth occupancy detection of the container can be quickly responded to according to the process change, thereby improving the efficiency and accuracy of the memory bandwidth occupancy detection of the target container.
[0177] Step 340: Determine the container memory bandwidth usage detection result of the process in the target container in the memory bandwidth usage detection result based on the container tag.
[0178] The memory bandwidth usage detection result corresponding to the memory bandwidth usage detection tag can include the detection results of multiple corresponding containers. Therefore, the memory bandwidth usage detection result can be used to obtain the container memory bandwidth usage detection result of the process in the target container based on the container tag.
[0179] The memory bandwidth occupancy detection result may include the sum of the detection results of multiple containers corresponding to the memory bandwidth occupancy detection label and the detection result corresponding to each container. Therefore, the detection result of the container memory bandwidth occupancy detection result corresponding to the target container determined based on the container label can directly obtain the detection result corresponding to the container label in the memory bandwidth occupancy detection result. For example, the containers detected by the memory bandwidth occupancy detection label include the target container D1, container D2 and container D3, and the corresponding memory bandwidth occupancy detection result is 15250MB / s, of which the container memory bandwidth occupancy detection result corresponding to the target container D1 is 8840MB / s, the container memory bandwidth occupancy detection result corresponding to the container D2 is 4580MB / s, and the container memory bandwidth occupancy detection result corresponding to the container D3 is 1830MB / s. From this, the container memory bandwidth occupancy detection result corresponding to the target container D1 can be obtained.
[0180] After determining the container memory bandwidth usage detection result of the container, the memory bandwidth resources occupied by each container can be controlled according to the container memory bandwidth usage detection result. Therefore, in one embodiment, the container memory bandwidth usage detection method provided by the present disclosure further includes:
[0181] Determine the maximum memory bandwidth usage required by the container based on the container's running status;
[0182] Memory bandwidth resources are allocated to the container based on the container's maximum memory bandwidth usage and the container's memory bandwidth usage detection results.
[0183] The maximum memory bandwidth required by a container is the amount of memory bandwidth resources required to support the smooth execution of threads and processes in the container. If the memory bandwidth resources used by a container are less than the maximum memory bandwidth, the execution efficiency of threads and processes in the container may be low. If the memory bandwidth resources cannot support the amount of data transmitted in the container, network congestion may occur, causing the container process to crash. If the memory bandwidth resources used by a container exceed the maximum memory bandwidth, the excess memory bandwidth resources do not need to be allocated to the container, and the threads and processes in the container can continue to run efficiently. In this case, the excess memory bandwidth resources will be wasted.
[0184] The running status of a container can be determined by the number of threads or process size running in the container. Both the number of threads and the process size in a container reflect the amount of memory space occupied by computing tasks in the container. Thread size is related to the operating system's memory space. In an operating system, each thread has the same size. Therefore, the maximum memory bandwidth required by a container can be determined based on the number of threads running in the container. The total memory space occupied by threads in the container can be determined based on the number of threads in the container and the memory size of each thread. For example, if there are 8 threads in the container, and each thread occupies 1MB of memory, the total memory space occupied by threads in the container is 8 * 1MB = 8MB. The more threads running in the container, the larger the memory space occupied by computing tasks in the container. To ensure the efficient operation of each thread, the container requires more memory bandwidth resources. The process size in the container indicates the amount of memory space occupied by the container process. The larger the process size, the more memory space the process occupies, and the more memory bandwidth resources the process requires to ensure stable data transmission.
[0185] The maximum memory bandwidth usage required for a container can be determined based on the number of threads or process size running in the container, specifically the memory space occupied by the compute tasks within the container. The larger the memory space occupied by the compute tasks within the container, the larger the maximum memory bandwidth usage can be set for the container. Specifically, the larger the number of threads within the container, the larger the maximum memory bandwidth usage can be set; similarly, the larger the process size within the container, the larger the maximum memory bandwidth usage can be set for the container.
[0186] The operating status of a container can also be determined based on the container's priority in the operating system. Container priorities can be categorized based on actual needs. Containers for critical tasks can be set to high priority, while containers for other routine tasks can be set to low priority. High-priority containers require more memory bandwidth resources and are prioritized even when memory bandwidth resources are insufficient, ensuring that high-priority containers can obtain sufficient memory bandwidth resources to support the execution of critical tasks. Container priorities can be manually set based on the computing tasks performed by each container. Once set, memory bandwidth resources can be automatically allocated to containers of different priorities. The maximum memory bandwidth usage required for a container can be determined based on the container's operating status based on the container's priority in the operating system. The higher the container's priority, the higher the maximum memory bandwidth that can be set.
[0187] The maximum memory bandwidth usage required for a container can be determined based on the container's operating status. This can also be determined based on the memory space usage and priority of the computing tasks in the container. Because the memory space occupied by computing tasks in some containers may be small, but the container's priority may be very high, if the maximum memory bandwidth usage is determined solely based on the memory space usage of the computing tasks in the container, the memory bandwidth allocated to the container may not be able to support the execution of critical tasks in the container. If the maximum memory bandwidth usage is determined solely based on the priority of the container, the memory bandwidth allocated to the container may be wasted, and other containers may not be able to execute computing tasks normally. Therefore, determining the maximum memory bandwidth usage based on the memory space usage and priority of the computing tasks in the container can improve the accuracy of determining the maximum memory bandwidth usage, so that the memory bandwidth resources allocated to the container can efficiently execute the computing tasks in the container.
[0188] Determining the maximum memory bandwidth usage based on the memory space occupied by computing tasks in a container and their priorities may include: determining a first score based on the memory space occupied by computing tasks in the container; determining a second score based on the priority of the container; and determining the maximum memory bandwidth usage based on the first and second scores. The larger the memory space occupied by computing tasks in the container, the higher the first score; similarly, the higher the priority of the container, the higher the second score.
[0189] The maximum memory bandwidth usage can be determined based on the first and second scores. The average of the first and second scores can be calculated. The larger the average, the larger the maximum memory bandwidth usage set for the container. For example, the first score determined based on the space occupied by the computing tasks in container D1 is 80, and the second score determined based on the priority is 50. The average of the first and second scores is (80 + 50) / 2 = 65. The first score determined based on the space occupied by the computing tasks in container D2 is 60, and the second score determined based on the priority is 76. The average of the first and second scores is (60 + 76) / 2 = 68. Therefore, the maximum memory bandwidth usage set for container D1 is smaller than the maximum memory bandwidth usage set for container D2. Using the average to determine the maximum memory bandwidth usage ensures that the memory space occupied by the computing tasks in the container and the priority have the same impact on the memory bandwidth allocation for the container, thereby improving the fairness of memory bandwidth allocation for the container.
[0190] The maximum memory bandwidth usage is determined based on the first and second scores. Alternatively, different weights can be assigned to the first and second scores, and a weighted average of the two scores is calculated. The larger the weighted average, the larger the maximum memory bandwidth usage set for the container. For example, if the weight assigned to the first score is 0.6 and the weight assigned to the second score is 0.4, based on the above example, the weighted average of the first and second scores for container D1 is 80*0.6+50*0.4=68. The weighted average of the first and second scores for container D2 is 60*0.6+76*0.4=66.4. Therefore, the maximum memory bandwidth usage set for container D1 is greater than the maximum memory bandwidth usage set for container D2. Using the weighted average, different weights can be assigned to the first and second scores based on actual application needs. This allows for differentiating the impact of the memory space occupied by computing tasks within the container and the container priority on the container's memory bandwidth allocation, thereby increasing flexibility in allocating memory bandwidth to containers.
[0191] Memory bandwidth resources are allocated to containers based on their maximum memory bandwidth usage and the container memory bandwidth usage detection result. By comparing the maximum memory bandwidth usage of a container with the memory bandwidth usage detection result, if the container memory bandwidth usage detection result is greater than the maximum memory bandwidth usage of the container, it indicates that the memory bandwidth used by the container exceeds the actual memory bandwidth resources required to execute the container's computing tasks. Therefore, some memory bandwidth resources are wasted. This memory bandwidth resource can be allocated to the container whose memory bandwidth usage detection result is less than the corresponding container's maximum memory bandwidth usage.
[0192] For example, container D1's maximum memory bandwidth usage is 3500 MB / s, and its container memory bandwidth usage detection result is 4800 MB / s. Therefore, 4800 - 3500 = 1300 MB / s of container D1's memory bandwidth resources are wasted. Container D2's maximum memory bandwidth usage is 5800 MB / s, and its container memory bandwidth usage detection result is 5200 MB / s. Therefore, the memory bandwidth resources used by container D2 effectively support the execution of its computing tasks, with a shortfall of 5800 - 5200 = 600 MB / s. Container D3's maximum memory bandwidth usage is 4700 MB / s, and its container memory bandwidth usage detection result is 4100 MB / s. Therefore, the memory bandwidth resources used by container D3 also cannot effectively support the execution of its computing tasks, with a shortfall of 4700 - 4100 = 600 MB / s. Therefore, we can allocate the memory occupied by container D1 to container D2, so that container D2's memory bandwidth reaches 5800 MB / s. We can also allocate the memory occupied by container D1 to container D3, so that container D3's memory bandwidth reaches 4700 MB / s. At this point, the memory bandwidth occupied by containers D1, D2, and D3 all reach their respective maximum memory bandwidth usage.
[0193] Determining the maximum memory bandwidth usage required by each container based on its operating status and allocating memory bandwidth resources to each container based on the maximum memory bandwidth usage ensures that each container can maintain efficient operation while also reasonably allocating memory bandwidth resources, which is beneficial to improving the resource utilization of memory bandwidth resources and the service quality of each container.
[0194] The embodiments of the present disclosure are described in detail in conjunction with specific application scenarios.
[0195] like Figure 10 FIG. 1 is another flow chart of the container memory bandwidth usage detection method provided by the present disclosure. The method specifically includes the following steps:
[0196] Step 1010: Perform process switching in the processor.
[0197] Process switching within a processor can involve suspending the currently running process and resuming another previously suspended process, or creating a new process and running it directly. Each processor can run one process, so the processor may need to detect the memory bandwidth usage of the currently running process.
[0198] The processor can be an Intel Xeon processor E5-xxxx v4 series, which provides L3 cache configuration and application performance detection mechanisms, which can detect and analyze the performance and behavior of applications in real time. Some communication-related functions during application operation can be introduced in the Intel Xeon processor E5-xxxx v3 series. The processor can also be some Intel processors that support L2 cache control (such as the Intel Atom processor series). The L2 cache is a temporary storage located between the processor and the memory. It is a cache resource that the processor will access in a short period of time. When the processor calls a large amount of data, it can bypass the memory and call it directly from the cache, thereby speeding up the reading speed. The L3 cache is a shared cache between multiple processors. The L3 cache is usually larger than the L2 cache, but the reading speed is relatively slower.
[0199] The memory bandwidth usage detection process for containers can interact with administrators so that administrators can view the memory bandwidth usage of each container in real time. Therefore, the Resctrl file system can be introduced into the operating system to enable interaction between administrators and memory bandwidth usage detection technology.
[0200] Step 1020: Determine the memory bandwidth usage detection tag of the container corresponding to the process.
[0201] The memory management parameters of each container include an RMID field. The value corresponding to the RMID field indicates the memory bandwidth occupancy detection tag assigned to the container. Each memory bandwidth occupancy detection tag corresponds to a detection group, and the detection group can be used to detect the memory bandwidth occupancy of multiple containers. When assigning a memory bandwidth occupancy detection tag to a container, the container tag corresponding to the container can be written into the CGroups file corresponding to the target detection group, and then the memory bandwidth occupancy detection tag corresponding to the target detection group can be assigned to the RMID field of the container. The CGroups file stores the container tags of the containers that can use the target detection group for memory bandwidth occupancy detection. Therefore, the RMID field values of the containers corresponding to the container tags stored in the CGroups file are the same.
[0202] When a process switches, the "__intel_rdt_sched_in" function is called to find the container corresponding to the process and obtain the RMID field in the container. The function then determines whether the container's memory bandwidth usage detection tag is equal to the default value, which can be -1. If the RMID field value is -1, this indicates that the container has not been assigned any memory bandwidth usage detection tag. Since processes are also assigned a process memory bandwidth usage detection tag when they are created, the process can use the process memory bandwidth usage detection tag to perform memory bandwidth usage detection. Once the container to which the process belongs is assigned a memory bandwidth usage detection tag, the process transitions from process-level memory bandwidth usage detection to container-level memory bandwidth usage detection. The process then begins using the container-specific memory bandwidth usage detection tag to perform memory bandwidth usage detection. Therefore, when the container's RMID field is equal to the default value, the "__intel_rdt_sched_in" function can be used to obtain the process memory bandwidth usage detection tag. If the RMID field is not equal to the default value, this indicates that the container has been assigned a memory bandwidth usage detection tag, and the tag is then retrieved.
[0203] Step 1030: Write the memory bandwidth usage detection tag into the memory bandwidth usage detection module corresponding to the processor.
[0204] After obtaining the memory bandwidth usage detection tag, the memory bandwidth usage detection tag can be written into the memory bandwidth usage detection module corresponding to the processor. The memory bandwidth usage detection module in the processor can be the "IA32_PQR_ASSOC" register. The "IA32_PQR_ASSOC" register contains the RMID field. The memory bandwidth usage detection tag can be written into the RMID field to indicate the memory bandwidth usage detection tag corresponding to the container to which the currently running process in the processor belongs. Memory bandwidth usage detection is then performed on all containers and processes corresponding to the memory bandwidth usage detection tag.
[0205] Step 1040: Perform memory bandwidth occupancy detection on the memory bandwidth occupancy detection tag in the memory bandwidth occupancy detection module.
[0206] While the processor is running, the memory bandwidth usage detection module determines the currently detected memory bandwidth usage detection tag and performs real-time memory bandwidth usage detection on all containers and processes corresponding to the memory bandwidth usage detection tag. Because the memory bandwidth usage detection module performs memory bandwidth usage detection at the container granularity level, even if the processes in the container frequently change, the memory bandwidth usage detection tag indicated by the memory bandwidth usage detection module remains unchanged, allowing the container to be consistently monitored for memory bandwidth usage.
[0207] Step 1050: Count the memory bandwidth usage detection results.
[0208] Obtain memory bandwidth usage detection results from testing the memory bandwidth usage detection tag on the processor. If there are multiple processors, the same memory bandwidth usage detection tag detected by each processor can be counted and aggregated into the detection group corresponding to the memory bandwidth usage detection tag.
[0209] Step 1060: Read the memory bandwidth usage detection result.
[0210] To read memory bandwidth usage test results, enter a read command in the detection group directory in the command window to obtain the memory bandwidth usage test results for the memory bandwidth usage detection tag corresponding to the detection group. Read commands are divided into global read commands and local read commands. Local read commands can be used to read memory bandwidth usage test results detected by a single processor, while global read commands can be used to read test results from memory bandwidth usage detection tags detected by multiple processors.
[0211] In step 1020, the memory bandwidth usage detection tag of the container may be changed in any of the following situations:
[0212] Step 1071: Create a container.
[0213] When creating a container, you can call the mem_cgroup_css_alloc() function to initialize the container state. The container parameters include an RMID field that indicates the memory bandwidth usage detection tag corresponding to the container.
[0214] When creating a container, step 1080 can be executed to modify the memory bandwidth occupancy detection tag corresponding to the container. The mem_cgroup_css_alloc() function will first determine whether the created container is a child container of other containers. When a container is not a child container of any other container, then when creating the container, the mem_cgroup_css_alloc() function can set the default value of the RMID field to -1, indicating that the container was not assigned any memory bandwidth occupancy detection tag when it was created. When a container is a child container of another container, then when creating the container, it can inherit the memory bandwidth occupancy detection tag of its parent container, that is, modify the value of the RMID field so that it is the same as the value of the RMID field in the parent container.
[0215] Step 1072: Release the container.
[0216] When a container no longer needs to perform computing tasks, the computing resources occupied by the container can be released. To release the container, you can call the mem_cgroup_free() function.
[0217] When releasing a container, you can execute step 1080 to modify the memory bandwidth usage detection tag corresponding to the container. Use the mem_cgroup_free() function to modify the RMID field corresponding to the container and the RMID fields of each subcontainer in the container to -1, indicating that the released container is not assigned any memory bandwidth usage detection tag. At the same time, you can also delete the container tag of the container whose computing resources are released in the CGroups file of the target detection group, so that the target detection group will no longer perform memory bandwidth resource detection on the container.
[0218] Step 1073: Add the container label of the container to the target detection group.
[0219] A container's container label can be manually added to a target detection group. In the command window, enter the container label print command. This command calls the memory.id file in the container's configuration file, which stores the container label. After calling the memory.id file, the container label can be printed in the command window. Once the container label is known, add it to the target detection group's CGroups file in the target detection group directory.
[0220] When the container tag of a container is added to the target detection group, the callback function in the res_common_files array can be called. The res_common_files array stores functions for executing different tasks in the target detection group. The callback function is used to pass the memory bandwidth occupancy tag corresponding to the target detection group to the container. Therefore, when the container tag is added to the target detection group, step 1080 can be executed to modify the memory bandwidth occupancy detection tag corresponding to the container. The callback function is used to pass the memory bandwidth occupancy detection tag corresponding to the target detection group to the RMID field of the container corresponding to the container tag, and facilitates all sub-containers under the container to pass the memory bandwidth occupancy detection tag to the RMID field of all sub-containers.
[0221] Step 1074: Delete the target detection group corresponding to the container.
[0222] When the target detection group is deleted, the container corresponding to the target detection group cannot be detected using the memory bandwidth occupancy detection tag of the target detection group. Therefore, it is necessary to execute step 1080 to modify the memory bandwidth occupancy detection tag corresponding to the container. Specifically, the memory bandwidth occupancy detection tag corresponding to the target detection group can be obtained, and then all containers stored in the operating system can be traversed. If the RMID field in the traversed container is equal to the memory bandwidth occupancy detection tag of the target detection group, the RMID fields of the container and its subcontainers are modified to the default value, that is, -1, indicating that the current container and its containers are not assigned any memory bandwidth occupancy detection tags.
[0223] The embodiment of the present disclosure adds an RMID field to the parameters of the container, and determines the target detection group for memory bandwidth occupancy detection of the container by changing the value of the RMID field. Add a CGroups file to the target detection group, add the container label of the container to the CGroups file, and use the target detection group to detect the memory bandwidth occupancy of the container. Through the above process, a mapping relationship between the container and the target detection group is established. When it is necessary to perform memory bandwidth occupancy detection on a frequently changing process in a container, it can be automatically detected according to the memory bandwidth occupancy detection label corresponding to the container, thereby improving the efficiency of memory bandwidth occupancy detection of processes in the container at the container granularity level.
[0224] Description of the apparatus and device of the present disclosure
[0225] It is to be understood that, although the steps in the above-mentioned flowcharts are shown in sequence according to the arrow representations, these steps are not necessarily performed in sequence according to the order represented by the arrows. Unless otherwise specified in the present embodiment, there is no strict order restriction on the execution of these steps, and these steps can be performed in other orders. Moreover, at least a portion of the steps in the above-mentioned flowcharts may include multiple steps or multiple stages, and these steps or stages are not necessarily performed at the same time, but can be performed at different times, and the execution order of these steps or stages is not necessarily performed in sequence, but can be performed in turn or alternately with other steps or at least a portion of the steps or stages in other steps.
[0226] It should be noted that in each specific embodiment of the present disclosure, when it comes to the need to perform relevant processing based on data related to the characteristics of the target object, such as the target object attribute information or attribute information set, the permission or consent of the target object will be obtained first, and the collection, use and processing of such data will comply with the relevant laws, regulations and standards of the relevant region. In addition, when the embodiment of the present application needs to obtain the attribute information of the target object, the target object's separate permission or separate consent will be obtained through a pop-up window or by jumping to a confirmation page. After clearly obtaining the target object's separate permission or separate consent, the necessary target object-related data for the normal operation of the embodiment of the present application will be obtained.
[0227] Figure 11 This is a schematic diagram of the structure of a container memory bandwidth usage detection device 1100 provided in an embodiment of the present disclosure. The container memory bandwidth usage detection device 1100 includes:
[0228] A responding unit 1110 is configured to determine a container tag corresponding to the target container in response to a memory bandwidth usage detection instruction for the target container;
[0229] A first allocating unit 1120 is configured to allocate a memory bandwidth usage detection tag to the target container, and detect the memory bandwidth occupied by the process in the target container based on the memory bandwidth usage detection tag;
[0230] The first acquiring unit 1130 is configured to acquire a memory bandwidth usage detection result of a process corresponding to a memory bandwidth usage detection tag;
[0231] The first determining unit 1140 is configured to determine, based on the container tag, a container memory bandwidth usage detection result of a process in a target container in the memory bandwidth usage detection result.
[0232] Optionally, the memory management parameters of the target container include a first detection group label field;
[0233] The first allocation unit 1120 is specifically configured to:
[0234] Determine a target detection group corresponding to the target container in at least one detection group, where each detection group corresponds to a memory bandwidth usage detection label;
[0235] Assign the first target memory bandwidth occupancy detection label corresponding to the target detection group to the first detection group label field.
[0236] Optionally, the target detection group includes a container tag set, where the container tag set includes a container tag corresponding to a container for performing memory bandwidth usage detection using the first target memory bandwidth usage detection tag;
[0237] The first allocation unit 1120 is specifically configured to:
[0238] Write the container tag corresponding to the target container into the container tag set;
[0239] The container assignment function corresponding to the container tag set is called to assign the first target memory bandwidth occupancy detection tag corresponding to the target detection group to the first detection group tag field.
[0240] Optionally, the container memory bandwidth usage detection device 1100 further includes:
[0241] A second acquiring unit (not shown) is configured to acquire a second target memory bandwidth usage detection tag corresponding to the detection group to be deleted in response to a detection group deletion instruction for the detection group to be deleted;
[0242] A second determining unit (not shown) is configured to determine a container having the same detection group tag field as the second target memory bandwidth usage detection tag as a container to be adjusted;
[0243] The first modifying unit (not shown) is configured to modify the detection group label field of the container to be adjusted to a predetermined value.
[0244] Optionally, the first allocating unit 1120 is specifically configured to:
[0245] Determine the target subcontainer contained in the target container;
[0246] The memory bandwidth usage detection tag is assigned to the first detection group tag field and the second detection group tag field of the target sub-container.
[0247] Optionally, the container memory bandwidth usage detection device 1100 includes:
[0248] A third acquiring unit (not shown), configured to acquire a container creation function in response to the container creation instruction;
[0249] The initialization unit (not shown) is used to call the container creation function to initialize the detection group label field corresponding to the container to be created to a predetermined value.
[0250] Optionally, the container memory bandwidth usage detection device 1100 further includes:
[0251] A first detection unit (not shown), configured to detect a parent-child relationship between a container to be created and an already created container;
[0252] An updating unit (not shown) is configured to update the value of the detection group tag field of the container to be created based on the value of the detection group tag field of the target created container when the container to be created is a child container of the target created container.
[0253] Optionally, the container memory bandwidth usage detection device 1100 further includes:
[0254] a fourth acquiring unit (not shown), configured to acquire a container release function in response to a release instruction for the container to be released;
[0255] The second modifying unit (not shown) is configured to call the container release function to modify the third detection group tag field of the container to be released to a predetermined value.
[0256] Optionally, the first allocating unit 1120 is specifically configured to:
[0257] Get the container status of the target container, where the container status includes one of online status and offline status.
[0258] A memory bandwidth usage detection label is assigned to the target container based on the container status of the target container.
[0259] Optionally, the container memory bandwidth usage detection device 1100 further includes:
[0260] a second detection unit (not shown), configured to detect changes in the container state of the target container;
[0261] The second allocating unit (not shown) is configured to reallocate the memory bandwidth usage detection tag to the target container based on the changed container state when the container state of the target container changes.
[0262] In the embodiments of the present application, the term "module" or "unit" refers to a computer program or a part of a computer program that has a predetermined function and works together with other related parts to achieve a predetermined goal, and can be implemented in whole or in part by using software, hardware (such as processing circuits or memories) or a combination thereof. Similarly, a processor (or multiple processors or memories) can be used to implement one or more modules or units. In addition, each module or unit can be part of an overall module or unit that includes the function of the module or unit.
[0263] Reference Figure 12 , Figure 12 The following is a block diagram of the structure of the object terminal 110 for implementing the container memory bandwidth usage detection method according to an embodiment of the present disclosure. The object terminal 110 includes: a radio frequency (RF) circuit 1210, a memory 1215, an input unit 1230, a display unit 1240, a sensor 1250, an audio circuit 1260, a wireless fidelity (WiFi) module 1270, a processor 1280, and a power supply 1290. It will be understood by those skilled in the art that Figure 12The structure of the target terminal 110 shown does not constitute a limitation on a mobile phone or a computer, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.
[0264] The RF circuit 1210 may be used for receiving and sending signals during information transmission or calls. In particular, after receiving downlink information from the base station, it is sent to the processor 1280 for processing. In addition, the designed uplink data is sent to the base station.
[0265] The memory 1215 may be used to store software programs and modules. The processor 1280 executes various functional applications of the terminal and identifies lane change points by running the software programs and modules stored in the memory 1215 .
[0266] The input unit 1230 may be configured to receive input digital or character information and generate key signal input related to terminal settings and function control. Specifically, the input unit 1230 may include a touch panel 1231 and other input devices 1232 .
[0267] The display unit 1240 may be configured to display input information or provided information and various menus of the terminal. The display unit 1240 may include a display panel 1241 .
[0268] The audio circuit 1260 , the speaker 1261 , and the microphone 1262 may provide an audio interface.
[0269] In this embodiment, the processor 1280 included in the terminal 110 can execute the container memory bandwidth usage detection method of the previous embodiment.
[0270] The target terminal 110 of the embodiment of the present disclosure includes but is not limited to mobile phones, computers, intelligent voice interaction devices, smart home appliances, vehicle terminals, aircraft, etc. The embodiment of the present invention can be applied to various scenarios, including but not limited to cloud computing, computing resource management, etc.
[0271] Figure 13A structural block diagram of a portion of a server 130 for implementing the container memory bandwidth occupancy detection method according to an embodiment of the present disclosure. The server 130 may vary greatly due to different configurations or performance, and may include one or more central processing units (CPUs) 1322 (e.g., one or more processors) and a storage device 1332, and one or more storage media 1330 (e.g., one or more massive storage devices) for storing application programs 1342 or data 1344. The storage device 1332 and the storage medium 1330 may be temporary storage or persistent storage. The program stored in the storage medium 1330 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations on the server 130. Furthermore, the central processing unit 1322 may be configured to communicate with the storage medium 1330 to execute a series of instruction operations in the storage medium 1330 on the server 130.
[0272] The server 130 may also include one or more power supplies 1326, one or more wired or wireless network interfaces 1350, one or more input and output interfaces 1358, and / or one or more operating systems 1341, such as Windows Server™, Mac OS X™, Unix™, Linux™, FreeBSD™, etc.
[0273] The central processing unit 1322 in the server 130 may be configured to execute the container memory bandwidth usage detection method according to an embodiment of the present disclosure.
[0274] The embodiments of the present disclosure further provide a computer-readable storage medium for storing program code, and the program code is used to execute the container memory bandwidth usage detection method of each of the aforementioned embodiments.
[0275] The present disclosure also provides a computer program product, including a computer program, wherein a processor of a computer device reads and executes the computer program, so that the computer device implements the above-mentioned method for detecting container memory bandwidth usage.
[0276] The terms "first," "second," "third," "fourth," and the like (if any) in the specification of the present disclosure and the accompanying drawings are used to distinguish similar objects and are not necessarily used to describe a particular order or precedence. It should be understood that the terms used in this manner are interchangeable where appropriate, so that the embodiments of the present disclosure described herein, for example, can be implemented in orders other than those illustrated or described herein. In addition, the terms "comprises" and "comprising," and any variations thereof, are intended to cover non-exclusive inclusions, e.g., a process, method, system, product, or apparatus comprising a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such process, method, product, or apparatus.
[0277] It should be understood that in the present disclosure, "at least one (item)" refers to one or more, and "plurality" refers to two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship. "At least one of the following items" or similar expressions refers to any combination of these items, including any combination of single items or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.
[0278] It should be understood that in the description of the embodiments of the present disclosure, the meaning of multiple (or multiple items) is more than two, greater than, less than, exceed, etc. are understood to exclude the number itself, and above, below, within, etc. are understood to include the number itself.
[0279] In the several embodiments provided in the present disclosure, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are merely schematic. For example, the division of units is only a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0280] Units described as separate components may or may not be physically separate, and components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.
[0281] In addition, the functional units in the various embodiments of the present disclosure may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.
[0282] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present disclosure is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the various embodiments of the present disclosure. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk, and other media that can store program code.
[0283] It should also be understood that the various implementations provided in the embodiments of the present disclosure can be combined arbitrarily to achieve different technical effects.
[0284] The above is a specific description of the implementation methods of the present disclosure, but the present disclosure is not limited to the above implementation methods. Those skilled in the art can make various equivalent modifications or substitutions without violating the spirit of the present disclosure. These equivalent modifications or substitutions are all included in the scope defined by the claims of the present disclosure.
Claims
1. A method for detecting container memory bandwidth usage, characterized in that: include: In response to a memory bandwidth usage detection instruction for a target container, determining a container tag corresponding to the target container; Allocating a memory bandwidth occupancy detection tag to the target container, and detecting the memory bandwidth occupied by the process in the target container based on the memory bandwidth occupancy detection tag; Obtaining a memory bandwidth occupancy detection result of the process corresponding to the memory bandwidth occupancy detection tag; A container memory bandwidth usage detection result of the process in the target container is determined from the memory bandwidth usage detection result based on the container tag.
2. The method according to claim 1, characterized in that The memory management parameters of the target container include a first detection group label field; The allocating a memory bandwidth usage detection label to the target container includes: Determine a target detection group corresponding to the target container in at least one detection group, where each detection group corresponds to a memory bandwidth usage detection tag; Assign a first target memory bandwidth occupancy detection tag corresponding to the target detection group to the first detection group tag field.
3. The method according to claim 2, characterized in that The target detection group includes a container tag set, where the container tag set includes container tags corresponding to containers for which memory bandwidth usage detection is performed using the first target memory bandwidth usage detection tag; The assigning the first target memory bandwidth occupancy detection label corresponding to the target detection group to the first detection group label field includes: Writing the container tag corresponding to the target container into the container tag set; The container assignment function corresponding to the container tag set is called to assign the first target memory bandwidth occupancy detection tag corresponding to the target detection group to the first detection group tag field.
4. The method according to claim 3, characterized in that The method further comprises: In response to a detection group deletion instruction for the detection group to be deleted, obtaining a second target memory bandwidth occupancy detection tag corresponding to the detection group to be deleted; Determine that a container having the same detection group tag field as the second target memory bandwidth usage detection tag is a container to be adjusted; The detection group label field of the container to be adjusted is modified to a predetermined value.
5. The method according to claim 2, characterized in that The assigning the first target memory bandwidth occupancy detection tag corresponding to the target detection group to the first detection group tag field includes: Determine a target subcontainer contained in the target container; The memory bandwidth usage detection tag is assigned to the first detection group tag field and the second detection group tag field of the target sub-container.
6. The method according to claim 2, characterized in that The method further comprises: In response to the container creation instruction, obtaining a container creation function; The container creation function is called to initialize the detection group label field corresponding to the container to be created to a predetermined value.
7. The method according to claim 6, characterized in that After calling the container creation function to initialize the detection group tag field corresponding to the container to be created to a predetermined value, the method further includes: Performing parent-child relationship detection on the container to be created and the created container; When the container to be created is a child container of a target container that has been created, the value of the detection group tag field of the container to be created is updated based on the value of the detection group tag field of the target container that has been created.
8. The method according to claim 2, characterized in that The method further comprises: In response to a release instruction for a container to be released, obtaining a container release function; The container release function is called to modify the third detection group tag field of the container to be released to a predetermined value.
9. The method according to claim 1, characterized in that The allocating a memory bandwidth usage detection label to the target container includes: Obtaining a container status of the target container, where the container status includes one of an online state and an offline state; A memory bandwidth usage detection tag is allocated to the target container based on the container state of the target container.
10. The method according to claim 9, characterized in that After allocating a memory bandwidth usage detection tag to the target container based on the container status of the target container, the method further includes: Performing change detection on the container state of the target container; When the container state of the target container changes, the memory bandwidth usage detection tag is reallocated to the target container based on the changed container state.
11. A container memory bandwidth usage detection device, characterized in that: include: a response unit, configured to determine a container tag corresponding to the target container in response to a memory bandwidth usage detection instruction for the target container; a first allocating unit, configured to allocate a memory bandwidth occupancy detection tag to the target container, and detect the memory bandwidth occupied by the process in the target container based on the memory bandwidth occupancy detection tag; A first acquiring unit is configured to acquire a memory bandwidth usage detection result of a process corresponding to the memory bandwidth usage detection tag; A first determining unit is configured to determine, based on the container tag, a container memory bandwidth usage detection result of the process in the target container from the memory bandwidth usage detection result.
12. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method for detecting container memory bandwidth usage according to any one of claims 1 to 10 is implemented.
13. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the method for detecting container memory bandwidth usage according to any one of claims 1 to 10 is implemented.
14. A computer program product, comprising a computer program, wherein the computer program is read and executed by a processor of a computer device, so that the computer device executes the container memory bandwidth usage detection method according to any one of claims 1 to 10.