Database instruction execution method and device, electronic equipment and storage medium

By using the atomic operation instructions, pre-read instructions and memory model adjustment strategies of the ARM architecture in the database, the problem of performance degradation of X86 architecture database under the ARM architecture is solved, and the database operation performance and efficiency are improved.

CN118939323APending Publication Date: 2024-11-12BEIJING CHINA POWER INFORMATION TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410920284.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-10
Publication Date
2024-11-12

AI Technical Summary

Technical Problem

Current databases based on X86 architectures lead to problems such as performance degradation, efficiency reduction and processing errors when adapting to ARM architecture.

Method used

The atomic operation instructions, pre-read instructions and preset memory models of the ARM architecture are used to adjust the concurrency control strategy, and the corresponding instructions are directly set in the database to achieve the adaptation between the database and the ARM architecture, and optimize locking operations, memory access and concurrency control.

Benefits of technology

It improves the operating performance and efficiency of databases under the ARM architecture, solves the performance problems when databases are adapted to ARM architecture, and realizes the optimized adaptation of databases and mainstream ARM processors.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118939323A_ABST
    Figure CN118939323A_ABST
Patent Text Reader

Abstract

The invention provides a database instruction execution method and device, electronic equipment and a storage medium, and the method comprises the steps: responding to an obtained locking instruction, and carrying out a locking operation through employing an atomic operation instruction of an ARM architecture; in response to the obtained memory access instruction, performing pre-reading by using a pre-reading instruction of the ARM architecture, and accessing pre-read data by using a loading and storage instruction of the ARM architecture; in response to the obtained memory barrier instruction, adjusting a concurrency control strategy by using a preset memory model of the ARM architecture, so as to execute read and / or write operation according to a sequence determined by a preset rule; and in response to the obtained access instruction, determining a target of the access instruction, determining a target field corresponding to the target, and setting locking protection for the target field, so that when any target field of the target is accessed, only any target field is locked through the locking protection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing technology, and in particular to a database instruction execution method, device, electronic device and storage medium. Background Art

[0002] The current mainstream database structure is generally the X86 architecture database structure. However, with the development of technology, more and more processors are beginning to adapt to the ARM architecture (Advanced RISC Machine). This causes the current database based on the X86 architecture to have problems such as performance degradation, reduced efficiency and even processing errors when applied due to framework mismatch. Summary of the invention

[0003] In view of this, the present application proposes a database instruction execution method, device, electronic device and storage medium to solve or partially solve the above-mentioned problems.

[0004] Based on the above purpose, the present application provides a database instruction execution method, which is applied to a database of ARM architecture, including:

[0005] In response to acquiring a lock instruction, determining a first target of the lock instruction, and performing a lock operation on the first target using an atomic operation instruction of the ARM architecture;

[0006] In response to obtaining a memory access instruction, determining a second target of the memory access instruction, using a pre-read instruction of the ARM architecture to pre-read the second target, and then using load and store instructions of the ARM architecture to access the pre-read data;

[0007] In response to obtaining a memory barrier instruction, determining a third target of the memory barrier instruction, and adjusting a concurrency control strategy using a preset memory model of the ARM architecture to perform a read and / or write operation on the third target in an order determined by a preset rule;

[0008] In response to obtaining an access instruction, a fourth target of the access instruction is determined, at least one target field corresponding to the fourth target is determined, and lock protection is set for each of the at least one target fields, so that when any target field of the fourth target is accessed, only the any one target field is locked through the lock protection.

[0009] In some exemplary embodiments, the using the atomic operation instruction of the ARM architecture to perform a locking operation on the first target includes:

[0010] Using the LDREX instruction of the ARM architecture to read the first target, and set a lock mark;

[0011] Using the STREX instruction of the ARM architecture to modify the first target with the lock mark set, and determine whether the value of the first target changes;

[0012] If there is no change, the locking operation on the first target is completed.

[0013] In some exemplary embodiments, after determining whether the value of the first target has changed, the method further includes:

[0014] If there is a change, the first target is re-read using the LDREX instruction, and the STREX instruction is re-used to modify it, and the judgment is re-performed on whether the value of the first target has changed, and this cycle is repeated until the value of the first target has not changed.

[0015] In some exemplary embodiments, the pre-reading of the second target using the pre-reading instruction of the ARM architecture includes:

[0016] The second target is pre-read using the PLD instruction of the ARM architecture.

[0017] In some exemplary embodiments, the accessing of the pre-read data using the load and store instructions of the ARM architecture includes:

[0018] The pre-read data is loaded using the LDR instruction of the ARM architecture, and the pre-read data is stored using the STR instruction of the ARM architecture.

[0019] In some exemplary embodiments, the adjusting the concurrency control strategy using the preset memory model of the ARM architecture includes:

[0020] Determine a time node for reading the third target, and insert a memory barrier field of the ARM architecture after reading according to the preset memory model, so as to adjust the concurrency control strategy;

