CN115016944A - Process access method and device and electronic equipment - Google Patents

Process access method and device and electronic equipment Download PDF

Info

Publication number
CN115016944A
CN115016944A CN202210764410.8A CN202210764410A CN115016944A CN 115016944 A CN115016944 A CN 115016944A CN 202210764410 A CN202210764410 A CN 202210764410A CN 115016944 A CN115016944 A CN 115016944A
Authority
CN
China
Prior art keywords
target
bit field
target variable
recorded
accessing
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210764410.8A
Other languages
Chinese (zh)
Inventor
蒲启元
吕建民
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Loongson Technology Corp Ltd
Original Assignee
Loongson Technology Corp Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Loongson Technology Corp Ltd filed Critical Loongson Technology Corp Ltd
Priority to CN202210764410.8A priority Critical patent/CN115016944A/en
Publication of CN115016944A publication Critical patent/CN115016944A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5016Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals the resource being the memory
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The embodiment of the invention provides a process access method, a process access device and electronic equipment, wherein the method comprises the following steps: under the condition that an access request of a process for a target variable is received, acquiring accessed information recorded in a newly added member of the target variable; updating the accessed 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 identifier recorded in the third bit field, and the process identifier and the access time of the process accessing the target variable; when the update frequency of the timestamp recorded in the second bit field in 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, binding the process to a NUMA node corresponding to a target node number, so that the process accesses the target variable on the NUMA node. The embodiment of the invention can reduce the hardware overhead caused by frequently performing cache synchronization among a plurality of NUMA nodes, and is beneficial to improving the access performance of the process.

Description

