Process access method, device and electronic device
By adding a data structure to record access information for the target variable under the NUMA architecture, and binding the process to the NUMA node corresponding to the target node number when specific conditions are met, the cache consistency overhead caused by concurrent access by multiple processes is solved, and access performance is improved.
Patent Information
- Application Number
- CN202210764410.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-30
- Publication Date
- 2025-05-23
- Estimated Expiration
- 2042-06-30
AI Technical Summary
Under the NUMA architecture, when multiple processes access the same address concurrently, they need to frequently synchronize cache and memory, which greatly increases the cache consistency overhead.
By adding a new member to the data structure of the target variable, the target node number, timestamp, process identity, and target parameters are recorded. When the target variable is accessed by different processes, update this information and bind the process to the NUMA node corresponding to the target node number when specific conditions are met to reduce the cache synchronization overhead across nodes.
It effectively reduces the hardware overhead caused by frequent cache synchronization between multiple NUMA nodes, and improves the process's access performance of shared variables.
Smart Images

Figure CN115016944B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a process access method, device and electronic equipment. Background Art
[0002] NUMA (Non-uniform memory access) is a computer memory design for multiple processors. The memory access time depends on the location of the memory relative to the processor. Under the NUMA architecture, the processor has memory bound to it (called local memory), and the two together form a NUMA node. The processor accesses local memory faster than other memory, that is, local access is faster than remote access.
[0003] In the NUMA architecture, if multiple processes access the same address concurrently, frequent synchronization between the cache and the memory is required, which greatly increases the cache consistency overhead. Summary of the invention
[0004] The embodiments of the present invention provide a process access method, device and electronic device, which can solve the problem of large cache consistency overhead caused by multiple processes concurrently accessing the same address.
[0005] In order to solve the above problem, an embodiment of the present invention discloses a process access method, the method comprising:
[0006] In the case of receiving an access request for a target variable from a process, obtaining access information recorded in a newly added member of the target variable, wherein the data structure of the target variable includes a newly added member, and the newly added member includes 4 bit fields, wherein the first bit field is used to record the target node number, the second bit field is used to record the timestamp of the target process accessing the target variable, the third bit field is used to record the process identifier of the target process accessing the target variable, and the fourth bit field is used to record a target parameter, and when the target variable is accessed by the target process, the target parameter is increased by 1; the target process is any process accessing the target variable, and the target process is different from the process that accessed the target variable last time;
[0007] According to the process identifier recorded in the third bit field, and the process identifier and access time of the process accessing the target variable, updating the accessed information recorded in the second bit field, the third bit field, and the fourth bit field;
[0008] When the update frequency of the timestamp recorded in the second bit field within the first preset time is greater than the first frequency threshold, and the target parameter recorded in the fourth bit field is greater than the preset parameter threshold, the process is bound to the NUMA node corresponding to the target node number so that the process can access the target variable on the NUMA node.
[0009] Optionally, updating the accessed information recorded in the second bit field, the third bit field, and the fourth bit field according to the process identifier recorded in the third bit field, and the process identifier and access time of the process accessing the target variable includes:
[0010] If the process identifier of the process currently accessing the target variable is different from the process identifier recorded in the third bit field, determining that the process is the target process;
[0011] Update the timestamp recorded in the second bit field according to the access time of the target process accessing the target variable;
[0012] Update the process identifier recorded in the third bit field according to the process identifier of the target process;
[0013] The target parameter recorded in the fourth bit field is incremented by 1.
[0014] Optionally, the target process also includes a first process that accesses the target variable.
[0015] Optionally, after binding the process to the NUMA node corresponding to the target node number, the method further includes:
[0016] If the timestamp recorded in the second bit field is not updated within a second preset time, the binding relationship between the process and the NUMA node corresponding to the target node number is released.
[0017] Optionally, after binding the process to the NUMA node corresponding to the target node number, the method further includes:
[0018] If the target parameter is greater than a preset parameter threshold, and the update frequency of the timestamp recorded in the second bit field within a third preset time is greater than a second frequency threshold, the binding relationship between the process and the NUMA node is kept unchanged.
[0019] Optionally, the length of the newly added member is 64 bits.
[0020] Optionally, when receiving an access request from a process for a target variable, obtaining access information recorded in a newly added member of the target variable includes:
[0021] When an access request for a target variable is received from a process, a statistical information interface is called to obtain access information recorded in a newly added member of the target variable.
[0022] On the other hand, an embodiment of the present invention discloses a process access device, the device comprising:
[0023] An information acquisition module, configured to, upon receiving an access request from a process for a target variable, acquire access information recorded in a newly added member of the target variable, wherein the data structure of the target variable includes a newly added member, and the newly added member includes four bit fields, wherein the first bit field is used to record a target node number, the second bit field is used to record a timestamp of a target process accessing the target variable, the third bit field is used to record a process identifier of a target process accessing the target variable, and the fourth bit field is used to record a target parameter, and when the target variable is accessed by the target process, the target parameter is incremented by 1; the target process is any process accessing the target variable, and the target process is different from the process that accessed the target variable last time;
[0024] an information updating module, configured to update the accessed information recorded in the second bit field, the third bit field, and the fourth bit field according to the process identifier recorded in the third bit field, and the process identifier and access time of the process accessing the target variable;
[0025] A process binding module is used to bind the process to the NUMA node corresponding to the target node number when the update frequency of the timestamp recorded in the second bit field within a first preset time is greater than a first frequency threshold and the target parameter recorded in the fourth bit field is greater than a preset parameter threshold, so that the process can access the target variable on the NUMA node.
[0026] Optionally, the information updating module includes:
[0027] a target process determination submodule, configured to determine that the process is a target process if the process identifier of the process currently accessing the target variable is different from the process identifier recorded in the third bit field;
[0028] A second bit field updating submodule, configured to update the timestamp recorded in the second bit field according to the access time of the target process accessing the target variable;
[0029] A third bit field updating submodule, configured to update the process identifier recorded in the third bit field according to the process identifier of the target process;
[0030] The fourth bit field updating submodule is used to add 1 to the target parameter recorded in the fourth bit field.
[0031] Optionally, the target process also includes a first process that accesses the target variable.
[0032] Optionally, the device further comprises:
[0033] A relationship release module is used to release the binding relationship between the process and the NUMA node corresponding to the target node number if the timestamp recorded in the second bit field is not updated within a second preset time.
[0034] Optionally, the device further comprises:
[0035] A relationship maintaining module is used to maintain the binding relationship between the process and the NUMA node unchanged if the target parameter is greater than a preset parameter threshold and the update frequency of the timestamp recorded in the second bit field within a third preset time is greater than a second frequency threshold.
[0036] Optionally, the length of the newly added member is 64 bits.
[0037] Optionally, the information acquisition module includes:
[0038] The information acquisition submodule is used to call the statistical information interface to obtain the access information recorded in the newly added member of the target variable when receiving an access request from the process to the target variable.
[0039] On the other hand, an embodiment of the present invention further discloses an electronic device, which includes a memory and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by one or more processors to perform the aforementioned process access method.
[0040] The embodiment of the present invention further discloses a readable storage medium. When instructions in the storage medium are executed by a processor of an electronic device, the electronic device can execute the aforementioned process access method.
[0041] The embodiments of the present invention include the following advantages:
[0042] An embodiment of the present invention provides a process access method, which can obtain access information of a target variable when receiving an access request from a process to a target variable, wherein the data structure of the target variable includes a newly added member, and the newly added member includes 4 bit fields, wherein the first bit field is used to record the target node number, the second bit field is used to record the timestamp of the target process accessing the target variable, the third bit field is used to record the process identifier of the target process accessing the target variable, and the fourth bit field is used to record the target parameter, when the target variable is accessed by the target process, the target parameter is increased by 1; the target process accesses the target variable any process, the target process is different from the process that accessed the target variable last time; then, according to the process identifier recorded in the third bit field, and the process identifier and access time of the process accessing the target variable, update the accessed information recorded in the second bit field, the third bit field and the fourth bit field; when the update frequency of the timestamp recorded in the second bit field within the first preset time is greater than the first frequency threshold, and the target parameter recorded in the fourth bit field is greater than the preset parameter threshold, bind the process to the NUMA node corresponding to the target node number, so that the process accesses the target variable on the NUMA node. The embodiment of the present invention can bind each process that concurrently accesses the target variable to the same NUMA node when the target variable is accessed concurrently by multiple processes, and convert the concurrent access of the target variable by processes on different NUMA nodes into the concurrent access of the target variable by processes on the same NUMA node, effectively reducing the hardware overhead caused by frequent cache synchronization between multiple NUMA nodes, which is conducive to improving the access performance of the process. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative labor.
[0044] Figure 1 is a flowchart of a process access method embodiment of the present invention;
[0045] Figure 2 It is a structural schematic diagram of a NUMA architecture of the present invention;
[0046] Figure 3 It is a structural block diagram of an electronic device for process access provided by an example of the present invention. DETAILED DESCRIPTION
[0047] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0048] Method Embodiment
[0049] Reference Figure 1 , shows a flowchart of a process access method embodiment of the present invention, the method may specifically include the following steps:
[0050] Step 101: upon receiving an access request from a process for a target variable, obtaining access information recorded in a newly added member of the target variable.
[0051] Step 102: Update the access information recorded in the second bit field, the third bit field, and the fourth bit field of the newly added member according to the process ID recorded in the third bit field, and the process ID and access time of the process accessing the target variable.
[0052] Step 103: When the update frequency of the timestamp recorded in the second bit field within the first preset time is greater than the first frequency threshold, and the target parameter recorded in the fourth bit field is greater than the preset parameter threshold, the process is bound to the NUMA node corresponding to the target node number, so that the process can access the target variable on the NUMA node.
[0053] Among them, the data structure of the target variable includes a new member, and the new member includes 4 bit fields. The first bit field is used to record the target node number, the second bit field is used to record the timestamp of the target process accessing the target variable, the third bit field is used to record the process identifier of the target process accessing the target variable, and the fourth bit field is used to record the target parameter. When the target variable is accessed by the target process, the target parameter is increased by 1; the target process is any process accessing the target variable, and the target process is different from the process that accessed the target variable last time.
[0054] The process access method provided by the embodiment of the present invention can bind each process that concurrently accesses the target variable to the same NUMA node when multiple processes under the NUMA architecture frequently and alternately access the same target variable, thereby avoiding the cache consistency overhead between different nodes and facilitating improving the speed of process access to shared variables.
[0055] It should be noted that in the NUMA architecture, each CPU core has memory bound to it (called local memory), and the two together form a NUMA node. A single NUMA node is connected through a scalable network (I / O bus), so that the CPU can systematically access the memory associated with other NUMA nodes.
[0056] The NUMA architecture may include at least one NUMA node, and each NUMA node may include at least one processor. It should be noted that in an embodiment of the present invention, the processor may be a logical processor. For example, a Node may correspond to a CPUSocket (CPU socket), a physical CPU may be plugged into a CPUSocket, and a physical CPU may include multiple CPUCores (computing cores), and a CPUCore may include multiple logical CPUs (corresponding to the processors in this case). Of course, this is only exemplary, and in an embodiment of the present invention, the structure of the NUMA node is not limited to this.
[0057] Under the NUMA architecture, the read and write consistency of the cache needs to be guaranteed. Specifically, for a single-core system, the data consistency between the cache and the memory needs to be guaranteed; for a multi-core system, not only the consistency between the cache and the memory needs to be guaranteed, but also the consistency between the caches of each CPU needs to be guaranteed. When multiple processes located in different NUMA nodes concurrently access the same shared variable (address), in order to ensure cache consistency, each NUMA node must not only frequently synchronize the local cache with the memory, but also frequently synchronize with each other, resulting in excessive hardware overhead.
[0058] In order to solve this problem, an embodiment of the present invention provides a process access method, which counts the access information of the target variable to be optimized, and sets the affinity of the process according to the access information of the target variable when receiving an access request from the process for the target variable. The access information includes the information recorded in each bit field of the newly added member of the target variable of the target node number.
[0059] It is understandable that the target variable in the embodiment of the present invention is different from a conventional variable, and the data structure of the target variable includes a new member, and the new member is used to count the access information of the target variable. Specifically, the member can be divided into 4 bit fields, which are respectively recorded as the first bit field, the second bit field, the third bit field and the fourth bit field.
[0060] Among them, the first field is used to record the target node number, which can be the node number of a pre-specified NUMA node, or the node number of the NUMA node to which the target variable belongs, etc., and the embodiment of the present invention does not limit this. As an example, the node number of the NUMA node to which the first process accessing the target variable belongs is used as the target node number, and each process accessing the target variable thereafter is bound to the NUMA node corresponding to the target node number. It should be noted that in the embodiment of the present invention, once the target node number is determined, it will no longer change, so as to ensure that when the target parameter of the target variable accessed by different processes is greater than a preset threshold, all processes accessing the target variable can be affinity-bound to the same determined NUMA node.
[0061] The second bit field is used to record the timestamp of the target process accessing the target variable, wherein the target process is any process accessing the target variable, and the target process is different from the process that accessed the target variable last time. Exemplarily, assuming that the process that accessed the target variable last time is process A, and the process that currently accesses the target variable is process B, since process B is not the same process as process A, it can be determined that process B is the target process in the embodiment of the present invention, and the time when process B accesses the target variable is updated to the second bit field.
[0062] Optionally, the target process also includes the first process to access the target variable. As an example, assuming that the first process to access the target variable is process A, since no other process has accessed the target variable before, process A can be directly determined as the target process.
[0063] The third bit field is used to record the process ID of the target process accessing the target variable. Taking the above example, process B is the target process, and the process ID recorded in the third bit field is recorded as the process ID of process B. It should be noted that the process ID is used to uniquely identify the identity of the process, and illustratively, the process ID can be a process identifier (Process Identifier, PID).
[0064] The fourth bit field is used to record a target parameter, and when the target variable is accessed by the target process, the target parameter is incremented by 1. In other words, the target parameter recorded in the fourth bit field is incremented by 1 as long as the processes accessing the target variable are different in two consecutive accesses.
[0065] Optionally, the length of the member is 64 bits. How many bits each bit field occupies requires some consideration. Looking from the highest to the lowest bit, as an example, the first bit field records a definite node number. Since the total number of nodes is relatively small, it can occupy only 4 bits, so a total of 16 nodes can be recorded. The second bit field records the PID of the process. The PID is generally also small and occupies 8 bits. The third bit field records the timestamp when the target variable is accessed by different target processes and occupies 32 bits. The fourth bit field has 20 bits left for recording the target parameters when the target variable is accessed by different target processes. It should be noted that the records in these bit fields may overflow. For example, the original 64-bit timestamp cannot be put into the 32-bit third bit field, and this requires unified truncation processing, only caring about the lower 32 bits. Of course, the order and the size occupied by these bit fields can be other combinations as long as this combination can achieve the purpose described in the present invention. The length of this member can also be other values, such as 32 bits, 128 bits, and so on. In the embodiments of the present invention, the data recorded in each bit field is relatively simple. In order to avoid occupying more storage space while ensuring that the data in each bit field can be recorded normally, the length of this member is usually set to 64 bits.
[0066] In the embodiments of the present invention, to facilitate obtaining the access information of the target variable, a general statistical information interface can be preset, and the newly added member of the target variable is accessed by calling this statistical information interface. Optionally, when receiving an access request from a process for a target variable, obtaining the access information recorded in the newly added member of the target variable includes: when receiving an access request from a process for a target variable, calling the statistical information interface to obtain the access information recorded in the newly added member of the target variable.
[0067] If the update frequency of the timestamp recorded in the second bit field within the first preset time is greater than the first frequency threshold, and the target parameter recorded in the fourth bit field is greater than the preset parameter threshold, it indicates that the target variable is frequently accessed by multiple different processes. In this case, in the embodiments of the present invention, the processes that concurrently access the target variable are all bound to the NUMA node corresponding to the target node number specified in the access information of the target variable, so that each process that concurrently accesses the target variable is bound to the same NUMA node, converting the concurrent access of the target variable by processes on different NUMA nodes into the concurrent access of the target variable by processes on the same NUMA node, which can effectively reduce the hardware overhead caused by frequent cache synchronization between multiple NUMA nodes and is beneficial to improving the access performance of the processes.
[0068] Binding the process to the NUMA node corresponding to the target node number can be achieved by setting the affinity of the process, so that the process moves on the CPU of the given NUMA node as long as possible without being migrated to other processors.
[0069] It should be noted that, in the embodiment of the present invention, the target variable can be any data that can be accessed in the program, such as user input data, the result of a specific operation, data that needs to be displayed on a form, etc. The target variable represents a section of operable memory. In the embodiment of the present invention, the target variable is a shared variable that can be accessed by different NUMA nodes. The embodiment of the present invention does not specifically limit the data structure type of the target variable. As an example, the target variable can be a lock, a table, an array, a queue, a stack, etc.
[0070] In an optional embodiment of the present invention, the updating of the accessed information recorded in the second bit field, the third bit field, and the fourth bit field according to the process identifier recorded in the third bit field, and the process identifier and access time of the process accessing the target variable in step 102 includes:
[0071] Step S11: if the process identifier currently accessing the target variable is different from the process identifier recorded in the third bit field, determining that the process is the target process;
[0072] Step S12: updating the timestamp recorded in the second bit field according to the access time of the target process accessing the target variable;
[0073] Step S13: updating the process identifier recorded in the third bit field according to the process identifier of the target process;
[0074] Step S14: Add 1 to the target parameter recorded in the fourth bit field.
[0075] In an embodiment of the present invention, an initial value may be set in advance in the second bit field, the third bit field, and the fourth bit field, respectively, and then the initial values of the second bit field, the third bit field, and the fourth bit field may be updated according to the access of each process to the target variable. Specifically, if the first process currently accessing the target variable is different from the second process that last accessed the target variable, the first process is determined to be the target process, and then the timestamp recorded in the second bit field is updated according to the time when the target process accesses the target variable, the process identifier recorded in the third bit field is updated according to the process identifier of the target process, and the target parameter recorded in the fourth bit field is increased by 1. It should be noted that the target process also includes the first process that accesses the target variable.
[0076] As an example, referring to Table 1, it shows the information recorded in each bit field of the newly added member in the target variable when the target variable is accessed by multiple processes within a period of time.
[0077] Table 1
[0078] Access time process First field Second bit field The third field The fourth field 16:31 Process A Target node number 16:31 PID_A 1 16:32 Process B Target node number 16:32 PID_B 2 16:34 Process B Target node number 16:32 PID_B 2 16:35 Process A Target node number 16:35 PID_A 3 16:36 Process C Target node number 16:36 PID_C 4
[0079] As shown in Table 1, the first process to access the target variable is process A, so process A is taken as the target process, the timestamp in the second bit field is updated to the access time of process A, the process ID in the third bit field is updated to the process ID of process A: PID_A, and the target parameter recorded in the fourth bit field is updated to 1.
[0080] Next, process B accesses the target variable. Since process B is not the same process as process A that accessed the target variable last time, process B is taken as the target process and the data recorded in the second bit field, the third bit field, and the fourth bit field are updated.
[0081] In the third access, process B accesses the target variable again, which is the same process as the previous access to the target variable, so no update is performed on the individual bit fields of the members.
[0082] And so on, according to the information of each process accessing the target variable, the records in each bit field of the new member of the target variable are updated.
[0083] It should be noted that the access time of the target variable shown in Table 1 is only an exemplary description. In actual applications, when multiple processes concurrently access the target variable, the access time of each process may be in milliseconds.
[0084] In an optional embodiment of the present invention, after binding the process to the NUMA node corresponding to the target node number, the method further includes: if the timestamp recorded in the second bit field is not updated within a second preset time, releasing the binding relationship between the process and the NUMA node corresponding to the target node number.
[0085] In an embodiment of the present invention, after a process is bound to a NUMA node corresponding to a target node number, if the timestamp recorded in the second bit field is not updated within a second preset time, it means that the target variable is no longer frequently accessed by multiple processes, and the affinity of the process to the NUMA node corresponding to the target node number can be cancelled, that is, the binding relationship between the process and the NUMA node corresponding to the target node number is released, so that other NUMA nodes in the NUMA architecture call the process for calculation. The second preset time can be set according to actual needs.
[0086] In an optional embodiment of the present invention, after binding the process to the NUMA node corresponding to the target node number, the method further includes: if the target parameter is greater than a preset parameter threshold, and the update frequency of the timestamp recorded in the second bit field within a third preset time is greater than a second frequency threshold, then the binding relationship between the process and the NUMA node is kept unchanged.
[0087] In an embodiment of the present invention, the affinity of the process for the NUMA node corresponding to the target node number can also be maintained based on the timestamp recorded in the second bit field. Specifically, if the target parameter recorded in the fourth bit field is greater than the preset threshold, but the update frequency of the timestamp recorded in the second bit field within the third preset time is greater than the second frequency threshold, it means that within the third preset time, the target variable is still frequently accessed by multiple different processes. In this case, the embodiment of the present invention can keep the binding relationship between the process and the NUMA node unchanged to avoid the hardware overhead caused by changing the affinity of the process. Among them, the third preset time can be set according to actual needs.
[0088] In summary, an embodiment of the present invention provides a process access method. When a target variable is accessed concurrently by multiple processes, the method can bind each process that concurrently accesses the target variable to the same NUMA node, and convert the concurrent accesses to the target variable by processes on different NUMA nodes into concurrent accesses to the target variable by processes on the same NUMA node, thereby effectively reducing the hardware overhead caused by frequent cache synchronization between multiple NUMA nodes, and is beneficial to improving the access performance of the process.
[0089] It should be noted that, for the sake of simplicity, the method embodiments are described as a series of action combinations, but those skilled in the art should be aware that the embodiments of the present invention are not limited by the order of the actions described, because according to the embodiments of the present invention, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present invention.
[0090] Device Embodiment
[0091] Reference Figure 2 , shows a structural block diagram of an embodiment of a process access device of the present invention, and the device may specifically include:
[0092] The information acquisition module 201 is used to obtain the access information recorded in the newly added member of the target variable when receiving the access request of the process for the target variable, wherein the data structure of the target variable includes a newly added member, and the newly added member includes 4 bit fields, wherein the first bit field is used to record the target node number, the second bit field is used to record the timestamp of the target process accessing the target variable, the third bit field is used to record the process identifier of the target process accessing the target variable, and the fourth bit field is used to record the target parameter, when the target variable is accessed by the target process, the target parameter is increased by 1; the target process is any process accessing the target variable, and the target process is different from the process that accessed the target variable last time;
[0093] The information updating module 202 is used to update the accessed information recorded in the second bit field, the third bit field and the fourth bit field according to the process identifier recorded in the third bit field, and the process identifier and access time of the process accessing the target variable;
[0094] The process binding module 203 is used to bind the process to the NUMA node corresponding to the target node number when the update frequency of the timestamp recorded in the second bit field within the first preset time is greater than the first frequency threshold and the target parameter recorded in the fourth bit field is greater than the preset parameter threshold, so that the process can access the target variable on the NUMA node.
[0095] Optionally, the information updating module includes:
[0096] a target process determination submodule, configured to determine that the process is a target process if the process identifier of the process currently accessing the target variable is different from the process identifier recorded in the third bit field;
[0097] A second bit field updating submodule, configured to update the timestamp recorded in the second bit field according to the access time of the target process accessing the target variable;
[0098] A third bit field updating submodule, configured to update the process identifier recorded in the third bit field according to the process identifier of the target process;
[0099] The fourth bit field updating submodule is used to add 1 to the target parameter recorded in the fourth bit field.
[0100] Optionally, the target process also includes a first process that accesses the target variable.
[0101] Optionally, the device further comprises:
[0102] A relationship release module is used to release the binding relationship between the process and the NUMA node corresponding to the target node number if the timestamp recorded in the second bit field is not updated within a second preset time.
[0103] Optionally, the device further comprises:
[0104] A relationship maintaining module is used to maintain the binding relationship between the process and the NUMA node unchanged if the target parameter is greater than a preset parameter threshold and the update frequency of the timestamp recorded in the second bit field within a third preset time is greater than a second frequency threshold.
[0105] Optionally, the length of the newly added member is 64 bits.
[0106] Optionally, the information acquisition module includes:
[0107] The information acquisition submodule is used to call the statistical information interface to obtain the access information recorded in the newly added member of the target variable when receiving an access request from the process to the target variable.
[0108] In summary, an embodiment of the present invention provides a process access device, which can obtain the access information of the target variable when receiving an access request for the target variable from the process, and the access information includes the target node number and the target parameter of the target variable accessed by different processes; then, it is determined whether the target parameter is greater than a preset threshold. If the target parameter is greater than the preset target parameter threshold, the process is bound to the NUMA node corresponding to the target node number, so that the process can access the target variable on the NUMA node. The embodiment of the present invention can bind all processes that concurrently access the same target variable to the same determined NUMA node, and convert the concurrent access of the target variable by processes on different NUMA nodes into the concurrent access of the target variable by processes on the same NUMA node, which effectively reduces the hardware overhead caused by frequent cache synchronization between multiple NUMA nodes, and is conducive to improving the access performance of the process.
[0109] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0110] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0111] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0112] An embodiment of the present invention provides an electronic device for process access, the electronic device comprising a memory and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by one or more processors, wherein the one or more programs include instructions for performing the following operations:
[0113] A11. When receiving an access request for a target variable from a process, obtain access information recorded in a newly added member of the target variable, wherein the data structure of the target variable includes a newly added member, and the newly added member includes 4 bit fields, wherein the first bit field is used to record the target node number, the second bit field is used to record the timestamp of the target process accessing the target variable, the third bit field is used to record the process identifier of the target process accessing the target variable, and the fourth bit field is used to record a target parameter, and when the target variable is accessed by the target process, the target parameter is increased by 1; the target process is any process accessing the target variable, and the target process is different from the process that accessed the target variable last time;
[0114] A12. Update the accessed information recorded in the second bit field, the third bit field, and the fourth bit field according to the process ID recorded in the third bit field, and the process ID and access time of the process accessing the target variable;
[0115] A13. When the update frequency of the timestamp recorded in the second bit field within the first preset time is greater than the first frequency threshold, and the target parameter recorded in the fourth bit field is greater than the preset parameter threshold, the process is bound to the NUMA node corresponding to the target node number, so that the process can access the target variable on the NUMA node.
[0116] Optionally, updating the accessed information recorded in the second bit field, the third bit field, and the fourth bit field according to the process identifier recorded in the third bit field, and the process identifier and access time of the process accessing the target variable includes:
[0117] If the process identifier of the process currently accessing the target variable is different from the process identifier recorded in the third bit field, determining that the process is the target process;
[0118] Update the timestamp recorded in the second bit field according to the access time of the target process accessing the target variable;
[0119] Update the process identifier recorded in the third bit field according to the process identifier of the target process;
[0120] The target parameter recorded in the fourth bit field is incremented by 1.
[0121] Optionally, the target process also includes a first process that accesses the target variable.
[0122] Optionally, after binding the process to the NUMA node corresponding to the target node number, the device is further configured to execute, by one or more processors, the one or more programs including instructions for performing the following operations:
[0123] If the timestamp recorded in the second bit field is not updated within a second preset time, the binding relationship between the process and the NUMA node corresponding to the target node number is released.
[0124] Optionally, after binding the process to the NUMA node corresponding to the target node number, the device is further configured to execute, by one or more processors, the one or more programs including instructions for performing the following operations:
[0125] If the target parameter is greater than a preset parameter threshold, and the update frequency of the timestamp recorded in the second bit field within a third preset time is greater than a second frequency threshold, the binding relationship between the process and the NUMA node is kept unchanged.
[0126] Optionally, the length of the newly added member is 64 bits.
[0127] Optionally, when receiving an access request from a process for a target variable, obtaining access information recorded in a newly added member of the target variable includes:
[0128] When an access request for a target variable is received from a process, a statistical information interface is called to obtain access information recorded in a newly added member of the target variable.
[0129] Figure 3 1 is a block diagram of an electronic device 600 for process access according to an exemplary embodiment. For example, the electronic device 600 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.
[0130] Reference Figure 3, the electronic device 600 may include one or more of the following components: a processing component 602 , a memory 604 , a power component 606 , a multimedia component 608 , an audio component 610 , an input / output (I / O) interface 612 , a sensor component 614 , and a communication component 616 .
[0131] The processing component 602 generally controls the overall operation of the electronic device 600, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 602 may include one or more processors 620 to execute instructions to complete all or part of the steps of the above-mentioned method. In addition, the processing component 602 may include one or more modules to facilitate the interaction between the processing component 602 and other components. For example, the processing component 602 may include a multimedia module to facilitate the interaction between the multimedia component 608 and the processing component 602.
[0132] The memory 604 is configured to store various types of data to support operations on the electronic device 600. Examples of such data include instructions for any application or method operating on the electronic device 600, contact data, phone book data, messages, pictures, videos, etc. The memory 604 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.
[0133] The power supply component 606 provides power to the various components of the electronic device 600. The power supply component 606 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the electronic device 600.
[0134] The multimedia component 608 includes a screen that provides an output interface between the electronic device 600 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 608 includes a front camera and / or a rear camera. When the electronic device 600 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and the rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
[0135] The audio component 610 is configured to output and / or input audio signals. For example, the audio component 610 includes a microphone (MIC), and when the electronic device 600 is in an operating mode, such as a call mode, a recording mode, and a voice information processing mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 604 or sent via the communication component 616. In some embodiments, the audio component 610 also includes a speaker for outputting audio signals.
[0136] I / O interface 612 provides an interface between processing component 602 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: a home button, a volume button, a start button, and a lock button.
[0137] The sensor assembly 614 includes one or more sensors for providing various aspects of status assessment for the electronic device 600. For example, the sensor assembly 614 can detect the open / closed state of the electronic device 600, the relative positioning of the components, such as the display and keypad of the device 600, and the sensor assembly 614 can also detect the position change of the electronic device 600 or a component of the electronic device 600, the presence or absence of user contact with the electronic device 600, the orientation or acceleration / deceleration of the electronic device 600, and the temperature change of the electronic device 600. The sensor assembly 814 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor assembly 614 may also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 614 may also include an accelerometer, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
[0138] The communication component 616 is configured to facilitate wired or wireless communication between the electronic device 600 and other devices. The electronic device 600 can access a wireless network based on a communication standard, such as WiFi, 2G or 3G, or a combination thereof. In an exemplary embodiment, the communication component 616 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 616 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency information processing (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.
[0139] In an exemplary embodiment, the electronic device 600 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the above methods.
[0140] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 604 including instructions, and the instructions can be executed by a processor 620 of an electronic device 600 to perform the above method. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
[0141] A non-transitory computer-readable storage medium, when the instructions in the storage medium are executed by a processor of an electronic device (server or terminal), enables the processor to execute Figure 1 The process access method shown.
[0142] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0143] It will be appreciated by those skilled in the art that the embodiments of the present invention may be provided as methods, devices, or computer program products. Therefore, the embodiments of the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the embodiments of the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.
[0144] The embodiments of the present invention are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems), and computer program products according to the embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0145] These computer program instructions may also be stored in a computer readable memory capable of directing a computer or other programmable data processing terminal device to operate in a predictable manner, so that the instructions stored in the computer readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0146] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0147] Although the preferred embodiments of the present invention have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present invention.
[0148] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or terminal device including the elements.
[0149] The process access method, device and electronic device provided by the present invention are introduced in detail above. The principle and implementation mode of the present invention are explained by using specific examples in this article. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the idea of the present invention, there will be changes in the specific implementation mode and application scope. In summary, the content of this specification should not be understood as limiting the present invention.
Claims
1. A process access method, It is characterized in that The method comprises: In the case of receiving an access request for a target variable from a process, obtaining access information recorded in a newly added member of the target variable, wherein the data structure of the target variable includes a newly added member, the newly added member includes 4 bit fields, the first bit field is used to record the target node number, the second bit field is used to record the timestamp of the target process accessing the target variable, the third bit field is used to record the process identifier of the target process accessing the target variable, and the fourth bit field is used to record a target parameter, when the target variable is accessed by the target process, the target parameter is increased by 1; the target process is any process accessing the target variable, and the target process is different from the process that accessed the target variable last time; According to the process identifier recorded in the third bit field, and the process identifier and access time of the process accessing the target variable, updating the accessed information recorded in the second bit field, the third bit field, and the fourth bit field; When the update frequency of the timestamp recorded in the second bit field within the first preset time is greater than the first frequency threshold, and the target parameter recorded in the fourth bit field is greater than the preset parameter threshold, the process is bound to the NUMA node corresponding to the target node number so that the process can access the target variable on the NUMA node.
2. The method according to claim 1, It is characterized in that The updating of the accessed information recorded in the second bit field, the third bit field, and the fourth bit field according to the process identifier recorded in the third bit field, and the process identifier and access time of the process accessing the target variable comprises: If the process identifier of the process currently accessing the target variable is different from the process identifier recorded in the third bit field, determining that the process is the target process; Update the timestamp recorded in the second bit field according to the access time of the target process accessing the target variable; Update the process identifier recorded in the third bit field according to the process identifier of the target process; The target parameter recorded in the fourth bit field is incremented by 1.
3. The method according to claim 1, It is characterized in that The target process also includes a first process that accesses the target variable.
4. The method according to claim 1, It is characterized in that After binding the process to the NUMA node corresponding to the target node number, the method further includes: If the timestamp recorded in the second bit field is not updated within a second preset time, the binding relationship between the process and the NUMA node corresponding to the target node number is released.
5. The method according to claim 1, It is characterized in that After binding the process to the NUMA node corresponding to the target node number, the method further includes: If the target parameter is greater than a preset parameter threshold, and the update frequency of the timestamp recorded in the second bit field within a third preset time is greater than a second frequency threshold, the binding relationship between the process and the NUMA node is kept unchanged.
6. The method according to any one of claims 1 to 5, It is characterized in that The length of the newly added member is 64 bits.
7. The method according to claim 1, It is characterized in that The step of, upon receiving an access request from a process for a target variable, obtaining access information recorded in a newly added member of the target variable, includes: When an access request for a target variable is received from a process, a statistical information interface is called to obtain access information recorded in a newly added member of the target variable.
8. A process access device, It is characterized in that The device comprises: An information acquisition module, configured to, upon receiving an access request from a process for a target variable, acquire access information recorded in a newly added member of the target variable, wherein the data structure of the target variable includes a newly added member, and the newly added member includes four bit fields, wherein the first bit field is used to record a target node number, the second bit field is used to record a timestamp of a target process accessing the target variable, the third bit field is used to record a process identifier of a target process accessing the target variable, and the fourth bit field is used to record a target parameter, and when the target variable is accessed by the target process, the target parameter is incremented by 1; the target process is any process accessing the target variable, and the target process is different from the process that accessed the target variable last time; an information updating module, configured to update the accessed information recorded in the second bit field, the third bit field, and the fourth bit field according to the process identifier recorded in the third bit field, and the process identifier and access time of the process accessing the target variable; A process binding module is used to bind the process to the NUMA node corresponding to the target node number when the update frequency of the timestamp recorded in the second bit field within a first preset time is greater than a first frequency threshold and the target parameter recorded in the fourth bit field is greater than a preset parameter threshold, so that the process can access the target variable on the NUMA node.
9. An electronic device, It is characterized in that The electronic device includes a memory and at least one program, wherein the at least one program is stored in the memory and is configured to execute the process access method according to any one of claims 1 to 7 by at least one processor.
10. A readable storage medium, It is characterized in that When the instructions in the storage medium are executed by a processor of an electronic device, the processor is enabled to execute the process access method as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Data access between computing nodes
WO2017204990A1
Cache management method and device
WO2021143154A1