[0021] Determine a time node for writing the third target, and insert a memory barrier field of the ARM architecture after writing according to the preset memory model, so as to adjust the concurrency control strategy.

[0022] In some exemplary embodiments, the target field is specifically a field requiring concurrent access control.

[0023] Based on the same concept, the present application also provides a database instruction execution device, which is applied to a database of ARM architecture, including:

[0024] A first response module, configured to determine a first target of the lock instruction in response to obtaining the lock instruction, and perform a lock operation on the first target using an atomic operation instruction of the ARM architecture;

[0025] A second response module is used to determine a second target of the memory access instruction in response to obtaining the memory access instruction, use the pre-read instruction of the ARM architecture to pre-read the second target, and then use the load and store instructions of the ARM architecture to access the pre-read data;

[0026] a third response module, configured to, in response to obtaining a memory barrier instruction, determine a third target of the memory barrier instruction, and adjust a concurrency control strategy using a preset memory model of the ARM architecture to perform a read and / or write operation on the third target in an order determined by a preset rule;

[0027] The fourth response module is used to determine the fourth target of the access instruction in response to obtaining the access instruction, determine at least one target field corresponding to the fourth target, and set lock protection for the at least one target field respectively, so that when accessing any target field of the fourth target, only the any one target field is locked through the lock protection.

[0028] Based on the same concept, the present application also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements any of the methods described above when executing the program.

[0029] Based on the same concept, the present application also provides a non-transitory computer-readable storage medium, which stores computer instructions, and the computer instructions are used to enable a computer to implement any of the methods described above.

[0030] As can be seen from the above, the present application provides a database instruction execution method, device, electronic device and storage medium, including: in response to obtaining a lock instruction, determining a first target of the lock instruction, using an atomic operation instruction of the ARM architecture to lock the first target; in response to obtaining a memory access instruction, determining a second target of the memory access instruction, using a pre-read instruction of the ARM architecture to pre-read the second target, and then using the load and store instructions of the ARM architecture to access the pre-read data; in response to obtaining a memory barrier instruction, determining a third target of the memory barrier instruction, using a preset memory model of the ARM architecture to adjust the concurrency control strategy to perform read and / or write operations on the third target in an order determined by a preset rule; in response to obtaining an access instruction, determining a fourth target of the access instruction, determining at least one target field corresponding to the fourth target, and setting lock protection for at least one target field respectively, so that when any target field of the fourth target is accessed, only any one target field is locked through lock protection. This application directly uses the corresponding instruction format of the ARM architecture to perform data operations when the database receives the corresponding instructions. That is, the corresponding instructions are set based on the ARM framework when setting the database, so as to achieve database and mainstream ARM architecture processor adaptation optimization, solve the performance problems caused by the adaptation of database products to the ARM architecture, and improve the database operation performance and efficiency under the ARM architecture. BRIEF DESCRIPTION OF THE DRAWINGS

[0031] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related technologies, the drawings required for use in the embodiments or the related technical descriptions are briefly introduced below. Obviously, the drawings described below are only embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0032] Figure 1 A flowchart of an exemplary method provided in an embodiment of the present application.

[0033] Figure 2 A schematic diagram of executing a memory access instruction according to an exemplary method provided in an embodiment of the present application.

[0034] Figure 3 A schematic diagram of locking processing when executing an access instruction in an exemplary method provided in an embodiment of the present application.

[0035] Figure 4 A schematic diagram of the structure of an exemplary device provided in an embodiment of the present application.

[0036] Figure 5 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0037] In order to make the purpose, technical solutions and advantages of this specification more clear, this specification is further described in detail below in combination with specific embodiments and with reference to the accompanying drawings.

[0038] It should be noted that, unless otherwise defined, the technical terms or scientific terms used in the embodiments of the present application should be understood by people with ordinary skills in the field to which the present application belongs. The "first", "second" and similar words used in the embodiments of the present application do not represent any order, quantity or importance, but are only used to distinguish different components. "Including" or "comprising" and similar words mean that the elements, objects or method steps appearing before the word cover the elements, objects or method steps listed after the word and their equivalents, without excluding other elements, objects or method steps. "Connect" or "connected" and similar words are not limited to physical or mechanical connections, but can include electrical connections, whether direct or indirect. "Up", "down", "left", "right" and the like are only used to indicate relative positional relationships. When the absolute position of the described object changes, the relative positional relationship may also change accordingly.