Process access method and device and electronic equipment
Technical Field
The invention relates to the technical field of computers, in particular to a process access method, a process access device and electronic equipment.
Background
NUMA (Non-uniform memory access) is a computer memory bank design for multiple processors, with memory access time dependent on the location of memory relative to the processor. Under a NUMA architecture, a processor will have memory bound to it (referred to as local memory), which together make up a NUMA node. The processor accesses local memory faster than other memory, i.e., local access is faster than remote access.
Under the NUMA architecture, if a plurality of processes access the same address concurrently, the synchronization between the cache and the memory needs to be performed frequently, which greatly increases the cache consistency overhead.
Disclosure of Invention
The embodiment of the invention provides a process access method, a process access device and electronic equipment, which can solve the problem of high cache consistency overhead caused by concurrent access of a plurality of processes to the same address.
In order to solve the above problem, an embodiment of the present invention discloses a process access method, where the method includes:
under the condition that an access request of a process for a target variable is received, acquiring accessed information recorded in a newly added member of the target variable, wherein a data structure of the target variable comprises the newly added member, the newly added member comprises 4bit fields, a first bit field is used for recording a target node number, a second bit field is used for recording a timestamp of the target process for accessing the target variable, a third bit field is used for recording a process identifier of the target process for accessing the target variable, a fourth bit field is used for recording a target parameter, and when the target variable is accessed by the target process, the target parameter is added by 1; the target process is any process accessing the target variable, and the target process is different from the process accessing the target variable last time;
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 the access time of the process accessing the target variable;
and when the update frequency of the timestamp recorded in the second bit field in 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, binding the process to the NUMA node corresponding to the target node number, so that the process accesses the target variable on the NUMA node.
Optionally, the 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 the access time of the process accessing the target variable includes:
if the process identification of the process currently accessing the target variable is different from the process identification recorded in the third bit field, determining the process as a target process;
updating the timestamp recorded in the second bit field according to the access time of the target process to access the target variable;
updating the process identifier recorded in the third bit field according to the process identifier of the target process;
adding 1 to the target parameter recorded in the fourth field.
Optionally, the target process further includes a first process accessing the target variable.
Optionally, after the process is bound to a NUMA node corresponding to the target node number, the method further includes:
and if the timestamp recorded in the second bit field is not updated within second preset time, removing the binding relationship between the process and the NUMA node corresponding to the target node number.
Optionally, after the process is bound to a NUMA node corresponding to the target node number, the method further includes:
and if the target parameter is greater than a preset parameter threshold value and the update frequency of the timestamp recorded in the second bit field in a third preset time is greater than a second frequency threshold value, keeping the binding relationship between the process and the NUMA node unchanged.
Optionally, the length of the new member is 64 bits.
Optionally, the obtaining, when an access request of a process for a target variable is received, accessed information recorded in a newly added member of the target variable includes:
and under the condition of receiving an access request of a process for a target variable, calling a statistical information interface to acquire accessed information recorded in a newly added member of the target variable.
On the other hand, the embodiment of the invention discloses a process access device, which comprises:
the information acquisition module is used for acquiring accessed information recorded in a newly added member of a target variable under the condition that an access request of a process for the target variable is received, wherein the data structure of the target variable comprises the newly added member which comprises 4bit fields, a first bit field is used for recording a target node number, a second bit field is used for recording a timestamp of the target process for accessing the target variable, a third bit field is used for recording a process identifier of the target process for accessing the target variable, a fourth bit field is used for recording a target parameter, and when the target variable is accessed by the target process, the target parameter is added by 1; the target process is any process for accessing the target variable, and the target process is different from the process for accessing 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 the access time of the process accessing the target variable;
and the process binding module is configured 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 accesses the target variable on the NUMA node.
Optionally, the information updating module includes:
a target process determining submodule, configured to determine that the process is the 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;
the second bit field updating submodule is used for updating the timestamp recorded in the second bit field according to the access time of the target process for accessing the target variable;
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;
and the fourth field updating submodule is used for adding 1 to the target parameter recorded in the fourth field.
Optionally, the target process further includes a first process accessing the target variable.
Optionally, the apparatus further comprises:
and the relation removing module is used for removing the binding relation 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.
Optionally, the apparatus further comprises:
and the relationship maintaining module is configured 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 an update frequency of the timestamp recorded in the second bit field within a third preset time is greater than a second frequency threshold.
Optionally, the length of the new member is 64 bits.
Optionally, the information obtaining module includes:
and the information acquisition submodule is used for calling a statistical information interface to acquire the accessed information recorded in the newly added member of the target variable under the condition of receiving an access request of a process for the target variable.
In still another aspect, an embodiment of the present invention further discloses an electronic device, which includes a memory and one or more programs, where the one or more programs are stored in the memory and configured to be executed by one or more processors to perform the aforementioned process access method.
The embodiment of the invention also discloses a readable storage medium, and when the instructions in the storage medium are executed by a processor of the electronic equipment, the electronic equipment can execute the process access method.
The embodiment of the invention has the following advantages:
the embodiment of the invention provides a process access method, which can acquire accessed information of a target variable under the condition of receiving an access request of a process for the target variable, wherein a data structure of the target variable comprises a newly added member, the newly added member comprises 4bit fields, the first bit field is used for recording a target node number, the second bit field is used for recording a timestamp of the target process for accessing the target variable, the third bit field is used for recording a process identifier of the target process for accessing the target variable, the fourth bit field is used for recording a target parameter, and when the target variable is accessed by the target process, the target parameter is added by 1; the target process is any process accessing the target variable, and the target process is different from the process accessing the target variable last time; then, according to the process identifier recorded in the third bit field, and the process identifier and the 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; and when the update frequency of the timestamp recorded in the second bit field in 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, binding the process to the NUMA node corresponding to the target node number, so that the process accesses the target variable on the NUMA node. According to the embodiment of the invention, when the target variable is concurrently accessed by a plurality of processes, each process concurrently accessing the target variable can be bound to the same NUMA node, and the concurrent access of the processes on different NUMA nodes to the target variable is converted into the concurrent access of the processes on the same NUMA node to the target variable, so that the hardware overhead caused by frequent cache synchronization among a plurality of NUMA nodes is effectively reduced, and the access performance of the processes is favorably improved.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings needed to be used in the description of the embodiments of the present invention will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art that other drawings can be obtained according to these drawings without inventive labor.
FIG. 1 is a flow chart of the steps of one embodiment of a process access method of the present invention;
FIG. 2 is a schematic structural diagram of a NUMA architecture of the present invention;
fig. 3 is a block diagram of an electronic device for process access according to an example of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Method embodiment
Referring to fig. 1, a flowchart illustrating steps of an embodiment of a process access method according to the present invention is shown, where the method specifically includes the following steps:
step 101, acquiring accessed information recorded in a newly added member of a target variable under the condition of receiving an access request of a process for the target variable.
And step 102, updating the accessed 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 identifier recorded in the third bit field, and the process identifier and the access time of the process accessing the target variable.
Step 103, when the update frequency of the timestamp recorded in the second bit field in 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, binding the process to a NUMA node corresponding to a target node number, so that the process accesses the target variable on the NUMA node.
The data structure of the target variable comprises a newly added member, the newly added member comprises 4bit fields, a first bit field is used for recording a target node number, a second bit field is used for recording a time stamp of a target process accessing the target variable, a third bit field is used for recording a process identifier of the target process accessing the target variable, a fourth bit field is used for recording a target parameter, and when the target variable is accessed by the target process, the target parameter is added by 1; the target process is any process accessing the target variable, and the target process is different from the process accessing the target variable last time.
The process access method provided by the embodiment of the invention can bind each process concurrently accessing the target variable to the same NUMA node when a plurality of processes under the NUMA architecture frequently and alternately access the same target variable, thereby avoiding the cache consistency overhead among different nodes and being beneficial to improving the speed of accessing the shared variable by the processes.
It should be noted that, in the NUMA architecture, each CPU core has a memory (referred to as a local memory) bound thereto, and the two cores form a NUMA node. Individual NUMA nodes are connected by a scalable network (I/O bus) so that the CPU can systematically access memory associated with other NUMA nodes.
At least one NUMA node can be included in the NUMA architecture, and each NUMA node can include at least one processor. It should be noted that, in the embodiment of the present invention, the processor may be a logical processor. For example, one Node may correspond to one CPU socket, one physical CPU may be plugged into one CPU socket, one physical CPU may include a plurality of cpucores (computational cores), and one CPUCore may include a plurality of logical CPUs (processors in this case). Of course, this is merely exemplary, and the structure of the NUMA node is not limited thereto in the embodiment of the present invention.
Under the NUMA architecture, it is necessary to ensure read-write consistency of a cache (cache), and particularly, for a single-core system, it is necessary to ensure data consistency between the cache and a memory; for a multi-core system, consistency between the cache and the memory needs to be ensured, and consistency between the caches of the CPUs needs to be ensured. When multiple processes located in different NUMA nodes concurrently access the same shared variable (address), in order to ensure cache consistency, each NUMA node not only needs to frequently synchronize between a local cache and a memory, but also needs to frequently synchronize between each NUMA node, which causes hardware overhead to be too large.
In order to solve the problem, an embodiment of the present invention provides a process access method, where accessed information of a target variable that needs to be optimized is counted, and when an access request of a process for the target variable is received, affinity of the process is set according to the accessed information of the target variable. The accessed information comprises information recorded in each bit field of the new member of the target variable of the target node number.
It is understood that, unlike the conventional variable, the target variable in the embodiment of the present invention includes an additional member in the data structure of the target variable, and the additional member is used for counting accessed information of the target variable. Specifically, the member may be divided into 4bit fields, which are respectively referred to as a first bit field, a second bit field, a third bit field, and a fourth bit field.
The first bit field is used to record a target node number, where the target node number may be a node number of a pre-specified NUMA node, or a node number of a NUMA node to which the target variable belongs, and the like. As an example, the node number of the NUMA node to which the first process accessing the target variable belongs is taken as the target node number, and then each process accessing the target variable 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, the target node number is not changed any more, so as to ensure that all processes accessing the target variable can be affinity-bound to the same determined NUMA node in the case that the target parameter of the target variable accessed by different processes is greater than the preset threshold.
And the second bit field is used for recording a time stamp of 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 accessing the target variable last time. For example, assuming that the process that last accessed the target variable is process a and the process that currently accessed the target variable is process B, since process B and process a are not the same process, it may be determined that process B is the target process in the embodiment of the present invention, and the time for process B to access the target variable is updated to the second bit field.
Optionally, the target process further includes a first process accessing the target variable. As an example, assuming that the first process accessing the target variable is process A, since no other process has accessed the target variable before that, process A can be directly determined to be the target process.
And the third bit field is used for recording the process identification of the target process accessing the target variable. Taking the above example as an example, if the process B is the target process, the process identifier recorded in the third location field is recorded as the process identifier of the process B. It should be noted that the Process Identifier is used to uniquely identify the Process, and may be, for example, a Process Identifier (PID).
And the fourth field is used for recording a target parameter, and when the target variable is accessed by a target process, the target parameter is added by 1. In other words, the target variable recorded in the fourth field is incremented by 1 as long as the process of accessing the target variable is different in two consecutive accesses.
Optionally, the length of the member is 64 bits, and how many bits each bit field occupies needs to be considered, and as an example, from high to low, the first bit field records a certain node number, and as the total number of nodes is relatively small, only 4 bits can be occupied, so that 16 nodes can be recorded in total. The second bit field records the PID of the process, the PID is generally smaller and occupies 8 bits, and the third bit field records the timestamp of the target variable accessed by different target processes and occupies 32 bits. The fourth bit field has 20 bits left for recording the target parameters of the target variable accessed by the 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 third bit field of 32 bits, which requires a uniform truncation process, and only care is taken about the lower 32 bits. Of course, the order of the bit fields and the occupied size can be other combinations as long as the combination can achieve the purpose of the invention. The member length may also be other values, such as 32bit, 128bit, etc. In the embodiment of the present invention, the data recorded in each bit field is relatively simple, and in order to avoid occupying more storage space under the condition of ensuring that the data in each bit field can be recorded normally, the length of the member is usually set to 64 bits.
In the embodiment of the invention, in order to obtain the accessed 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 the statistical information interface. Optionally, the obtaining, when an access request of a process for a target variable is received, accessed information recorded in a newly added member of the target variable includes: and under the condition of receiving an access request of a process for a target variable, calling a statistical information interface to acquire accessed information recorded in a newly added member of the target variable.
If the update frequency of the timestamp recorded in the second bit field in 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 is indicated that the target variable is frequently accessed by a plurality of different processes, in this case, the embodiments of the present invention bind all the processes concurrently accessing the target variable to the NUMA node corresponding to the target node number specified in the accessed information of the target variable, so that each process concurrently accessing the target variable is bound to the same NUMA node, convert the concurrent access of the processes on different NUMA nodes to the target variable into the concurrent access of the processes on the same NUMA node to the target variable, can effectively reduce hardware overhead caused by frequent cache synchronization among a plurality of NUMA nodes, and is favorable for improving the access performance of the processes.
The process is bound to the NUMA node corresponding to the target node number, and the affinity of the process can be set, so that the process can move on the CPU of the given NUMA node for as long as possible without being migrated to other processors.
It should be noted that, in the embodiment of the present invention, the target variable may be any data that can be accessed in the program, such as input data of a user, a result of a specific operation, data that needs to be displayed on a form, and the like. The target variable represents a segment of operable memory, and in an embodiment of the present invention, the target variable is a shared variable that can be accessed by different NUMA nodes. The data structure type of the target variable is not specifically limited in the embodiments of the present invention, and as an example, the target variable may be a lock, a table, an array, a queue, a stack, or the like.
In an optional embodiment of the present invention, the step 102 of 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 the access time of the process accessing the target variable includes:
step S11, if the process identification of the current access target variable is different from the process identification recorded in the third bit field, determining that the process is the target process;
step S12, the timestamp recorded in the second bit field is updated according to the access time of the target process to access the target variable;
step S13, updating the process identifier recorded in the third bit field according to the process identifier of the target process;
and step S14, adding 1 to the target parameter recorded in the fourth field.
In the embodiment of the present invention, an initial value may be set in the second bit field, the third bit field, and the fourth bit field in advance, 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 condition of each process to the target variable. Specifically, if a first process currently accessing the target variable is different from a second process accessing the target variable last time, the first process is determined to be the target process, 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 1 is added to the target parameter recorded in the fourth bit field. It should be noted that the target process further includes a first process accessing the target variable.
As an example, referring to table 1, information recorded in each bit field of a newly added member in a target variable when the target variable is accessed by a plurality of processes over a period of time is shown.
TABLE 1
Time of access Process and system for managing a process First bit field Second bit field Third bit field The fourth field
16:31 Process A Destination node number 16:31 PID_A 1
16:32 ProcessB Destination node number 16:32 PID_B 2
16:34 Process B Destination node number 16:32 PID_B 2
16:35 Process A Destination node number 16:35 PID_A 3
16:36 Process C Destination node number 16:36 PID_C 4
As shown in table 1, the first process accessing the target variable is process a, so that process a is taken as the target process, the timestamp in the second bit field is updated to the access time of process a, and the process identifier in the third bit field is updated to the process identifier of process a: PID _ a, and updates the target parameter recorded in the fourth field to 1.
And then, accessing the target variable by the process B, taking the process B as the target process and updating the data recorded in the second bit field, the third bit field and the fourth bit field because the process B is not the same process as the process A which accessed the target variable last time.
In the 3 rd access, process B accesses the target variable again, the same as the last access to the target variable, and therefore does not update each of the member's bitfields.
And so on, updating the records in each bit field of the new member of the target variable according to the information of each process accessing the target variable.
It should be noted that the access time of the target variable shown in table 1 is only an exemplary illustration, and in practical applications, when multiple processes access the target variable concurrently, the access time of each process may be in milliseconds.
In an optional embodiment of the present invention, after the process is bound to the NUMA node corresponding to the target node number, the method further includes: and if the timestamp recorded in the second bit field is not updated within second preset time, removing the binding relationship between the process and the NUMA node corresponding to the target node number.
In the embodiment of the present invention, after the process is bound to the NUMA node corresponding to the target node number, if the timestamp recorded in the second bit field is not updated within the second preset time, it is indicated that the target variable is no longer frequently accessed by the multiple processes, and the affinity of the process for the NUMA node corresponding to the target node number may be cancelled, that is, the binding relationship between the process and the NUMA node corresponding to the target node number is cancelled, so that other NUMA nodes in the NUMA architecture call the process for calculation. The second preset time can be set according to actual requirements.
In an optional embodiment of the present invention, after the process is bound to a NUMA node corresponding to the target node number, the method further includes: and if the target parameter is greater than a preset parameter threshold value and the update frequency of the timestamp recorded in the second bit field in a third preset time is greater than a second frequency threshold value, keeping the binding relationship between the process and the NUMA node unchanged.
In this embodiment of the present invention, the affinity of the process for the NUMA node corresponding to the target node number may 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, which indicates that the target variable is still frequently accessed by a plurality of different processes within the third preset time, in this case, the embodiment of the present invention may keep the binding relationship between the processes and the NUMA node unchanged, so as to avoid hardware overhead caused by changing process affinity. The third preset time can be set according to actual requirements.
To sum up, the embodiment of the present invention provides a process access method, which can bind processes concurrently accessing a target variable to a same NUMA node when the target variable is concurrently accessed by multiple processes, and convert concurrent accesses of processes on different NUMA nodes to the target variable into concurrent accesses of processes on the same NUMA node to the target variable, thereby effectively reducing hardware overhead caused by frequent cache synchronization among multiple NUMA nodes, and facilitating improvement of access performance of the processes.
It should be noted that for simplicity of description, the method embodiments are shown as a series of combinations of acts, but those skilled in the art will recognize that the embodiments are not limited by the order of acts, as some steps may occur in other orders or concurrently in accordance with the embodiments. Further, those skilled in the art will appreciate that the embodiments described in the specification are presently preferred and that no particular act is required to implement the invention.
Device embodiment
Referring to fig. 2, a block diagram of a process access apparatus according to an embodiment of the present invention is shown, where the apparatus may specifically include:
an information obtaining module 201, configured to obtain, when an access request of a process for a target variable is received, accessed information recorded in a newly added member of the target variable, where a data structure of the target variable includes one newly added member, and the newly added member includes 4bit fields, a first bit field is used to record a target node number, a second bit field is used to record a timestamp that the target process accesses the target variable, a third bit field is used to record a process identifier of the target process that accesses the target variable, and a 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 accessing the target variable last time;
an information updating module 202, 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 the access time of the process accessing the target variable;
a process binding module 203, configured to bind the process to a NUMA node corresponding to the target node number when an update frequency of the timestamp recorded in the second bit field within a first preset time is greater than a first frequency threshold and a target parameter recorded in the fourth bit field is greater than a preset parameter threshold, so that the process accesses the target variable on the NUMA node.
Optionally, the information updating module includes:
a target process determining submodule, configured to determine that the process is the 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;
the second bit field updating submodule is used for updating the timestamp recorded in the second bit field according to the access time of the target process for accessing the target variable;
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;
and the fourth field updating submodule is used for adding 1 to the target parameter recorded in the fourth field.
Optionally, the target process further includes a first process accessing the target variable.
Optionally, the apparatus further comprises:
and the relation removing module is used for removing the binding relation 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.
Optionally, the apparatus further comprises:
and the relationship maintaining module is configured 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 an update frequency of the timestamp recorded in the second bit field within a third preset time is greater than a second frequency threshold.
Optionally, the length of the new member is 64 bits.
Optionally, the information obtaining module includes:
and the information acquisition submodule is used for calling a statistical information interface to acquire the accessed information recorded in the newly added member of the target variable under the condition of receiving an access request of a process for the target variable.
To sum up, an embodiment of the present invention provides a process access apparatus, where the apparatus is capable of acquiring accessed information of a target variable when receiving an access request of a process for the target variable, where the accessed information includes a target node number and a target parameter of the target variable accessed by different processes; and then, judging whether the target parameter is larger than a preset threshold value. And if the target parameter is greater than a preset target parameter threshold value, binding the process to a NUMA node corresponding to the target node number, so that the process accesses the target variable on the NUMA node. The embodiment of the invention can bind all processes concurrently accessing the same target variable to the same determined NUMA node, and convert the concurrent access of the processes on different NUMA nodes to the target variable into the concurrent access of the processes on the same NUMA node to the target variable, thereby effectively reducing the hardware overhead caused by frequent cache synchronization among a plurality of NUMA nodes and being beneficial to improving the access performance of the processes.
For the device embodiment, since it is basically similar to the method embodiment, the description is simple, and for the relevant points, refer to the partial description of the method embodiment.
The embodiments in the present specification are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other.
With regard to the apparatus in the above-described embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.
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 configured to be executed by one or more processors, the one or more programs including instructions for:
a11, under the condition that an access request of a process for a target variable is received, acquiring accessed information recorded in a newly added member of the target variable, wherein a data structure of the target variable comprises the newly added member, the newly added member comprises 4bit fields, a first bit field is used for recording a target node number, a second bit field is used for recording a timestamp of the target process for accessing the target variable, a third bit field is used for recording a process identifier of the target process for accessing the target variable, a fourth bit field is used for recording a target parameter, and when the target variable is accessed by the target process, the target parameter is added by 1; the target process is any process accessing the target variable, and the target process is different from the process accessing the target variable last time;
a12, updating the accessed information recorded in the second bit field, the third bit field and the fourth bit field according to the process identification recorded in the third bit field and the process identification and the access time of the process accessing the target variable;
a13, when the update frequency of the timestamp recorded in the second bit field in 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, binding the process to a NUMA node corresponding to the target node number, so that the process accesses the target variable on the NUMA node.
Optionally, the 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 the access time of the process accessing the target variable includes:
if the process identification of the process currently accessing the target variable is different from the process identification recorded in the third bit field, determining the process as a target process;
updating the timestamp recorded in the second bit field according to the access time of the target process to access the target variable;
updating the process identifier recorded in the third bit field according to the process identifier of the target process;
adding 1 to the target parameter recorded in the fourth field.
Optionally, the target process further includes a first process accessing the target variable.
Optionally, after binding the process to the NUMA node corresponding to the target node number, the apparatus is further configured to execute, by the one or more processors, the one or more programs including instructions for:
and if the timestamp recorded in the second bit field is not updated within second preset time, removing the binding relationship between the process and the NUMA node corresponding to the target node number.
Optionally, after binding the process to the NUMA node corresponding to the target node number, the apparatus is further configured to execute, by the one or more processors, the one or more programs including instructions for:
and if the target parameter is greater than a preset parameter threshold value and the update frequency of the timestamp recorded in the second bit field in a third preset time is greater than a second frequency threshold value, keeping the binding relationship between the process and the NUMA node unchanged.
Optionally, the length of the new member is 64 bits.
Optionally, the obtaining, when an access request of a process for a target variable is received, accessed information recorded in a newly added member of the target variable includes:
and under the condition of receiving an access request of a process for a target variable, calling a statistical information interface to acquire accessed information recorded in a newly added member of the target variable.
FIG. 3 is a block diagram illustrating an architecture of an electronic device 600 for process access in accordance with 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, an exercise device, a personal digital assistant, and the like.
Referring to fig. 3, electronic device 600 may include one or more of the following components: processing component 602, memory 604, power component 606, multimedia component 608, audio component 610, input/output (I/O) interface 612, sensor component 614, and communication component 616.
The processing component 602 generally controls overall operation of the electronic device 600, such as operations associated with display, telephone calls, data communications, camera operations, and recording operations. The processing elements 602 may include one or more processors 620 to execute instructions to perform all or a portion of the steps of the methods described above. Further, the processing component 602 can include one or more modules that facilitate interaction between the processing component 602 and other components. For example, the processing component 602 can include a multimedia module to facilitate interaction between the multimedia component 608 and the processing component 602.
The memory 604 is configured to store various types of data to support operations at the electronic device 600. Examples of such data include instructions for any application or method operating on the electronic device 600, contact data, phonebook data, messages, pictures, videos, and so forth. The memory 604 may be implemented by any type or combination of volatile or non-volatile memory devices 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 or optical disks.
Power supply component 606 provides power to the various components of electronic device 600. The power components 606 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the electronic device 600.
The multimedia component 608 includes a screen that provides an output interface between the electronic device 600 and a 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 an input signal from a 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 boundary of a 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 facing camera and/or a rear facing camera. The front camera and/or the rear camera may receive external multimedia data when the electronic device 600 is in an operation mode, such as a photographing mode or a video mode. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
The audio component 610 is configured to output and/or input audio signals. For example, the audio component 610 includes a Microphone (MIC) configured to receive external audio signals when the electronic device 600 is in an operational mode, such as a call mode, a recording mode, and a voice information processing mode. The received audio signal may further be stored in the memory 604 or transmitted via the communication component 616. In some embodiments, audio component 610 further includes a speaker for outputting audio signals.
The I/O interface 612 provides an interface between the processing component 602 and peripheral interface modules, which may be 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.
The sensor component 614 includes one or more sensors for providing status assessment of various aspects of the electronic device 600. For example, the sensor component 614 may detect an open/closed state of the electronic device 600, the relative positioning of components, such as a display and keypad of the apparatus 600, the sensor component 614 may also detect a change in position 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, orientation or acceleration/deceleration of the electronic device 600, and a change in temperature of the electronic device 600. Sensor assembly 814 may include a proximity sensor configured to detect the presence of a nearby object without any physical contact. The sensor assembly 614 may also include a light 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 acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
The communication component 616 is configured to facilitate communications between the electronic device 600 and other devices in a wired or wireless manner. The electronic device 600 may 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 broadcast signals or broadcast related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 616 further includes a Near Field Communication (NFC) module to facilitate short-range communications. For example, the NFC module may 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.
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, micro-controllers, microprocessors or other electronic components for performing the above-described methods.
In an exemplary embodiment, a non-transitory computer readable storage medium comprising instructions, such as the memory 604 comprising instructions, executable by the processor 620 of the electronic device 600 to perform the above-described method is also provided. For example, the non-transitory computer readable storage medium may be a ROM, a Random Access Memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, and the like.
A non-transitory computer-readable storage medium in which instructions, when executed by a processor of an electronic device (server or terminal), enable the processor to perform the process access method shown in fig. 1.
The embodiments in the present specification are all described in a progressive manner, and each embodiment focuses on differences from other embodiments, and portions that are the same and similar between the embodiments may be referred to each other.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, apparatus, or computer program product. Accordingly, embodiments of the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, embodiments of the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and so forth) having computer-usable program code embodied therein.
Embodiments of the present invention are described with reference to flowchart illustrations and/or block diagrams of methods, terminal devices (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing terminal to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing terminal to function in a predictive manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing terminal to cause a series of operational steps to be performed on the computer or other programmable terminal to produce a computer implemented process such that the instructions which execute on the computer or other programmable terminal provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While preferred embodiments of the present invention have been described, additional variations and modifications of these embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. Therefore, it is intended that the appended claims be interpreted as including the preferred embodiment and all changes and modifications that fall within the true scope of the embodiments of the present invention.
Finally, it should also be noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "include", "including" or any other variations 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 inherent to such process, method, article, or terminal device. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or terminal that comprises the element.
The above detailed description is given to a process access method, a process access device, and an electronic device provided by the present invention, and specific examples are applied herein to explain the principles and embodiments of the present invention, and the descriptions of the above embodiments are only used to help understand the method and the core idea of the present invention; meanwhile, for a person skilled in the art, according to the idea of the present invention, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present invention.

Claims (10)

1. A method for process access, the method comprising:
under the condition that an access request of a process for a target variable is received, acquiring accessed information recorded in a newly added member of the target variable, wherein a data structure of the target variable comprises the newly added member, the newly added member comprises 4bit fields, a first bit field is used for recording a target node number, a second bit field is used for recording a timestamp of the target process for accessing the target variable, a third bit field is used for recording a process identifier of the target process for accessing the target variable, a fourth bit field is used for recording a target parameter, and when the target variable is accessed by the target process, the target parameter is added by 1; the target process is any process accessing the target variable, and the target process is different from the process accessing the target variable last time;
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 the access time of the process accessing the target variable;
and when the update frequency of the timestamp recorded in the second bit field in 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, binding the process to the NUMA node corresponding to the target node number, so that the process accesses the target variable on the NUMA node.
2. The method according to claim 1, wherein the 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 the access time of the process accessing the target variable comprises:
if the process identification of the process currently accessing the target variable is different from the process identification recorded in the third bit field, determining the process as a target process;
updating the timestamp recorded in the second bit field according to the access time of the target process to access the target variable;
updating the process identifier recorded in the third bit field according to the process identifier of the target process;
adding 1 to the target parameter recorded in the fourth field.
3. The method of claim 1, wherein the target process further comprises a first process accessing the target variable.
4. The method in accordance with claim 1, after binding the process to a NUMA node corresponding to the target node number, the method further comprising:
and if the timestamp recorded in the second bit field is not updated within second preset time, removing the binding relationship between the process and the NUMA node corresponding to the target node number.
5. The method in accordance with claim 1, after binding the process to a NUMA node corresponding to the target node number, the method further comprising:
and if the target parameter is greater than a preset parameter threshold value and the update frequency of the timestamp recorded in the second bit field in third preset time is greater than a second frequency threshold value, keeping the binding relationship between the process and the NUMA node unchanged.
6. The method of any one of claims 1 to 5, wherein the newly added member is 64 bits long.
7. The method according to claim 1, wherein the obtaining of the accessed information recorded in the newly added member of the target variable in the case of receiving an access request of a process for the target variable comprises:
and under the condition of receiving an access request of a process for a target variable, calling a statistical information interface to acquire accessed information recorded in a newly added member of the target variable.
8. A process access apparatus, the apparatus comprising:
the information acquisition module is used for acquiring accessed information recorded in a newly added member of a target variable under the condition that an access request of a process for the target variable is received, wherein the data structure of the target variable comprises the newly added member which comprises 4bit fields, a first bit field is used for recording a target node number, a second bit field is used for recording a timestamp of the target process for accessing the target variable, a third bit field is used for recording a process identifier of the target process for accessing the target variable, a fourth bit field is used for recording a target parameter, and when the target variable is accessed by the target process, the target parameter is added by 1; the target process is any process accessing the target variable, and the target process is different from the process accessing 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 the access time of the process accessing the target variable;
and the process binding module is configured 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 accesses the target variable on the NUMA node.
9. An electronic device comprising a memory, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by one or more processors to perform the process access method of any one of claims 1-7.
10. A readable storage medium, wherein instructions in the storage medium, when executed by a processor of an electronic device, enable the processor to perform the process access method of any of claims 1-7.
CN202210764410.8A 2022-06-30 2022-06-30 Process access method and device and electronic equipment Pending CN115016944A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210764410.8A CN115016944A (en) 2022-06-30 2022-06-30 Process access method and device and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210764410.8A CN115016944A (en) 2022-06-30 2022-06-30 Process access method and device and electronic equipment

Publications (1)

Publication Number Publication Date
CN115016944A true CN115016944A (en) 2022-09-06

Family

ID=83079277

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210764410.8A Pending CN115016944A (en) 2022-06-30 2022-06-30 Process access method and device and electronic equipment

Country Status (1)

Country Link
CN (1) CN115016944A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116910744A (en) * 2023-07-25 2023-10-20 上海合芯数字科技有限公司 Variable access management method, device, computer equipment and storage medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116910744A (en) * 2023-07-25 2023-10-20 上海合芯数字科技有限公司 Variable access management method, device, computer equipment and storage medium
CN116910744B (en) * 2023-07-25 2024-04-12 上海合芯数字科技有限公司 Variable access management method, device, computer equipment and storage medium

Similar Documents

Publication Publication Date Title
CN110751275B (en) Graph training system, data access method and device, electronic device and storage medium
CN104615546A (en) File data management method and device
CN111258952B (en) Data storage control method, device and storage medium
US11494117B2 (en) Method and system for data processing
CN107608714B (en) Byte alignment method, device and computer readable storage medium
CN111937468A (en) Resource indication method and device, and resource determination method and device
CN114428589A (en) Data processing method and device, electronic equipment and storage medium
CN111638938A (en) Virtual machine migration method and device, electronic equipment and storage medium
CN109634762B (en) Data recovery method and device, electronic equipment and storage medium
CN115016944A (en) Process access method and device and electronic equipment
JP2024521963A (en) Data access method, device and non-transitory computer-readable storage medium
CN110968523A (en) Memory defragmentation method and device
CN111695064B (en) Buried point loading method and device
CN106528247B (en) Data refreshing method and device
CN112948440A (en) Page data processing method and device, terminal and storage medium
CN106354657B (en) Register access method, device and system
CN114610324A (en) Binary translation method, processor and electronic equipment
CN111984423B (en) Method, device and medium for running deep learning model
CN114610656A (en) Data replacement method and device, electronic equipment and storage medium
CN110008135B (en) Information processing method and device and electronic equipment
CN114077461A (en) Application program running method, device, equipment and storage medium
CN112131104A (en) Test data distribution method and device, electronic equipment and storage medium
CN111625536B (en) Data access method and device
CN110716985B (en) Node information processing method, device and medium
CN111241097B (en) Method for processing object, device for processing object and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination