Method and system for improving TPC-B performance based on openGauss database
By sharing hardware encryption driver resources for concurrently executed clients in the openGauss database and using mutexes to control the consistency of global key handles, the problem of key negotiation resource consumption is solved and TPC-B performance is improved.
Patent Information
- Application Number
- CN202310923785.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-26
- Publication Date
- 2025-09-16
- Estimated Expiration
- 2043-07-26
AI Technical Summary
In the openGauss database, when using the pgbench tool to perform TPC-B performance testing, the key negotiation between the client and the server consumes a large amount of hardware resources, resulting in degraded hardware encryption performance and failing to demonstrate the advantages of hardware encryption.
By loading the same hardware encryption driver resource for concurrently executed clients, creating a mutex to control the consistency of the global key handle, obtaining the mutex during key negotiation and determining whether the global key handle is generated, referencing or generating the global key handle, and destroying the mutex and global key handle when the connection exits, the key negotiation time is reduced.
It reduces the key negotiation time between the client and the server, improves TPC-B performance, and solves the performance degradation problem in hardware transmission encryption scenarios.
Smart Images

Figure CN116961902B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of database technology, and in particular to a method and system for improving TPC-B performance based on an openGauss database. Background Art
[0002] The TPC-B model is a widely used benchmark for evaluating the transaction processing performance of database systems. For example, the performance testing tool pgbench, provided in the OpenGauss database, can simulate TPC-B test scenarios by configuring test scripts and parameters to evaluate database performance under this model's load.
[0003] In environments with high data security requirements, hardware encryption cards are required to protect sensitive data, such as database transmission encryption. Currently, when using the pgbench tool to perform network-based database performance testing, when simulating a large number of concurrent client connections, executing test cases, the generation of key handles for each connection through key negotiation with the server consumes significant hardware resources, severely degrading database transmission encryption performance and negating the benefits of hardware encryption.
[0004] Therefore, how to improve the performance of TPC-B by reducing the time required for key negotiation between the client and the server has become a technical problem that needs to be solved urgently. Summary of the Invention
[0005] In view of this, in order to overcome the deficiencies of the prior art, the present invention aims to provide a method and system for improving TPC-B performance based on the openGauss database.
[0006] According to a first aspect of the present invention, a method for improving TPC-B performance based on an openGauss database is provided, comprising:
[0007] Loading the same hardware encryption driver resource for concurrently executed clients, and creating a mutex lock for controlling the consistency of the global key handle during the loading of the hardware encryption driver resource;
[0008] When concurrently executing clients connect to the database service for key negotiation, they acquire the created mutex lock, determine whether the global key handle has been generated, and reference the global key handle based on the determination result.
[0009] When the concurrently executed client exits the connection with the database service, the created mutex is acquired, and the global key handle and mutex are destroyed according to the global key handle reference count.
[0010] Preferably, in the method for improving TPC-B performance based on the openGauss database of the present invention, when the concurrently executed client concurrently connects to the database service for key negotiation, the created mutex is obtained, it is determined whether the global key handle has been generated, and the global key handle is referenced according to the determination result, including: using the key handle generated for the first time when the concurrently executed client concurrently connects to the database service for key negotiation as the global key handle, and the global key handle is generated after a client successfully connects to the database service.
[0011] Preferably, in the method for improving TPC-B performance based on the openGauss database of the present invention, when concurrently executed clients concurrently connect to the database service for key negotiation, the created mutex is acquired, and it is determined whether the global key handle has been generated. The global key handle is referenced according to the determination result, including:
[0012] Get the created mutex lock and determine whether the global key handle has been generated. If the global key handle has been generated, increase the reference count of the global key handle by 1 and release the acquired mutex lock.
[0013] When the global key handle is not generated, call the SDF_GenerateKeyWithEPK_ECC function to generate a global key handle, add 1 to the reference count of the global key handle, and release the acquired mutex lock.
[0014] Preferably, in the method for improving TPC-B performance based on the openGauss database of the present invention, when the concurrently executed client exits the connection with the database service, the created mutex is obtained, and the global key handle and the mutex are destroyed according to the global key handle reference count, including: obtaining the created mutex, judging whether the current global key handle reference count is 1, if the current global key handle reference count is 1, destroying the current global key handle; if the current global key handle reference count is not 1, decrementing the global key handle reference count by 1, and releasing the acquired mutex.
[0015] Preferably, in the method for improving TPC-B performance based on the openGauss database of the present invention, when a concurrently executed client exits the connection with the database service, the created mutex is acquired, and the global key handle and the mutex are destroyed according to the global key handle reference count, including: after releasing the acquired mutex, determining whether the current global key handle reference count is 0, and if the current global key handle reference count is 0, destroying the acquired mutex.
[0016] According to a second aspect of the present invention, a system for improving TPC-B performance based on an openGauss database is provided. The system includes a shared server for loading the same hardware encryption driver resource for concurrently executed clients, and creating a mutex for controlling the consistency of a global key handle during the loading of the hardware encryption driver resource; when the concurrently executed clients concurrently connect to a database service for key negotiation, the created mutex is obtained, and it is determined whether a global key handle has been generated, and the global key handle is referenced based on the determination result; when the concurrently executed clients exit the connection with the database service, the created mutex is obtained, and the global key handle and the mutex are destroyed based on a reference count of the global key handle.
[0017] Preferably, in the system for improving TPC-B performance based on the openGauss database of the present invention, the shared server includes:
[0018] A hardware encryption driver resource loading module is used to load the same hardware encryption driver resource for concurrently executed clients, and to create a mutex lock for controlling the consistency of the global key handle during the loading of the hardware encryption driver resource;
[0019] The global key handle generation and reference module is used to obtain the created mutex lock when concurrently executing clients connect to the database service for key negotiation, determine whether the global key handle has been generated, and reference the global key handle based on the judgment result;
[0020] The global key handle destruction module is used to obtain the created mutex when the concurrently executed client exits the connection with the database service, and destroy the global key handle and mutex according to the global key handle reference count.
[0021] Preferably, in the shared service end of the system for improving TPC-B performance based on the openGauss database of the present invention, the global key handle generation and reference module is specifically used to: use the key handle generated for the first time when the concurrently executed client concurrently connects to the database service for key negotiation as the global key handle, and the global key handle is generated after a client successfully connects to the database service; obtain the created mutex lock, determine whether the global key handle has been generated, and when the global key handle has been generated, increase the reference count of the global key handle by 1 and release the acquired mutex lock; when the global key handle has not been generated, call the SDF_GenerateKeyWithEPK_ECC function to generate the global key handle, increase the reference count of the global key handle by 1 and release the acquired mutex lock.
[0022] Preferably, in the shared server of the system for improving TPC-B performance based on the openGauss database of the present invention, the global key handle destruction module is specifically used to: obtain and create a mutex lock, determine whether the current global key handle reference count is 1, and if the current global key handle reference count is 1, destroy the current global key handle; if the current global key handle reference count is not 1, decrement the global key handle reference count by 1 and release the acquired mutex lock; after releasing the acquired mutex lock, determine whether the current global key handle reference count is 0, and if the current global key handle reference count is 0, destroy the acquired mutex lock.
[0023] According to a third aspect of the present invention, a computer device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method described in the first aspect of the present invention when executing the program.
[0024] The present invention provides a method and system for improving TPC-B performance based on the openGauss database. By generating a global key handle, the handle is shared by counting the handle when multiple threads and multiple clients concurrently execute database services. The consistency of the generation, reference, and destruction processes of the global key handle is controlled by a mutex lock, thereby reducing the time for key negotiation between the client and the server to improve TPC-B performance and solve the problem of severe performance degradation in hardware transmission encryption scenarios. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0026] Figure 1 Schematic diagram of a system for improving TPC-B performance based on the openGauss database applicable to an embodiment of the present application.
[0027] Figure 2 This is an architecture diagram of a shared server in a system for improving TPC-B performance based on an openGauss database according to an embodiment of the present invention.
[0028] Figure 3 The figure is a flowchart of a method for improving TPC-B performance based on the openGauss database according to an embodiment of the present invention.
[0029] Figure 4 This is a schematic structural diagram of the device provided by the present invention. DETAILED DESCRIPTION
[0030] The embodiments of the present invention are described in detail below with reference to the accompanying drawings.
[0031] It should be noted that, in the absence of conflict, the following embodiments and features in the embodiments may be combined with each other; and, based on the embodiments in this disclosure, all other embodiments obtained by persons of ordinary skill in the art without creative work are within the scope of protection of this disclosure.
[0032] It should be noted that various aspects of the embodiments within the scope of the appended claims are described below. It should be apparent that the aspects described herein can be embodied in a wide variety of forms, and any specific structure and / or function described herein is merely illustrative. Based on this disclosure, it should be understood by those skilled in the art that an aspect described herein can be implemented independently of any other aspect, and two or more of these aspects can be combined in various ways. For example, any number of aspects described herein can be used to implement an apparatus and / or practice a method. In addition, other structures and / or functionalities other than one or more of the aspects described herein can be used to implement this apparatus and / or practice this method.
[0033] Figure 1 An exemplary system for improving TPC-B performance based on the openGauss database applicable to the embodiment of the present application is shown. Figure 1 As shown, the system may include a sharing server 101, a communication network 102 and / or one or more sharing clients 103. Figure 1 The example in FIG. 1 is a plurality of shared clients 103 .
[0034] The shared server 101 can be any appropriate server for storing information, data, programs and / or any other suitable type of content. In some embodiments, the shared server 101 can perform appropriate functions. For example, in some embodiments, the shared server 101 can be used to improve TPC-B performance. As an optional example, in some embodiments, the shared server 101 can be used to improve TPC-B performance based on the openGauss database. For example, the shared server 101 can be used to load the same hardware encryption driver resource for concurrently executed clients, and create a mutex lock for controlling the consistency of the global key handle during the process of loading the hardware encryption driver resource; when the concurrently executed clients concurrently connect to the database service for key negotiation, the created mutex lock is obtained, and the global key handle is determined to be generated, and the global key handle is referenced based on the determination result; when the concurrently executed clients exit the connection with the database service, the created mutex lock is obtained, and the global key handle and the mutex lock are destroyed according to the global key handle reference count.
[0035] As an example, in some embodiments, the sharing server 101 may send a method for improving hardware transmission encryption TPC-B performance based on the openGauss database to the sharing client 103 for user use based on the request of the sharing client 103 .
[0036] As another example, Figure 2 The following is an architecture diagram of a shared server in a system for improving TPC-B performance based on an openGauss database according to an embodiment of the present invention.
[0037] In this example, the shared server includes:
[0038] The hardware encryption driver resource loading module is used to load the same hardware encryption driver resource for concurrently executed clients, and to create a mutex lock for controlling the consistency of the global key handle during the loading of the hardware encryption driver resource.
[0039] The global key handle generation and reference module is used to obtain the created mutex lock, determine whether the global key handle has been generated, and reference the global key handle based on the determination result when concurrently executed clients concurrently connect to the database service for key negotiation. Specifically, the global key handle generation and reference module is used to: use the key handle first generated when the concurrently executed clients concurrently connect to the database service for key negotiation as the global key handle, where the global key handle is generated after a client successfully connects to the database service; obtain the created mutex lock, determine whether the global key handle has been generated, and if so, increment the reference count of the global key handle by 1 and release the acquired mutex lock; if the global key handle has not been generated, call the SDF_GenerateKeyWithEPK_ECC function to generate the global key handle, increment the reference count of the global key handle by 1 and release the acquired mutex lock.
[0040] The global key handle destruction module is used to acquire the created mutex lock when the concurrently executed client exits the connection with the database service, and destroy the global key handle and mutex lock according to the global key handle reference count. The global key handle destruction module is specifically used to: acquire the created mutex lock, determine whether the current global key handle reference count is 1, and if so, destroy the current global key handle; if not, decrement the global key handle reference count by 1 and release the acquired mutex lock; after releasing the acquired mutex lock, determine whether the current global key handle reference count is 0, and if so, destroy the acquired mutex lock.
[0041] As an optional example, in some embodiments, the shared client 103 is used to provide a visualization interface, which is used to receive a user's selection input operation to improve TPC-B performance, and, in response to the selection input operation, obtain an interface corresponding to the option selected by the selection input operation from the shared server 101 and display the interface, wherein the visualization interface at least displays information on improving TPC-B performance and operation options for the information on improving TPC-B performance.
[0042] In some embodiments, the communication network 102 can be any suitable combination of one or more wired and / or wireless networks. For example, the communication network 102 can include any one or more of the following: the Internet, an intranet, a wide area network (WAN), a local area network (LAN), a wireless network, a digital subscriber line (DSL) network, a frame relay network, an asynchronous transfer mode (ATM) network, a virtual private network (VPN), and / or any other suitable communication network. The shared client 103 can be connected to the communication network 102 via one or more communication links (e.g., communication link 104), and the communication network 102 can be linked to the shared server 101 via one or more communication links (e.g., communication link 105). The communication link can be any communication link suitable for transmitting data between the shared client 103 and the shared server 101, such as a network link, a dial-up link, a wireless link, a hard-wired link, any other suitable communication link, or any suitable combination of such links.
[0043] Shared client 103 may include any one or more clients that present an interface related to improving TPC-B performance in an appropriate form for user use and operation. In some embodiments, shared client 103 may include any suitable type of device. For example, in some embodiments, shared client 103 may include a mobile device, a tablet computer, a laptop computer, a desktop computer, and / or any other suitable type of client device.
[0044] Although the sharing server 101 is illustrated as a single device, in some embodiments, any suitable number of devices may be used to perform the functions performed by the sharing server 101. For example, in some embodiments, multiple devices may be used to implement the functions performed by the sharing server 101. Alternatively, the functions of the sharing server 101 may be implemented using a cloud service.
[0045] Based on the above system, an embodiment of the present application provides a method for improving TPC-B performance based on the openGauss database, which is described below through the following embodiments.
[0046] Reference Figure 3, shows a flowchart of a method for improving TPC-B performance based on the openGauss database according to an embodiment of the present application.
[0047] The method for improving TPC-B performance based on the openGauss database of this embodiment can be executed on a shared server. The method for improving TPC-B performance based on the openGauss database includes the following steps:
[0048] The same hardware encryption driver resource is loaded for concurrently executed clients, and a mutex lock is created during the loading process to control the consistency of the global key handle. In this embodiment, the mutex lock controls the consistency of the global key handle during generation, reference, and destruction. The mutex lock is used to lock shared data, ensuring that only one thread is running at a time. Multiple threads will compete for the mutex lock. The thread that grabs the mutex lock will execute first, and the threads that do not grab the mutex lock will need to wait. After the mutex lock is used up and released, the other waiting threads can compete for the mutex lock.
[0049] As an example, in this embodiment, when the pgbench tool simulates multi-client, multi-threaded concurrent execution of test cases, the program creates corresponding threads based on the externally specified number of threads. Each connection session to the backend database is evenly distributed within each thread based on the externally specified number of clients. Each connection session is denoted by a "client ID," such as "client 1, client 2, ..., client n." Each client shares the same hardware encryption driver resource. Loading this driver creates a mutex and other related resources to control the consistency of the global key handle.
[0050] When concurrently executed clients connect to the database service for key negotiation, they acquire the created mutex lock, determine whether the global key handle has been generated, and reference the global key handle based on the determination result.
[0051] In the method of this embodiment, when the global key handle is used by multiple threads and multiple clients to concurrently execute database services, the handle is shared by counting the handle. The global key handle counting method enables all database connections to use the same key handle. As an example, when clients responsible for multiple threads concurrently connect to the database service for key negotiation, it is necessary to obtain a mutex lock first. When the created mutex lock is obtained, it is first necessary to determine whether the global key handle has been generated. When the global key handle has been generated, the reference count of the global key handle is increased by 1, and the acquired mutex lock is released; when the global key handle has not been generated, the SDF_GenerateKeyWithEPK_ECC function is called to generate the global key handle, the reference count of the global key handle is increased by 1, and the acquired mutex lock is released.
[0052] It should be noted that, in the method of this embodiment, the key handle generated for the first time when the concurrently executed clients concurrently connect to the database service for key negotiation is used as the global key handle. The global key handle is generated after a client successfully connects to the database service.
[0053] When a concurrently executed client exits the connection to the database service, the created mutex is acquired, and the global key handle and the mutex are destroyed based on the global key handle reference count. In actual applications, after executing related test cases or when an exception requires exiting the connection, the mutex needs to be acquired first. When the mutex is acquired and created, the first step is to determine whether the current global key handle reference count is 1. If the current global key handle reference count is 1, the current global key handle is destroyed; if the current global key handle reference count is not 1, the global key handle reference count is decremented by 1, and the acquired mutex is released.
[0054] After releasing the acquired mutex, determine whether the current global key handle reference count is 0. If the current global key handle reference count is 0, destroy the acquired mutex.
[0055] like Figure 4 As shown, the present invention further provides a device including a processor 310, a communication interface 320, a memory 330 for storing a computer program executable by the processor, and a communication bus 340. The processor 310, the communication interface 320, and the memory 330 communicate with each other via the communication bus 340. The processor 310 executes the executable computer program to implement the above-described method for high-speed access to an ORC external table.
[0056] Among them, the computer program in the memory 330 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the various embodiments of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0057] The system embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units. They may be located in one place or distributed across multiple network units. Some or all of the modules may be selected based on actual needs to achieve the objectives of this embodiment. Persons of ordinary skill in the art will be able to understand and implement the present invention without inventive effort.
[0058] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus the necessary general hardware platform, or of course, by hardware. Based on this understanding, the essence of the above technical solution or the part that contributes to the existing technology can be embodied in the form of a software product. The computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a magnetic disk, an optical disk, etc., and includes a number of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods of each embodiment or certain parts of the embodiment.
[0059] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in the present invention should be included in the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be based on the scope of protection of the claims.
Claims
1. A method for improving TPC-B performance based on the openGauss database, characterized in that: The method comprises: The concurrently executed clients load the same hardware encryption driver resource, and create a mutex lock for controlling the consistency of the global key handle during the loading of the hardware encryption driver resource; When concurrently executing clients connect to the database service for key negotiation, they acquire the created mutex lock, determine whether the global key handle has been generated, and reference the global key handle based on the determination result. When the concurrently executed client exits the connection with the database service, the created mutex is acquired, and the global key handle and mutex are destroyed according to the global key handle reference count; When concurrently executing clients concurrently connect to the database service for key negotiation, obtaining a created mutex lock, determining whether a global key handle has been generated, and referencing the global key handle based on the determination result, including: using a key handle first generated when the concurrently executing clients concurrently connect to the database service for key negotiation as the global key handle, where the global key handle is generated after a client successfully connects to the database service; When concurrently executing clients connect to the database service for key negotiation, they acquire the created mutex lock, determine whether the global key handle has been generated, and reference the global key handle based on the determination result. This also includes: Get the created mutex lock and determine whether the global key handle has been generated. If the global key handle has been generated, increase the reference count of the global key handle by 1 and release the acquired mutex lock. When the global key handle is not generated, call the SDF_GenerateKeyWithEPK_ECC function to generate a global key handle, add 1 to the reference count of the global key handle, and release the acquired mutex lock.
2. The method for improving TPC-B performance based on the openGauss database according to claim 1, characterized in that: When the concurrently executed client exits the connection with the database service, the created mutex is obtained, and the global key handle and the mutex are destroyed according to the global key handle reference count, including: obtaining the created mutex, determining whether the current global key handle reference count is 1, and if the current global key handle reference count is 1, destroying the current global key handle; if the current global key handle reference count is not 1, decrementing the global key handle reference count by 1 and releasing the acquired mutex.
3. The method for improving TPC-B performance based on the openGauss database according to claim 2, characterized in that: When the concurrently executed client exits the connection with the database service, the created mutex is acquired, and the global key handle and the mutex are destroyed according to the global key handle reference count, including: after releasing the acquired mutex, determining whether the current global key handle reference count is 0, and if the current global key handle reference count is 0, destroying the acquired mutex.
4. A system for improving TPC-B performance based on the openGauss database, comprising a shared server for loading the same hardware encryption driver resource for concurrently executing clients, and creating a mutex lock for controlling the consistency of global key handles during the loading of the hardware encryption driver resource; When concurrently executing clients connect to the database service for key negotiation, they acquire the created mutex lock, determine whether the global key handle has been generated, and reference the global key handle based on the determination result. When the concurrently executed client exits the connection with the database service, the created mutex is acquired, and the global key handle and mutex are destroyed according to the global key handle reference count; The shared server includes: A hardware encryption driver resource loading module is used to load the same hardware encryption driver resource for concurrently executed clients, and to create a mutex lock for controlling the consistency of the global key handle during the loading of the hardware encryption driver resource; The global key handle generation and reference module is used to obtain the created mutex lock when concurrently executing clients connect to the database service for key negotiation, determine whether the global key handle has been generated, and reference the global key handle based on the judgment result; The global key handle destruction module is used to obtain the created mutex lock when the concurrently executed client exits the connection with the database service, and destroy the global key handle and mutex lock according to the global key handle reference count; The global key handle generation and reference module is specifically used to: use the key handle generated for the first time when concurrently executed clients concurrently connect to the database service for key negotiation as the global key handle, where the global key handle is generated after a client successfully connects to the database service; obtain the created mutex lock, determine whether the global key handle has been generated, and if so, increment the reference count of the global key handle by 1 and release the acquired mutex lock; if the global key handle has not been generated, call the SDF_GenerateKeyWithEPK_ECC function to generate the global key handle, increment the reference count of the global key handle by 1 and release the acquired mutex lock.
5. The system for improving TPC-B performance based on the openGauss database according to claim 4 is characterized in that: The global key handle destruction module is specifically used to: obtain and create a mutex lock, determine whether the current global key handle reference count is 1, and if the current global key handle reference count is 1, destroy the current global key handle; if the current global key handle reference count is not 1, decrement the global key handle reference count by 1 and release the acquired mutex lock; After releasing the acquired mutex, determine whether the current global key handle reference count is 0. If the current global key handle reference count is 0, destroy the acquired mutex.
6. A computer device, characterized in that: The computer device includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, the steps of the method according to any one of claims 1 to 3 are implemented.
Citation Information
Patent Citations
Multi-task mutual exclusion method and system based on file lock
CN114706691A
System, method and computer program product for programming a concurrent software application
US20100122253A1