[0039] As mentioned in the background technology section, the significant differences between the ARM architecture and the X86 architecture in memory management, I / O design, and parallel processing mechanisms have a profound impact on the performance of database software. (1) ARM memory management. The ARM architecture uses a segmented memory management mechanism that controls access to memory segments through segment descriptors. Each process has its own 32 independent segments, and each segment has corresponding attributes such as segment base address and segment boundary. This memory management mechanism provides better memory protection and address translation mechanism. ARM also supports cache and write buffer to improve memory access speed. The cache is divided into data cache, instruction cache, and TLB (Translation Lookaside Buffer) to accelerate the conversion of virtual addresses to physical addresses. (2) ARM I / O design. The I / O design of the ARM architecture is relatively simple, and is mainly connected through the AMBA (Advanced Microcontroller Bus Architecture) bus. This bus architecture defines a series of protocols and standards that allow different components (such as CPU, memory, peripherals, etc.) to communicate easily. In order to improve I / O performance, ARM processors usually integrate a variety of high-speed interfaces, such as USB, Ethernet, SATA, etc. These interfaces can communicate directly with external devices, reducing communication delays through the bus. (3) ARM's parallel processing mechanism. The ARM architecture supports multi-core processors, which allow multiple cores to execute instructions simultaneously, thereby improving the overall performance of the processor. The ARM architecture uses NEON technology to implement SIMD functions. NEON technology provides support for 128-bit SIMD registers, which can process multiple data in parallel in a single instruction.

[0040] As can be seen from the above, due to the advantages of the ARM architecture, more and more processors are beginning to adapt to the ARM architecture. However, since the database is generally originally an X86 architecture, if it is directly applied without corresponding adaptation, it will lead to performance degradation, efficiency reduction, and even processing errors. If the data is converted after output, or other control units are added to the original database to adapt to the ARM architecture, this is itself adding additional module accessories to the original database, which will inevitably have a certain impact on performance and efficiency, that is, it will also lead to certain performance degradation and efficiency reduction problems.

[0041] In view of the above actual situation, the embodiment of the present application provides a database instruction execution scheme. When the database receives the corresponding instruction, the present application directly uses the corresponding instruction format of the ARM architecture to perform data operations, that is, when setting the database, the corresponding instructions are set based on the ARM framework, so as to achieve database and mainstream ARM architecture processor adaptation optimization, solve the performance problems generated when the database product is adapted to the ARM architecture, and improve the database operation performance and operation efficiency under the ARM architecture.

[0042] Figure 1 The flowchart of the exemplary method provided in the embodiment of the present application is shown. The exemplary method can be applied to a database of ARM architecture.

[0043] like Figure 1 As shown, the database instruction execution method exemplarily proposed in the embodiment of the present application specifically includes the following steps.

[0044] Step 102: In response to obtaining a lock instruction, determine a first target of the lock instruction, and use an atomic operation instruction of the ARM architecture to perform a lock operation on the first target.

[0045] Before explaining this step, it should be noted that this embodiment is applied to the database of ARM architecture, that is, it is a database that is modified and adjusted directly according to the coding rules of ARM architecture based on the current X86 architecture database, and the execution code of the corresponding instructions is directly optimized for the purpose of adapting to the ARM architecture when the database is designed, so that the corresponding instructions or codes can be directly used when applying this embodiment. In other words, in the process of forming the database, the modification and addition of the corresponding code are first completed, so that the database can adapt to the ARM architecture and can quickly respond to the response instructions under the ARM architecture.

[0046] At the same time, it should be emphasized that the lock instruction, memory access instruction, memory barrier instruction and access instruction appearing in this embodiment are not necessarily independent instructions, and may also be part of a command in a certain operation. For example, an operation may require the execution of multiple instructions, and these instructions may be sequential or parallel.

[0047] In addition, in specific scenarios, when migrating from the X86 architecture to the ARM architecture, considering the differences in instruction sets, memory access modes, and concurrency control characteristics between the two, it is particularly important to optimize the locking mechanism. The optimization of the locking mechanism involves a lot of content, mainly focusing on the optimization of the locking mechanism related to the differences in the instruction sets of the X86 and ARM architectures. Relevant technologies include adjusting locking instructions, optimizing memory access instructions, using memory barrier instructions, and reducing lock contention. Therefore, for the above four aspects, the corresponding code is adjusted or added respectively, so that the database can be executed in the form of the ARM architecture when executing the corresponding instructions.

[0048] In this step, the locking instruction is to lock a certain data, field, or code in the database, which may be a corresponding instruction generated when the user performs a read operation, an edit operation, and the like. Therefore, the first target here is a certain data target to be locked in the database. Afterwards, the so-called atomic operation refers to an operation that will not be interrupted by the thread scheduling mechanism; once this operation starts, it will run until it ends, and there will not be any context switch (switching to another thread) in the middle. There are multiple atomic operation instructions in the ARM architecture, such as: create, read, write, delete, clone, etc. In this way, the locking operation of the first target can be completed through the corresponding atomic operation instructions of the ARM architecture.

[0049] In some embodiments, in view of the simplicity of the ARM instruction set, the instructions involved in the lock operation can be adjusted to reduce the decoding overhead. The atomic operation instructions provided in the ARM architecture, such as the LDREX instruction and the STREX instruction, are used to perform the lock and unlock operations. These instructions are designed for a multi-threaded environment and can reduce potential race conditions. Specifically, in some embodiments, the use of the atomic operation instructions of the ARM architecture to perform a lock operation on the first target includes: using the LDREX instruction of the ARM architecture to read the first target and set a lock mark. Using the STREX instruction of the ARM architecture to modify the first target with the lock mark set, and determine whether the value of the first target has changed. If there is no change, the lock operation on the first target is completed. If there is a change, the LDREX instruction is used to re-read the first target, and the STREX instruction is used again to modify it, and the judgment of whether the value of the first target has changed is re-performed, and this cycle is repeated until the value of the first target has not changed.

[0050] Among them, the lock mark is a mark that needs to be set when the LDREX instruction is executed. Specifically, the LDREX instruction is used to read the value in the memory and mark the exclusive access to the memory segment (that is, mark it through the lock mark). The above means reading the 4-byte memory value pointed to by register Ry, saving it to register Rx, and marking the exclusive access to the memory area pointed to by Ry. When the STREX instruction updates the memory value, it will check whether the memory segment has been marked as exclusive access, and use this to decide whether to update the value in the memory. If it is found that it has been marked as exclusive access when executing this instruction, the value in register Ry is updated to the memory pointed to by register Rz, and register Rx is set to 0. After the instruction is successfully executed, the exclusive access mark bit will be cleared. Once a STREX instruction is successfully executed, when you try to update the same memory segment using the STREX instruction in the future, you will find that the exclusive mark has been cleared and it can no longer be updated, thereby realizing the exclusive access locking mechanism. Of course, in this embodiment, if the value of the first target is found to have changed during the locking process, that is, the first target is modified by other threads, then it cannot be locked at this time, and the locking will fail. At this time, the final locking can be completed by repeating the cycle process, that is, the value of the first target (that is, the changed current value) can be re-read, and the above steps can be repeated, and the cycle is repeated until the locking is completed.

[0051] Afterwards, the specific optimization method is explained in the form of pseudo code, that is, how to set the code when establishing the database so that the corresponding instructions can be executed in the application later. The specific C pseudo code is:

[0052] / / Suppose there is a global variable counter, which needs to be atomically incremented

[0053] volatile int counter = 0;

[0054] / / Atomic increment using LDREX and STREX

[0055] int old_value,new_value;

[0056] do{

[0057] old_value=__sync_lock_test_and_set(&counter,counter+1); / / LDREX equivalent

[0058] }while(!__sync_bool_compare_and_swap(&counter,old_value,old_value+1)); / / STREX equivalent

[0059] The above code shows how to use the equivalent functionality of the LDREX and STREX instructions for atomic increment operations. __sync_lock_test_and_set is an atomic operation that reads the value of counter and sets it to a new value (in this case, counter+1). Then, __sync_bool_compare_and_swap attempts to change the value of counter from old_value to old_value+1. If the value of counter has not changed during this time (i.e., no other thread has modified it), this operation succeeds and the loop ends. Otherwise, the loop continues and reads the current value of counter again.

[0060] Step 104, in response to obtaining a memory access instruction, determining a second target of the memory access instruction, using the pre-read instruction of the ARM architecture to pre-read the second target, and then using the load and store instructions of the ARM architecture to access the pre-read data.

[0061] In this step, the memory access instruction is an instruction to access a certain data temporarily stored in the memory or cache. At the same time, the second target is the data to be read and accessed by the instruction. At this time, in order to speed up the processing speed and improve efficiency, a pre-read operation can be performed on it first. After the pre-reading is completed, the load and store instructions of the ARM architecture can be used to access, modify, and other operations on the data.

[0062] In some embodiments, suitable load and store instructions, i.e., LDR instructions and STR instructions, may be used for the memory access characteristics of the ARM architecture to reduce memory access latency. At the same time, consider using the ARM pre-fetch instruction PLD to load the data that may be needed into the cache in advance. Specifically, in some embodiments, the use of the pre-read instruction of the ARM architecture to pre-read the second target includes: using the PLD instruction of the ARM architecture to pre-read the second target. The use of the load and store instructions of the ARM architecture to access the pre-read data includes: using the LDR instruction of the ARM architecture to load the pre-read data, and using the STR instruction of the ARM architecture to store the pre-read data.

[0063] Afterwards, the specific optimization method is explained in the form of pseudo code, that is, how to set the code when establishing the database so that the corresponding instructions can be executed in the application later. The specific C pseudo code is:

[0064] / / Suppose there is an array data, and the data in it needs to be prefetched and loaded

[0065] int data

[100] ;

[0066] / / Use PLD to prefetch data

[0067] __builtin_prefetch(data);

[0068] / / Use LDR and STR to load and store

[0069] int temp = data[0]; / / LDR equivalent

[0070] data[1]=temp+1; / / STR equivalent

[0071] The above code uses LDR and STR for memory access and PLD for prefetching. Figure 2 As shown in the figure, the above code first uses __builtin_prefetch to prefetch the data in the data array and loads it into the cache (i.e., using the PLD instruction). Then, standard load (LDR) and store (STR) instructions (in this case, load data[0] and store data[1]) are used to access and modify the data in the array.

[0072] Step 106, in response to obtaining a memory barrier instruction, determining a third target of the memory barrier instruction, and adjusting the concurrency control strategy using a preset memory model of the ARM architecture to perform read and / or write operations on the third target in an order determined by preset rules.

[0073] In this step, the memory barrier instruction means that when multiple operations are executed, in order to ensure the execution order, it is necessary to use a barrier to protect certain data to prevent other operations from occupying or modifying these data during the execution of the operation. For example, operation A requires data a, but it will not use data a until the 10th instruction. At this time, if a subsequent operation B is formed, it also needs data a, but it uses data a in the first instruction. Then, in the scenario of multi-line parallel or concurrent access, data a may be adjusted by the subsequent operation B, resulting in possible failure of operation A. The memory barrier instruction is an instruction to ensure the execution order. Afterwards, the concurrency control strategy is a strategic file or data that controls concurrent execution.

[0074] In some embodiments, on the ARM architecture, memory barrier instructions are used to ensure the sequentiality of memory operations. By correctly using memory barrier instructions in locking operations, it is possible to ensure that related read / write operations are executed in the expected order, thereby avoiding data inconsistency problems. Specifically, in some embodiments, the use of the preset memory model of the ARM architecture to adjust the concurrency control strategy includes: determining the time node for reading the third target, and inserting the memory barrier field of the ARM architecture after reading according to the preset memory model, thereby adjusting the concurrency control strategy; determining the time node for writing the third target, and inserting the memory barrier field of the ARM architecture after writing according to the preset memory model, thereby adjusting the concurrency control strategy.

[0075] The specific optimization method can be explained in the form of pseudo code, that is, how to set the code when establishing the database so that the corresponding instructions can be executed in the application later. The specific C pseudo code is:

[0076] / / Suppose there is a shared resource shared_resource, concurrent access control is required

[0077] volatile int shared_resource=0;

[0078] / / Use appropriate memory barriers to ensure order of memory operations

[0079] int value = shared_resource; / / read shared resources

[0080] __sync_synchronize(); / / Memory barrier to ensure that previous read operations are visible to other threads / / Modify shared resources and use memory barrier again

[0081] shared_resource = value + 1; / / write to shared resources

[0082] __sync_synchronize(); / / Memory barrier to ensure that subsequent write operations are visible to other threads

[0083] The above code adjusts the concurrency control strategy according to the ARM memory model. The above code shows how to use memory barriers (__sync_synchronize) in a concurrent environment to ensure the order and visibility of memory operations. This helps to adapt to the ARM memory model and ensure the efficiency and consistency of locking operations.

[0084] Step 108, in response to obtaining an access instruction, determining the fourth target of the access instruction, determining at least one target field corresponding to the fourth target, and setting lock protection for the at least one target field respectively, so that when any target field of the fourth target is accessed, only the any one target field is locked through the lock protection.

[0085] In this step, the access instruction is an instruction for accessing a certain data. The fourth target is the object of the access instruction. In a database based on the ARM architecture, in order to reduce lock contention, a more fine-grained lock can be introduced to reduce lock contention. One of the data (i.e., the fourth target) generally consists of multiple fields, where each field can be used as a target field, or only part of it can be used as a target field. Afterwards, through the ARM architecture, corresponding lock protection is set for each target field, so that when the fourth target is accessed, if it accesses the first target field, only the target field is locked, and if it accesses the second target field, only the second target field is locked.

[0086] In some embodiments, the combination Figure 3 , by introducing finer-grained locks or adopting more complex concurrency control mechanisms, lock contention in concurrent environments can be reduced, thereby improving the overall performance of the database. Among them, the target field is specifically the field that requires concurrent access control, and only the fields that require concurrent access need corresponding lock protection. If the corresponding data or field itself does not require concurrent access, then it only allows one thread to operate on it, so there will be no competition problem. The specific optimization method is explained in the form of pseudocode, that is, how to set the code when establishing the database so that the corresponding instructions can be executed later when it is applied. The specific C pseudocode is:

[0087] / / Suppose there is a structure (MyStruct) that contains multiple fields, each of which requires concurrent access control

[0088] typedef struct{

[0089] int field1;

[0090] int field2;

[0091] }MyStruct;

[0092] / / Use fine-grained locks to protect each field

[0093] pthread_mutex_t lock1=PTHREAD_MUTEX_INITIALIZER;

[0094] pthread_mutex_t lock2=PTHREAD_MUTEX_INITIALIZER;

[0095] / / When accessing field1, only lock1

[0096] pthread_mutex_lock(&lock1);

[0097] MyStruct.field1=some_value;

[0098] pthread_mutex_unlock(&lock1);

[0099] / / When accessing field2, only lock2

[0100] pthread_mutex_lock(&lock2);

[0101] MyStruct.field2=another_value;

[0102] pthread_mutex_unlock(&lock2);

[0103] Combined with Figure 3 , the above code introduces finer-grained locks to reduce lock contention. The above code shows how to use fine-grained locks to reduce lock contention. By introducing a separate lock for each field that requires concurrent access control, we can reduce lock contention between threads and improve the overall performance of the database. This approach is particularly effective when multiple threads access different fields at the same time.

[0104] It can be seen from the above embodiments that a database instruction execution method provided by an embodiment of the present application includes: in response to obtaining a lock instruction, determining a first target of the lock instruction, and using an atomic operation instruction of the ARM architecture to perform a lock operation on the first target; in response to obtaining a memory access instruction, determining a second target of the memory access instruction, using a pre-read instruction of the ARM architecture to pre-read the second target, and then using the load and store instructions of the ARM architecture to access the pre-read data; in response to obtaining a memory barrier instruction, determining a third target of the memory barrier instruction, and using a preset memory model of the ARM architecture to adjust the concurrency control strategy to perform read and / or write operations on the third target in an order determined by a preset rule; in response to obtaining an access instruction, determining a fourth target of the access instruction, determining at least one target field corresponding to the fourth target, and setting lock protection for at least one target field respectively, so that when any target field of the fourth target is accessed, only any one target field is locked through lock protection. This application directly uses the corresponding instruction format of the ARM architecture to perform data operations when the database receives the corresponding instructions. That is, the corresponding instructions are set based on the ARM framework when setting the database, so as to achieve database and mainstream ARM architecture processor adaptation optimization, solve the performance problems caused by the adaptation of database products to the ARM architecture, and improve the database operation performance and efficiency under the ARM architecture.

[0105] Specifically, this application solves the performance problem of database products adapting to the ARM architecture through the above-mentioned method, realizes the adaptation and optimization of the database and the mainstream ARM architecture processor, releases an optimized version of the database under the ARM architecture processing environment, and forms the advantages of domestic basic software and hardware as a whole, thereby having the ability to realize the rapid migration and replacement of foreign commercial databases.

[0106] It should be noted that the method of the embodiment of the present application can be performed by a single device, such as a computer or server. The method of the embodiment of the present application can also be applied to a distributed scenario and completed by multiple devices cooperating with each other. In the case of such a distributed scenario, one of the multiple devices can only perform one or more steps in the method of the embodiment of the present application, and the multiple devices will interact with each other to complete the described method.

[0107] It should be noted that the above describes specific embodiments of the present application. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the above embodiments and still achieve the desired results. In addition, the processes depicted in the accompanying drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0108] Based on the same concept, corresponding to any of the above-mentioned embodiment methods, the present application also provides a database instruction execution device.

[0109] refer to Figure 4 The database instruction execution device is applied to a database of ARM architecture, and includes:

[0110] The first response module 410 is used to determine a first target of the lock instruction in response to obtaining the lock instruction, and use the atomic operation instruction of the ARM architecture to perform a lock operation on the first target.

[0111] The second response module 420 is used to determine the second target of the memory access instruction in response to obtaining the memory access instruction, use the pre-read instruction of the ARM architecture to pre-read the second target, and then use the load and store instructions of the ARM architecture to access the pre-read data.

[0112] The third response module 430 is used to determine the third target of the memory barrier instruction in response to obtaining the memory barrier instruction, and use the preset memory model of the ARM architecture to adjust the concurrency control strategy to perform read and / or write operations on the third target in an order determined by preset rules.

[0113] The fourth response module 440 is used to determine the fourth target of the access instruction in response to obtaining the access instruction, determine at least one target field corresponding to the fourth target, and set lock protection for the at least one target field, so that when accessing any target field of the fourth target, only the any one target field is locked through the lock protection.

[0114] In some exemplary embodiments, the first response module 410 is further configured to:

[0115] Using the LDREX instruction of the ARM architecture to read the first target, and set a lock mark;

[0116] Using the STREX instruction of the ARM architecture to modify the first target with the lock mark set, and determine whether the value of the first target changes;

[0117] If there is no change, the locking operation on the first target is completed.

[0118] In some exemplary embodiments, the first response module 410 is further configured to:

[0119] If there is a change, the first target is re-read using the LDREX instruction, and the STREX instruction is re-used to modify it, and the judgment is re-performed on whether the value of the first target has changed, and this cycle is repeated until the value of the first target has not changed.

[0120] In some exemplary embodiments, the second response module 420 is further configured to:

[0121] The second target is pre-read using the PLD instruction of the ARM architecture.

[0122] In some exemplary embodiments, the second response module 420 is further configured to:

[0123] The pre-read data is loaded using the LDR instruction of the ARM architecture, and the pre-read data is stored using the STR instruction of the ARM architecture.

[0124] In some exemplary embodiments, the third response module 430 is further configured to:

[0125] Determine a time node for reading the third target, and insert a memory barrier field of the ARM architecture after reading according to the preset memory model, so as to adjust the concurrency control strategy;

[0126] Determine a time node for writing the third target, and insert a memory barrier field of the ARM architecture after writing according to the preset memory model, so as to adjust the concurrency control strategy.

[0127] In some exemplary embodiments, the target field is specifically a field requiring concurrent access control.

[0128] For the convenience of description, the above devices are described in terms of functions divided into various modules. Of course, when implementing the embodiments of the present application, the functions of each module can be implemented in the same or multiple software and / or hardware.

[0129] The device of the above embodiment is used to implement the corresponding database instruction execution method in the above embodiment, and has the beneficial effects of the corresponding method embodiment, which will not be described in detail here.

[0130] Based on the same concept, corresponding to any of the above-mentioned embodiments, the present application also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the database instruction execution method as described in any of the above embodiments is implemented.

[0131] Figure 5A more specific schematic diagram of the hardware structure of an electronic device provided in this embodiment is shown, and the device may include: a processor 1010, a memory 1020, an input / output interface 1030, a communication interface 1040, and a bus 1050. The processor 1010, the memory 1020, the input / output interface 1030, and the communication interface 1040 are connected to each other through the bus 1050 in the device.

[0132] The processor 1010 can be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of this specification.

[0133] The memory 1020 may be implemented in the form of ROM (Read Only Memory), RAM (Random Access Memory), static storage device, dynamic storage device, etc. The memory 1020 may store an operating system and other application programs. When the technical solutions provided in the embodiments of this specification are implemented by software or firmware, the relevant program codes are stored in the memory 1020 and are called and executed by the processor 1010.

[0134] The input / output interface 1030 is used to connect the input / output module to realize information input and output. The input / output module can be configured in the device as a component (not shown in the figure), or it can be externally connected to the device to provide corresponding functions. The input device may include a keyboard, a mouse, a touch screen, a microphone, various sensors, etc., and the output device may include a display, a speaker, a vibrator, an indicator light, etc.

[0135] The communication interface 1040 is used to connect a communication module (not shown) to realize communication interaction between the device and other devices. The communication module can realize communication through a wired mode (such as USB, network cable, etc.) or a wireless mode (such as mobile network, WIFI, Bluetooth, etc.).

[0136] The bus 1050 includes a path that transmits information between the various components of the device (eg, the processor 1010, the memory 1020, the input / output interface 1030, and the communication interface 1040).

[0137] It should be noted that, although the above device only shows the processor 1010, the memory 1020, the input / output interface 1030, the communication interface 1040 and the bus 1050, in the specific implementation process, the device may also include other components necessary for normal operation. In addition, it can be understood by those skilled in the art that the above device may also only include the components necessary for implementing the embodiments of the present specification, and does not necessarily include all the components shown in the figure.

[0138] The electronic device of the above embodiment is used to implement the corresponding database instruction execution method in any of the above embodiments, and has the beneficial effects of the corresponding method embodiment, which will not be described in detail here.

[0139] Based on the same concept, corresponding to any of the above-mentioned embodiment methods, the present application also provides a non-transitory computer-readable storage medium, wherein the non-transitory computer-readable storage medium stores computer instructions, and the computer instructions are used to enable the computer to execute the database instruction execution method described in any of the above embodiments.

[0140] The computer-readable medium of this embodiment includes permanent and non-permanent, removable and non-removable media, and information storage can be achieved by any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, read-only compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, tape disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device.

[0141] The computer instructions stored in the storage medium of the above embodiment are used to enable the computer to execute the database instruction execution method described in any of the above embodiments, and have the beneficial effects of the corresponding method embodiments, which will not be repeated here.

[0142] Based on the same concept, corresponding to any of the above-mentioned embodiments and methods, the present application also provides a computer program product, which includes computer program instructions. In some embodiments, the computer program instructions can be executed by one or more processors of a computer so that the computer and / or the processor execute the database instruction execution method. Corresponding to the execution subject corresponding to each step in each embodiment of the database instruction execution method, the processor that executes the corresponding step can belong to the corresponding execution subject.

[0143] The computer program product of the above embodiment is used to enable the computer and / or the processor to execute the database instruction execution method described in any of the above embodiments, and has the beneficial effects of the corresponding method embodiments, which will not be repeated here.

[0144] Those skilled in the art should understand that the discussion of any of the above embodiments is merely illustrative and is not intended to imply that the scope of the present application (including the claims) is limited to these examples. In line with the concept of the present application, the technical features in the above embodiments or different embodiments may be combined, the steps may be implemented in any order, and there are many other variations of the different aspects of the embodiments of the present application as described above, which are not provided in detail for the sake of simplicity.

[0145] In addition, to simplify the description and discussion, and in order not to make the embodiments of the present application difficult to understand, the known power supply / ground connection with the integrated circuit (IC) chip and other components may or may not be shown in the provided drawings. In addition, the device can be shown in the form of a block diagram to avoid making the embodiments of the present application difficult to understand, and this also takes into account the fact that the details of the implementation of these block diagram devices are highly dependent on the platform to be implemented in the embodiments of the present application (that is, these details should be fully within the scope of understanding of those skilled in the art). In the case of elaborating specific details (e.g., circuits) to describe exemplary embodiments of the present application, it is obvious to those skilled in the art that the embodiments of the present application can be implemented without these specific details or when these specific details are changed. Therefore, these descriptions should be considered to be illustrative rather than restrictive.

[0146] Although the present application has been described in conjunction with specific embodiments of the present application, many replacements, modifications and variations of these embodiments will be apparent to those skilled in the art from the foregoing description. For example, other memory architectures (e.g., dynamic RAM (DRAM)) may use the embodiments discussed.

[0147] The embodiments of the present application are intended to cover all such substitutions, modifications and variations that fall within the broad scope of the appended claims. Therefore, any omissions, modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the embodiments of the present application should be included in the scope of protection of the present application.

Claims

1. A database instruction execution method, characterized in that: Databases for ARM architecture include: In response to acquiring a lock instruction, determining a first target of the lock instruction, and performing a lock operation on the first target using an atomic operation instruction of the ARM architecture; In response to obtaining a memory access instruction, determining a second target of the memory access instruction, using a pre-read instruction of the ARM architecture to pre-read the second target, and then using load and store instructions of the ARM architecture to access the pre-read data; In response to obtaining a memory barrier instruction, determining a third target of the memory barrier instruction, and adjusting a concurrency control strategy using a preset memory model of the ARM architecture to perform a read and / or write operation on the third target in an order determined by a preset rule; In response to obtaining an access instruction, a fourth target of the access instruction is determined, at least one target field corresponding to the fourth target is determined, and lock protection is set for each of the at least one target fields, so that when any target field of the fourth target is accessed, only the any one target field is locked through the lock protection.

2. The method according to claim 1, characterized in that: The using the atomic operation instruction of the ARM architecture to perform a locking operation on the first target includes: Using the LDREX instruction of the ARM architecture to read the first target, and set a lock mark; Using the STREX instruction of the ARM architecture to modify the first target with the lock mark set, and determine whether the value of the first target changes; If there is no change, the locking operation on the first target is completed.

3. The method according to claim 2, characterized in that After determining whether the value of the first target has changed, the method further includes: If there is a change, the first target is re-read using the LDREX instruction, and the STREX instruction is re-used to modify it, and the judgment is re-performed on whether the value of the first target has changed, and this cycle is repeated until the value of the first target has not changed.

4. The method according to claim 1, characterized in that: The pre-reading of the second target using the pre-reading instruction of the ARM architecture includes: The second target is pre-read using the PLD instruction of the ARM architecture.

5. The method according to claim 1, characterized in that The accessing of the pre-read data using the load and store instructions of the ARM architecture includes: The pre-read data is loaded using the LDR instruction of the ARM architecture, and the pre-read data is stored using the STR instruction of the ARM architecture.

6. The method according to claim 1, characterized in that The using the preset memory model of the ARM architecture to adjust the concurrency control strategy includes: Determine a time node for reading the third target, and insert a memory barrier field of the ARM architecture after reading according to the preset memory model, so as to adjust the concurrency control strategy; Determine a time node for writing the third target, and insert a memory barrier field of the ARM architecture after writing according to the preset memory model, so as to adjust the concurrency control strategy.

7. The method according to claim 1, characterized in that The target field is specifically a field that requires concurrent access control.

8. A database instruction execution device, characterized in that: Databases for ARM architecture include: A first response module, configured to determine a first target of the lock instruction in response to obtaining the lock instruction, and perform a lock operation on the first target using an atomic operation instruction of the ARM architecture; A second response module is used to determine a second target of the memory access instruction in response to obtaining the memory access instruction, use the pre-read instruction of the ARM architecture to pre-read the second target, and then use the load and store instructions of the ARM architecture to access the pre-read data; a third response module, configured to, in response to obtaining a memory barrier instruction, determine a third target of the memory barrier instruction, and adjust a concurrency control strategy using a preset memory model of the ARM architecture to perform a read and / or write operation on the third target in an order determined by a preset rule; The fourth response module is used to determine the fourth target of the access instruction in response to obtaining the access instruction, determine at least one target field corresponding to the fourth target, and set lock protection for the at least one target field respectively, so that when accessing any target field of the fourth target, only the any one target field is locked through the lock protection.

9. An electronic device, characterized in that: The method comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the method according to any one of claims 1 to 7 is implemented.

10. A non-transitory computer-readable storage medium, characterized in that: The non-transitory computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to implement the method according to any one of claims 1 to 7.