WO2026007397A1 - 一种数据传输方法及相关装置 - Google Patents
一种数据传输方法及相关装置Info
- Publication number
- WO2026007397A1 WO2026007397A1 PCT/CN2025/075468 CN2025075468W WO2026007397A1 WO 2026007397 A1 WO2026007397 A1 WO 2026007397A1 CN 2025075468 W CN2025075468 W CN 2025075468W WO 2026007397 A1 WO2026007397 A1 WO 2026007397A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- target
- data
- thread
- address
- code
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/445—Program loading or initiating
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/448—Execution paradigms, e.g. implementations of programming paradigms
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/455—Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/48—Program initiating; Program switching, e.g. by interrupt
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/50—Allocation of resources, e.g. of the central processing unit [CPU]
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/54—Interprogram communication
Definitions
- This application relates to the field of computer technology, and in particular to a data transmission method and related apparatus.
- a microservice architecture breaks down an application into multiple small services, each of which can be deployed, run, and scaled independently, and different services can communicate with each other through service-oriented interfaces.
- Microservice architecture solves the problems of monolithic application architecture, such as difficulty in scaling, maintaining, deploying, and upgrading. Because each service can be independently scaled, maintained, deployed, and upgraded, and can be developed using different languages, microservice architecture has been widely adopted in large-scale software systems and cloud computing scenarios. However, microservice architecture does not only bring benefits. Compared to monolithic application architecture, microservice architecture has higher system complexity, and issues such as service discovery, load balancing, service monitoring, and business latency need to be considered and resolved.
- This application provides a data transmission method that can improve the efficiency of data transmission between services.
- a data transmission method for implementing data transmission between different services.
- This data transmission method includes: firstly, during the execution of a first process, a virtualization environment is created, and a target thread for providing the target service runs within this virtualization environment. Since the target thread is created and run by the first process after calling a dynamic link library, it runs within the memory space corresponding to the first process.
- the first process obtains the target address and reads or writes target data into that address. Specifically, if the first process reads target data from the target address, the target data is the data written to the target address after the target thread performs data processing operations; if the first process writes target data to the target address, the target data is the data passed from the first process to the target thread.
- data transmission between the target thread and the first process is achieved by the target thread writing the target data to the target address in the memory space, and then the first process retrieving the target data from the target address; or, the first process writing the target data to the target address in the memory space, and then the target thread retrieving the target data from the target address.
- a process providing a specific service creates a virtualized environment at runtime, and a thread providing the target service runs within this virtualized environment. Since the thread providing the target service actually runs within the memory space corresponding to the process, the thread and process can be considered as one entity. This ensures that both the thread and process can access the same memory address space, enabling data transfer between different services by performing data read and write operations based on these same memory addresses. Furthermore, data transfer does not require serialization, protocol encoding/decoding, or deserialization, effectively improving data transfer efficiency. In essence, this scheme transforms data interaction between two equal processes into data interaction between a process and its threads, thereby eliminating the cumbersome data transfer process between processes and improving data transfer efficiency.
- thread isolation can be achieved, ensuring that the operation of the threads does not affect the operation of the process itself (for example, if the thread crashes, the process itself will not also crash), thereby ensuring the independent operation of different services.
- the virtualization environment includes a virtual machine or sandbox, which provides an isolated environment and runtime environment for the target thread, thereby ensuring isolated operation between the target thread and the first process, and guaranteeing the smooth operation of the target thread within the first process.
- the target address used by the target thread to write target data can be off-heap memory within the virtualization environment, located within the memory space corresponding to the first process.
- the target thread since the target thread runs in a virtualized environment, it uses virtual memory addresses within the heap during runtime.
- the first process is unaware of these virtual memory addresses used by the target thread, and accessing them often requires additional cumbersome operations.
- the off-heap memory of the virtualized environment is directly accessible to the first process. Therefore, by writing the target data to off-heap memory, the first process can quickly retrieve the target data, improving data transfer efficiency.
- the process can access its own memory space to achieve data interaction with the thread, thereby ensuring efficient data transmission between different services, avoiding the execution of serialization, protocol encoding/decoding, and deserialization processes, and effectively improving data transmission efficiency.
- the source code of the target service can be compiled to obtain bytecode, or the bytecode of the target service can be directly obtained from a pre-provided source code. Then, the bytecode of the target service and the library files that the bytecode depends on at runtime are compiled to obtain machine code. Furthermore, the machine code is compiled and linked with the machine code of the virtualization environment to obtain the dynamic link library.
- the dynamic link library obtained through compilation and linking actually includes the machine code of the target service, the machine code of the library files that the target service depends on, and the machine code of the virtualization environment.
- the first process after the first process retrieves the target data from the target address, it deletes the target thread. That is, after the first process obtains the target data generated by the target thread, the target thread has completed the work instructed by the first process, and the first process no longer needs to retrieve the data generated by the target thread. Therefore, the first process can delete the target thread to free up idle computing and memory resources, which helps save the device's computing and memory resources.
- the first process after the first process deletes the target thread, it can delete the virtualization environment, for example, by deleting the virtual machine or sandbox used to run the target thread. Since the virtualization environment is primarily used to run the target thread that provides the target service, it becomes useless after the target thread is deleted, and can therefore be deleted as well, freeing up more computing and memory resources.
- the first process can release the virtualization environment to a resource pool.
- This released virtualization environment only contains the code for the target service.
- the virtualization environment itself is not deleted; only the target thread that was previously running within it is removed.
- the target service code remains in the virtualization environment, allowing the target thread to be run by executing that code.
- the first process subsequently needs to retrieve data generated by the target thread, it can directly obtain the virtualization environment from the resource pool and quickly start the target thread within it, eliminating the need to call dynamic link libraries to create the virtualization environment. This improves the efficiency of starting the target service within the first process.
- the target address can be specifically requested by the target thread. After the target thread completes writing the target data, the first process receives the target address sent by the target thread, thereby obtaining the target address.
- the target thread requests the target address for writing the target data and returns the target address to the first process after completing the writing of the target data.
- This allows the first process to obtain the data transmitted by the target thread simply by reading the data in its own corresponding memory space, improving data transmission efficiency.
- having the target thread that generates the target data request the target address i.e., the data generator requests the address for writing the data
- the target address is requested by the first process, and the first process pre-passes the target address for writing target data to the target thread.
- the first process receives a notification message sent by the target thread, which instructs the target thread to complete writing the target data. Then, the first process retrieves the target address pre-passed to the target thread, thereby determining from the target address to obtain the target data generated by the target thread.
- the first process pre-allocates the target address for writing the target data and passes the target address to the target thread. This ensures that the target thread strictly follows the target address in the memory space provided by the first process to write data. This facilitates the first process's management of its own memory space and ensures that the first process can quickly obtain the target data generated by the target thread, thereby improving the efficiency of data transmission.
- the source code of the target service and the source code of the first process are written in different programming languages. Since the services provided by the first process are not the same as the target service, and different services often use different programming languages based on actual needs during development, the source code of the target service and the source code of the first process can be written in different programming languages. For example, the source code of the first process can be written in C++, while the source code of the target service can be written in languages such as Java or Python.
- the first process provides a service different from the target service.
- this data transfer method could be applied to a microservice architecture, with the first process providing big data analytics services, while the target thread provides data read/write services.
- the first process can create the virtualization environment and the target thread by calling a dynamic link library.
- the dynamic link library includes the code for the virtualization environment and the code for the target service.
- the dynamic link library cannot be executed directly; it needs to be called by a process to run within that process.
- the entity that triggers the call to the dynamic link library can be any one or more threads already running in the first process.
- the process of another service can call the dynamic link libraries at runtime to create a virtualization environment and run a thread providing the target service within that environment. Furthermore, since the thread providing the target service actually runs within the memory space corresponding to the process, the thread and process can be considered as one entity. This ensures that both the thread and process can access the same memory address space, enabling data transfer between different services by performing data read and write operations based on the same memory address space. Moreover, no serialization, protocol encoding/decoding, or deserialization processes are required during data transfer, effectively improving data transfer efficiency.
- a data transmission device comprising: a processing module for enabling a first process to create a virtualized environment and a target thread running in the virtualized environment during its execution, the target thread providing target services and running in the memory space corresponding to the first process; an acquisition module for enabling the first process to acquire a target address, the target address being a memory address accessible to both the first process and the target thread; and the processing module further for enabling the first process to read or write target data to the target address; wherein, when the first process reads target data from the target address, the target data is data written to the target address after the target thread performs data processing operations; and when the first process writes target data to the target address, the target data is data passed from the first process to the target thread.
- the virtualization environment includes a virtual machine or a sandbox
- the target address is the off-heap memory of the virtualization environment, which is located in the memory space corresponding to the first process.
- the processing module is further configured to: compile the bytecode of the target service and the library files that the bytecode runtime depends on to obtain machine code; and link the machine code with the machine code of the virtualization environment to obtain a dynamic link library.
- the processing module is also used to cause the first process to delete the target thread.
- the processing module is further configured to cause: the first process to delete the virtualization environment; or, the first process to release the virtualization environment to a resource pool, wherein the virtualization environment released to the resource pool contains only the code of the target service.
- the target address is requested by the target thread, and the acquisition module is also used to enable:
- the first process receives the target address sent by the target thread.
- the target address is requested by the first process.
- the acquisition module is also used to enable the first process to receive a notification message sent by the target thread, which instructs the target thread to complete the writing of the target data.
- the first process acquires the target address that has been pre-passed to the target thread.
- the source code of the target service and the source code of the first process are written in different programming languages.
- the first process is used to provide a service different from the target service.
- the first process could create a virtualization environment and a target thread by calling a dynamic link library, which includes the code for the virtualization environment and the code for the target thread.
- a data transmission apparatus which may include a processor and a memory coupled together.
- the memory stores program instructions, and when the program instructions stored in the memory are executed by the processor, the method described in the first aspect or any implementation thereof is implemented.
- the steps of the various possible implementations of the first aspect executed by the processor please refer to the first aspect; further details will not be elaborated here.
- a computer-readable storage medium in which a computer program is stored, which, when run on a computer, causes the computer to perform the method of any implementation of the first aspect described above.
- circuit system including a processing circuit configured to perform the method of any implementation of the first aspect described above.
- a computer program product that, when run on a computer, causes the computer to execute any implementation of the first aspect described above.
- a chip system comprising a processor for supporting a server in implementing the functions involved in any implementation of the first aspect, such as processing data and/or information involved in the above methods.
- the chip system further includes a memory for storing necessary program instructions and data for the server.
- the chip system may be composed of chips or may include chips and other discrete devices.
- Figure 1 illustrates a process for data transmission between services provided in this application.
- Figure 2 is a schematic diagram of a system architecture provided in this application.
- FIG. 3 is a flowchart illustrating a data transmission method provided in this application.
- Figure 4 is a schematic diagram of data transmission between services in a related technology
- Figure 5 is a comparative diagram of a data transmission scheme provided in this application and related technologies
- Figure 6 is a schematic diagram of the compilation process of a dynamic link library provided in this application.
- Figure 7 is a flowchart illustrating a process A calling a dynamic link library according to this application.
- Figure 8 is a schematic diagram of a virtual machine destruction method provided in this application.
- Figure 9 is a schematic diagram of releasing a virtual machine to a resource pool according to this application.
- Figure 10A is a schematic diagram of a process A calling the Hudi engine to perform a read operation according to this application;
- FIG. 10B shows another flowchart of a process A calling the Hudi engine to perform a read operation, as provided in this application.
- Figure 11 is a schematic diagram of running the Hudi engine in a virtual machine according to this application.
- Figure 13 is a schematic diagram of a data transmission device provided in this application.
- Figure 14 is a schematic diagram of the structure of a computing device provided in this application.
- Figure 15 is a schematic diagram of the structure of a computing device cluster provided in this application.
- Figure 16 is a schematic diagram of another computing device cluster provided in this application.
- Figure 17 is a schematic diagram of the structure of a computer-readable storage medium provided in this application.
- Microservices architecture (or simply microservices) is a cloud-native architecture that includes numerous loosely coupled, independently deployable small services within a single application. Simply put, microservices architecture is a software architectural pattern where an application is broken down into small, autonomous service units that can be deployed, scaled, and maintained independently. Each service runs in its own process and can communicate with each other using inter-process communication mechanisms.
- microservice architecture The core idea of microservice architecture is to decompose an application into multiple small services, each with independent functionality and responsibilities. Each service can be developed, tested, deployed, and scaled independently, thereby improving the maintainability, scalability, and flexibility of the application. Furthermore, microservices allow different services to use different programming languages, enabling developers to choose the language best suited to their needs.
- a process is a program's execution activity on a certain set of data in a computer. It is the basic unit for system resource allocation and the foundation of the operating system structure.
- a thread is the smallest unit of computation that an operating system can schedule. It is contained within a process and is the actual unit of operation within a process.
- a thread refers to a single, sequential flow of control within a process; multiple threads can run concurrently within a process, each executing different tasks in parallel.
- Serialization is the process of converting an object's state information into a form that can be stored or transmitted. During serialization, the object writes its current state to temporary or persistent storage. Later, the object can be recreated by reading its state from or deserializing it from storage.
- Deserialization refers to the process of decoding and restoring serialized data to its original data structure or object. Deserialization is the reverse process of serialization. In serialization, the object's state information is converted into a byte stream for storage or transmission; in deserialization, these byte streams are converted back into the original object's state. Deserialization operations can be used in scenarios such as object recovery, distributed applications, and remote calls, allowing objects to be restored from stored byte streams, or, after transmission between different computers, the receiving end can use deserialization to convert the byte sequence into an operable object.
- Source code also called source program
- Source program refers to an uncompiled text file written according to a specific programming language specification; it is a series of human-readable computer language instructions.
- the most common format for source code is a text file, and the purpose of this typical format is to compile it into a computer program.
- the ultimate goal of computer source code is to translate human-readable text into binary instructions that the computer can execute; this process is called compilation and is accomplished by a compiler.
- Bytecode is a binary file containing an executable program, consisting of a sequence of op code/data pairs. Compared to machine instruction code that can be directly executed by hardware, bytecode is actually intermediate code, meaning it is instruction encoding that needs to be interpreted and executed by software code, and cannot be directly executed on hardware.
- Machine code typically refers to machine instructions, which are instructions that computer hardware (such as the Central Processing Unit (CPU)) can directly recognize and execute. It is represented in binary code. Machine code usually consists of two parts: the opcode and the operands.
- the opcode indicates the operation that the machine code is to perform, i.e., the function of the machine code; the operands indicate the objects involved in the operation and the location where the result is stored.
- the virtual machine is an important tool in programming languages (such as the Java Virtual Machine). Essentially, it is a software module that can provide a runtime environment for code in a specific language and enable isolated execution of the code.
- a virtual machine instance refers to a virtual machine running on hardware devices (such as processors); in other words, a virtual machine instance is a running virtual machine.
- Multiple virtual machine instances with identical configurations can be quickly created based on the same set of software code for a single virtual machine.
- a sandbox is an isolated environment for running program code. It can provide the runtime environment on which the program code depends and ensure that the runtime environment is isolated from the outside world, thereby achieving isolated execution of the program code.
- the virtual machine divides the memory it manages in main memory into multiple regions, each storing different types of data.
- the largest portion is the heap memory.
- the heap memory stores all object instances; this region is created when the virtual machine starts and is shared by all threads within the virtual machine. It is the primary working area of the garbage collector.
- Off-heap memory refers to memory space allocated and used outside of the virtual machine's on-heap memory. Off-heap memory is not managed by the garbage collector (GC) and is typically directly controlled by the application developers. Off-heap memory is primarily used in scenarios requiring direct control over memory allocation. The allocation and deallocation of off-heap memory are usually implemented manually through programming, such as using specific Application Programming Interfaces (APIs).
- APIs Application Programming Interfaces
- Figure 1 illustrates a process for data transmission between services according to this application.
- service A runs as process A
- service B runs as process B, requiring data transmission between them.
- request object A in process A serializes the request data to be transmitted, obtaining serialized data.
- the serialized data is encoded according to a communication protocol, resulting in encoded data, which is then sent to process B.
- process B decodes and deserializes it according to the communication protocol, enabling request object B to obtain the request data transmitted by process A.
- process B After process B completes the data processing operation on the request data transmitted by process A and generates the corresponding response data, response object B in process B serializes the response data to be transmitted, obtaining serialized data. Then, the serialized data is encoded according to the communication protocol to obtain encoded data, which is then sent to process A. After receiving the encoded data, process A decodes and deserializes the encoded data according to the communication protocol, thus enabling response object B to obtain the response data transmitted by process B.
- this application provides a data transmission method in which a process providing a certain service creates a virtualization environment at runtime, and runs a thread providing the target service within the virtualization environment. Since the thread providing the target service actually runs within the memory space corresponding to the process, the thread and the process can be considered as one entity, thus ensuring that both the thread and the process can access the same memory address. Data read and write operations are then performed based on the same memory address to achieve data transmission between different services. Furthermore, no serialization, protocol encoding/decoding, or deserialization processes are required during data transmission, effectively improving data transmission efficiency. In essence, this solution transforms data interaction between two equal processes into data interaction between a process and its threads, thereby eliminating the cumbersome data transmission process between processes and improving data transmission efficiency.
- thread isolation can be achieved, ensuring that the operation of the threads does not affect the operation of the process itself (for example, if the thread crashes, the process itself will not also crash), thereby ensuring the independent operation of different services.
- the execution device 101 can be, for example, a physical host or a physical server. Furthermore, the execution device 101 is communicatively connected to the data storage system 202 to obtain the program code stored in the data storage system 202, thereby implementing the data transmission method provided in this application.
- the data storage system 202 can be implemented, for example, by a storage device deployed on the execution device 201; for instance, the execution device 201 is a physical server, and the data storage system 202 is a hard disk deployed on the physical server.
- the data storage system 202 can be implemented by a storage device independent of the execution device; for example, the execution device 201 is a computing server, and the data storage system 202 is a dedicated data server for storing program code.
- the execution device 201 can obtain program code from the data storage system 202 and run a process on the execution device 201 based on the data transmission method provided in the embodiments of this application, thereby realizing data transmission within the process.
- Figure 3 is a flowchart illustrating a data transmission method provided in this application. As shown in Figure 3, the data transmission method includes the following steps 301-303.
- Step 301 During the execution of the first process, a virtualization environment and a target thread running in the virtualization environment are created.
- the target thread is used to provide target services and runs in the memory space corresponding to the first process.
- the data transmission method may be applied to a microservice architecture or other service architecture.
- the first process may be the execution form of a service under the microservice architecture, that is, the first process is used to provide a certain service under the microservice architecture.
- the first process when it needs to obtain data from another service (i.e., the target service), the first process can call a dynamic link library (DLL) to run the target service within itself.
- the service provided by the first process is different from the target service.
- the entity triggering the call to the DLL can be any one or more threads already running within the first process. For example, when a thread in the first process needs to obtain data from the target service, that thread can be the one triggering the call to the DLL.
- a dynamic link library includes code for both the virtualization environment and the target service. Calling the DLL enables the creation of a virtualization environment and the execution of the target service. Furthermore, DLLs cannot be executed directly; they must be called by a process to run within that process. Moreover, DLLs can be called by different processes, allowing them to run in different processes and provide corresponding services to those processes.
- the first process can create a virtualization environment based on the virtualization environment code included in the dynamic link library, and run the target service code within the virtualization environment, thereby enabling the target thread to run in the virtualization environment to provide the target service. Since the target thread is created and run by the first process after calling the dynamic link library, the target thread actually runs in the memory space corresponding to the first process (i.e., the memory space allocated to the first process by the operating system), meaning the running target thread belongs to the first process. Specifically, the target thread can include one or more threads, meaning the target service is provided by one or more threads included in the target thread.
- the first process can also create the virtualization environment and target thread by calling a static link library; this application does not specifically limit this.
- the first process runs the target thread through the virtualization environment, it can pass corresponding instructions to the target thread. This allows the target thread to perform data processing operations and obtain the corresponding target data based on the instructions passed by the first process.
- the first process can pass these instructions to the target thread through function calls or message notifications. In other words, the target thread performs data processing operations based on the request data sent by the first process and writes the obtained target data (i.e., response data) to the target address, so that the first process can retrieve the target data from that address.
- the first process can pass corresponding instructions to the target thread to instruct the target thread to retrieve the target data written by the first process to the target address specified by the first process.
- the target thread When the target thread runs in a virtualized environment, it operates in isolation, meaning its execution does not affect the normal operation of the first process. For example, if the target thread crashes abnormally, the first process will not also crash abnormally. Therefore, the first process and the target thread can independently provide different services, ensuring that the services provided by the first process are not affected by the target thread. This guarantees that even if the target thread crashes, the first process can still provide normal services, ensuring that the introduction of the target thread into the first process will not affect the normal operation of the first process itself.
- the virtualization environment described above may include a virtual machine or a sandbox.
- the virtualization environment can provide an isolated environment for the target thread to ensure isolated operation between the target thread and the first process; on the other hand, the virtualization environment can also provide a runtime environment for the target thread to ensure that the target thread can run normally, especially when the source code of the first process and the source code corresponding to the target thread are written in different languages. Based on the virtualization environment, it can be guaranteed that the target thread can be executed smoothly within the first process.
- Step 302 The first process obtains the target address, which is a memory address that can be accessed by both the first process and the target thread.
- the first process can also obtain the target address for writing the target data, so that the target data generated by the first process can be written into the target address, and the target thread can retrieve the target data from the target address.
- the target address is requested by the target thread.
- the target thread can request a block of memory for writing target data by calling the operating system's interface, thus obtaining the target address allocated by the operating system to the target thread within the memory space corresponding to the first process.
- the target thread can continuously write the data obtained from the data processing operations to the target address, enabling the target address to store the target data obtained from the completed data processing operations.
- the target thread After the target thread completes the data processing operation, the target thread requests a block of memory from the operating system for writing the target data, and after the operating system returns the target address to the target thread, the target thread writes the target data obtained from the data processing operation into the target address.
- the target thread When the target address is requested by the target thread, after the target thread completes writing the target data, it can pass the target address to the first process to indicate the address where the target data was written. That is, the first process obtains the target address by receiving it from the target thread. For example, the target thread can send a notification message to the first process, which includes the target address, specifically indicating that the target thread has completed writing the target data and that the data was written to the target address. Alternatively, if the first process passes instructions to the target thread via a function call, the target thread can directly return the target address to the first process after completing writing the target data, thus allowing the first process to obtain the target address.
- the target thread requests the target address for writing the target data and returns the target address to the first process after completing the writing of the target data.
- This allows the first process to obtain the data transmitted by the target thread simply by reading the data in its own corresponding memory space, improving data transmission efficiency.
- having the target thread that generates the target data request the target address i.e., the data generator requests the address for writing the data
- the target address is requested by the first process, and the first process needs to pass the requested target address to the target thread.
- the first process can request memory space to store the data generated by the target thread by calling operating system interfaces or other means, thus obtaining the target address.
- the first process invokes the target thread to perform data processing operations, it can pass this target address to the target thread, instructing it to write the generated target data into that address.
- the target thread can continuously write the data obtained from the data processing operations into the target address.
- the first process can receive a notification message from the target thread, instructing it to complete writing the target data. Based on this notification message, the first process retrieves the target address previously passed to the target thread, thereby determining from that address to obtain the target data generated by the target thread.
- the first process pre-allocates the target address for the target thread, it does not pass the target address to the target thread when invoking the target thread to perform data processing operations. Instead, the target thread stores the continuously generated data in a cache space while performing data processing. After completing the data processing, the target thread returns a feedback message to the first process confirming completion. In this way, after confirming the target thread's completion, the first process passes the pre-allocated target address to the target thread, allowing the target thread to copy the cached target data to the target address. After copying the target data to the target address, the target thread sends a notification message to the first process, informing it that the target data has been written to the target address.
- the first process pre-allocates the target address for writing the target data and passes the target address to the target thread. This ensures that the target thread strictly follows the target address in the memory space provided by the first process to write data. This facilitates the first process's management of its own memory space and ensures that the first process can quickly obtain the target data generated by the target thread, thereby improving the efficiency of data transmission.
- the target address can be either allocated by the first process or allocated by the target thread.
- the target address is specifically the off-heap memory of the virtualization environment.
- the target thread uses the memory of the first process after it runs the target thread by calling the dynamic link library, because the target thread runs in a virtualization environment, it uses virtual memory addresses within the heap. The first process does not recognize the virtual memory addresses used by the target thread, and accessing these addresses often requires additional cumbersome operations.
- the off-heap memory of the virtualization environment is directly accessible to the first process. Therefore, writing the target data to off-heap memory allows the first process to quickly retrieve the target data, improving data transfer efficiency.
- memory mapping technology can be employed to establish a mapping relationship between a block of on-heap memory in the virtualization environment and the actual memory address corresponding to the first process.
- the target thread can place the target data into the on-heap memory configured with the mapping relationship, allowing the first process to obtain the target data by accessing the corresponding mapped actual memory address externally.
- the target address can also be an address outside the memory space corresponding to the first process, meaning the target address is not located within the memory space corresponding to the first process.
- the target address could be a memory address outside the memory space corresponding to the first process, which is requested by the first process from the operating system and is specifically used to implement data transfer between the first process and the target thread.
- Step 303 The first process reads or writes target data to the target address.
- the target data is the data written to the target address after the target thread performs data processing operations; in the case where the first process writes target data to the target address, the target data is the data passed from the first process to the target thread.
- the first process when the first process reads target data from the target address, after obtaining the target address, the first process can retrieve the target data stored by the target thread at the target address by reading the data there. Since the first process and the target thread provide different services, retrieving the target data stored by the target thread from the target address by the first process essentially completes the data transfer process between the two services. Furthermore, because the target thread is embedded into the first process by calling a dynamic link library, the first process can directly access its allocated memory to obtain the data generated by the target thread, avoiding the cumbersome data transfer processes of serialization, protocol encoding/decoding, and deserialization, effectively improving data transfer efficiency.
- the first process When the first process writes target data to the target address, it can write the target data to be passed to the target thread. Then, the first process can send instructions to the target thread (e.g., via function calls) to instruct the target thread to read the target data transmitted by the first process from the target address. Thus, when the target thread reads the target data from the target address based on the instructions sent by the first process, the process of the first process transmitting data to the target thread is complete.
- the first process can delete the target thread. It is understood that, since the target thread used to provide the target service in this application runs within the first process, and the data generated by the target thread is primarily provided to the first process and unlikely to be provided to other processes, after the first process obtains the target data generated by the target thread, the target thread has completed the work instructed by the first process, and the first process no longer needs to obtain the data generated by the target thread. In this way, the first process can delete the target thread, thereby freeing up idle computing and memory resources, which helps save the device's computing and memory resources.
- the first process after the first process deletes the target thread, it can also delete the virtualization environment.
- the first process can delete the virtual machine or sandbox used to run the target thread. Since the virtualization environment is mainly used to run the target thread that provides the target service, it becomes useless after the target thread is deleted. Therefore, the virtualization environment can also be deleted, freeing up more computing and memory resources.
- the first process can release the virtualization environment to a resource pool.
- the virtualization environment released to the resource pool only includes the code for the target service. That is, the virtualization environment itself is not deleted; only the target thread that was originally running within it is removed.
- the code for the target service remains in the virtualization environment, allowing the target thread to be run by executing that code.
- the first process subsequently needs to retrieve data generated by the target thread, it can directly obtain the virtualization environment from the resource pool and quickly start the target thread within it, eliminating the need to call dynamic link libraries to create the virtualization environment. This improves the efficiency of starting the target service within the first process.
- the process of generating a dynamic link library can begin by compiling the source code of the target service to obtain bytecode; alternatively, the bytecode of the target service provided by the developers can be directly obtained. Then, the bytecode of the target service and the library files it depends on at runtime are compiled to obtain machine code. Finally, the compiled machine code is compiled and linked with the machine code of the virtualization environment to obtain the dynamic link library.
- the machine code of the virtualization environment can be provided by the developers or obtained by compiling the source code of the virtualization environment provided by the developers.
- the dynamic link library obtained through compilation and linking actually includes the machine code of the target service, the machine code of the library files that the target service depends on, and the machine code of the virtualization environment.
- the bytecode of the target service when generating the dynamic link library, can be compiled and linked together with the machine code of the virtualization environment (such as a virtual machine), so that the virtual machine can compile and run the bytecode of the target service at runtime, thereby starting the target thread.
- the machine code of the virtualization environment such as a virtual machine
- the source code of the target service and the source code of the first process may be written in different programming languages. Since the services provided by the first process are different from the target service, and different services often use different programming languages based on actual needs during development, the source code of the target service and the source code of the first process are very likely to be written in different programming languages. For example, the source code of the first process may be written in C++, while the source code of the target service may be written in Java or Python.
- this application first creates a virtualization environment by calling a dynamic link library. After the virtualization environment provides the environment that the target service depends on at runtime, the code of the target service is run in the virtualization environment, thereby starting and running the target thread that provides the target service, ensuring that the thread written in other programming languages runs in the first process.
- Figure 4 is a schematic diagram of inter-service data transmission in related technologies.
- the big data analysis service runs as process A, and the data read/write service runs as process B.
- Process A needs to read and write data in the database through process B.
- Process A and process B are deployed independently.
- Process A provides the big data analysis service, while process B is used to write and retrieve data.
- Process A and process B can communicate via Remote Procedure Call (RPC), enabling process A to perform data read and write operations on the database through process B.
- RPC Remote Procedure Call
- Figure 5 is a comparative schematic diagram of a data transmission scheme provided in this application and related technologies.
- two different services are actually run as independent processes, and data transmission between services is achieved based on inter-process communication.
- the code of the data read/write service is compiled and linked with the code of the virtual machine or sandbox into a dynamic link library, and the big data analysis service is run as process A.
- process A allows process A to run the data read/write service as a thread by calling the dynamic link library during its operation, thereby converting the data transmission between the two services into in-process memory access operations.
- FIG. 6 is a flowchart illustrating the compilation process of a dynamic link library provided in this application.
- Hudi is specifically a big data component capable of providing data read and write services.
- a Java compiler can be used to compile the Hudi source code into Java Class files, i.e., Java bytecode.
- the Hudi bytecode provided by the developer is already available, it may be unnecessary to perform the source code compilation process; instead, the subsequent compilation process can be directly executed on the Hudi bytecode.
- a compiler such as GraalVM Native Image Generator
- AOT Ahead-of-Time
- Hudi's machine code After obtaining Hudi's machine code, it is compiled and linked with virtual machine code (such as Substate VM code) and the Java Development Toolkit (JDK) to generate the dynamic link library Hudi.so.
- virtual machine code can include the Substate VM code and the execution environment code such as components and libraries that Hudi depends on at runtime.
- the Java Development Toolkit includes the Java runtime environment, Java tools, and Java base class libraries.
- process A calls the dynamic link library to create a virtual machine within process A and run the Hudi thread within that virtual machine.
- the Hudi component is actually compiled into the dynamic link library Hudi.so and embedded into the process, thus transforming the communication between process A and the Hudi process in related technologies into communication between process A and the dynamic link library Hudi.so.
- Figure 7 is a flowchart illustrating a process A calling a dynamic link library according to this application.
- the running process A can call the dynamic link library Hudi.so, thereby enabling process A to complete a data table read service provided by Hudi.
- the process of process A calling the dynamic link library may include the following steps 701-706.
- Step 701 Process A calls the dynamic link library Hudi.so.
- process A when process A needs to read or write data in the database, process A can call the dynamic link library Hudi.so.
- Step 702 Process A creates a virtual machine based on the dynamic link library Hudi.so.
- process A can create a virtual machine by running the virtual machine code.
- the virtual machine created by process A is a lightweight virtual machine, such as Substrate VM. Lightweight virtual machines start quickly, have a certain degree of isolation, and include the necessary runtime environment for the target, but generally do not include an operating system.
- Step 703 Process A initializes the Hudi engine within the virtual machine.
- the Hudi engine is native to Java and runs on the Java Virtual Machine, involving numerous startup steps (e.g., loading the Java Virtual Machine executable, loading classes from the file system, verifying Hudi bytecode, interpreting Hudi bytecode, running the static initializer, compiling the Hudi bytecode, and running the compiled machine code). Therefore, the startup time of the Hudi engine in related technologies is often in the order of seconds (1440ms in actual testing).
- the dynamic link library Hudi.so is obtained through AOT compilation. Therefore, when starting a Hudi instance, only the executable file needs to be loaded, and the optimized machine code can be started immediately, greatly reducing the startup time (78ms in actual testing) and ensuring efficient service response.
- this implementation also enables fine-grained management of the memory used by Hudi.
- each Hudi instance shares the memory of its Java Virtual Machine process, making fine-grained management impossible. For example, if a Java Virtual Machine is allocated 32GB of memory, regardless of the number of Hudi instances, they can only share this 32GB. This can easily lead to memory overflow in scenarios with a large number of Hudi instances, causing Hudi to malfunction.
- Hudi.so compiled using AOT each Hudi instance runs on an independent virtual machine, and each virtual machine has its own independent memory allocation, thus enabling fine-grained management of Hudi instance memory usage.
- Step 704 Process A calls the Hudi engine to perform read and write operations.
- Step 705 After completing the read/write operation, process A shuts down the Hudi engine.
- process A After completing the read and write operations, process A first releases the resources requested by the Hudi engine (such as off-heap memory), and then shuts down the Hudi engine, thereby releasing all resources related to the Hudi engine.
- the resources requested by the Hudi engine such as off-heap memory
- Step 706 Process A destroys the virtual machine or releases the virtual machine to the resource pool.
- process A can destroy the virtual machine, thereby releasing all resources associated with the virtual machine.
- process A can release the virtual machine to a resource pool, so that when the Hudi engine needs to be called later, a virtual machine in the resource pool can be requested and the Hudi engine can be quickly started in the virtual machine without having to call the dynamic link library Hudi.so again.
- Figure 8 is a schematic diagram of destroying a virtual machine according to this application.
- process A can create one or more virtual machines (such as virtual machine 1 and virtual machine 2 in Figure 8), and different virtual machines can run different Hudi instances.
- Each virtual machine includes heap memory for storing the Hudi image (i.e., Hudi's machine code), runtime heap memory for running the Hudi image, and reserved memory space.
- Hudi image i.e., Hudi's machine code
- runtime heap memory for running the Hudi image
- reserved memory space reserved memory space.
- FIG 9 is a schematic diagram of releasing a virtual machine to a resource pool according to this application.
- virtual machine 2 when releasing virtual machine 2, which has been created in process A, to the resource pool, virtual machine 2 will still occupy a certain amount of memory (i.e., Hudi image heap memory) to preserve the Hudi image.
- Hudi image heap memory i.e., Hudi image heap memory
- process A when process A still needs to call the Hudi engine to perform data read and write operations, it can request a virtual machine with space in the resource pool and quickly start the Hudi engine based on the Hudi image preserved in the virtual machine, thereby avoiding the process of recreating the virtual machine.
- Figure 10A illustrates the flowchart of a process A calling the Hudi engine to perform a read operation, as provided in this application.
- step 704 above may specifically include the following steps 7041-7044.
- Step 7041 Process A sends a data read request to the Hudi engine.
- process A When process A calls the Hudi engine, it can send a data read request to the Hudi engine to request the Hudi engine to read data from a certain data table in the database (i.e., the target data described in the above embodiment).
- step 7042 the Hudi engine requests off-heap memory and writes the data read from the database to off-heap memory.
- the Hudi engine Upon receiving a data read request, the Hudi engine first requests off-heap memory by calling the operating system interface. Since the Hudi engine is embedded in process A, the off-heap memory requested by the Hudi engine is also the memory of process A. Based on the requested off-heap memory, the Hudi engine reads the corresponding data from the database and writes the read data to the off-heap memory.
- Figure 11 is a schematic diagram of running the Hudi engine within a virtual machine according to this application.
- the Hudi engine in addition to the memory allocated to the virtual machine, the Hudi engine also requests off-heap memory.
- This off-heap memory is located outside the memory managed by the virtual machine, but is still located within the memory space allocated to process A by the operating system.
- the Hudi engine After the Hudi engine finishes reading the data, it can return the address of the off-heap memory (i.e., the target address described in the above embodiment) to process A so that process A can obtain the data based on the off-heap memory address.
- the address of the off-heap memory i.e., the target address described in the above embodiment
- Step 7044 Process A reads data from off-heap memory.
- process A After obtaining the address of the off-heap memory, since the off-heap memory belongs to the memory space corresponding to process A, process A can directly read the data in the off-heap memory based on the address of the off-heap memory.
- Figure 10B illustrates another flow diagram of process A calling the Hudi engine to perform a read operation according to this application.
- process A first requests a memory address from the operating system, then sends a data read request to the Hudi engine, carrying the requested memory address in the request.
- the Hudi engine can write the data read from the database to the memory address based on the memory address carried in the data read request.
- the Hudi engine returns a notification message to process A, indicating that the Hudi engine has written the data to off-heap memory, thereby triggering process A to read the data from the memory address.
- the first process is used to provide a service different from the target service.
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Devices For Executing Special Programs (AREA)
- Stored Programmes (AREA)
Abstract
一种数据传输方法,应用于实现不同服务间的数据传输过程。在该数据传输方法中,提供某一服务的进程在运行时创建虚拟化环境,并且在虚拟化环境内运行提供目标服务的线程。由于提供目标服务的线程实际上是运行于进程对应的内存空间内,因此线程与进程可以视为一体,从而能够保证线程与进程都能够访问同一片内存空间的地址,进而基于同一片内存空间的地址执行数据读写来实现不同服务间的数据传输,且数据传输期间无需执行序列化、协议编解码以及反序列化等过程,有效地提高了数据传输效率。即,本方案的本质是将对等的两个进程之间的数据交互变换为进程与进程内的线程之间的数据交互,从而免去进程间繁琐的数据传输过程,提高数据传输效率。
Description
本申请要求于2024年07月04日提交国家知识产权局、申请号为202410895764.5、申请名称为“一种数据传输方法及相关装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
本申请涉及计算机技术领域,尤其涉及一种数据传输方法及相关装置。
随着互联网的发展,软件系统逐渐从单体应用架构向微服务架构演进。微服务架构是将一个应用程序拆分为多个小的服务,每个服务都可以独立部署、运行和扩展,且不同的服务之间可以通过服务化接口来进行通信。
微服务架构解决了单体应用架构难于扩展、难于维护、难于部署、难于升级的问题,因为每个服务可以独立扩展、维护、部署和升级,还可以使用不同的语言开发,因此微服务架构在大型软件系统、云计算等场景已经被广泛采用。但是,微服务架构并非只带来好处,相对于单体应用架构,微服务架构的系统复杂度更高,服务发现、负载均衡、服务监控、业务时延等方面问题都需要考虑和解决。
具体来说,在微服务架构下,服务是以进程的形式来运行的,因此两个服务之间的通信本质上就是两个进程之间的通信。并且,两个服务往往是需要支持跨服务器部署的,因此在两个服务跨服务器执行数据交互时,数据传输期间往往需要执行序列化、协议编解码以及反序列化等过程,导致服务之间的数据传输效率较低。
本申请提供一种数据传输方法,能够提高服务间的数据传输效率。
第一方面,提供一种数据传输方法,应用于实现不同服务间的数据传输过程。该数据传输方法包括:首先,第一进程中在运行过程中创建虚拟化环境并在虚拟化环境中运行用于提供目标服务的目标线程,目标线程用于提供目标服务。由于目标线程是第一进程调用动态链接库后创建并运行的,因此目标线程运行于第一进程对应的内存空间内。
然后,第一进程获取目标地址,并在目标地址中读取或写入目标数据。其中,在第一进程是在目标地址中读取目标数据的情况下,目标数据是目标线程执行数据处理操作后写入到目标地址的数据;在第一进程是在目标地址中写入目标数据的情况下,目标数据为第一进程传递给目标线程的数据。
即,目标线程与第一进程之间的数据传输是通过由目标线程将目标数据写入至内存空间的目标地址中,再由第一进程从目标地址取出目标数据来实现;或者,由第一进程将目标数据写入至内存空间的目标地址中,再由目标线程从目标地址取出目标数据来实现。
本方案中,提供某一服务的进程在运行时创建虚拟化环境,并且在虚拟化环境内运行提供目标服务的线程。由于提供目标服务的线程实际上是运行于进程对应的内存空间内,因此线程与进程可以视为一体,从而能够保证线程与进程都能够访问同一片内存空间的地址,进而基于同一片内存空间的地址执行数据读写来实现不同服务间的数据传输,且数据传输期间无需执行序列化、协议编解码以及反序列化等过程,有效地提高了数据传输效率。即,本方案的本质是将对等的两个进程之间的数据交互变换为进程与进程内的线程之间的数据交互,从而免去进程间繁琐的数据传输过程,提高数据传输效率。
此外,通过将提供目标服务的线程运行于虚拟化环境内,能够实现线程的隔离,保证线程的运行并不会影响到进程本身的运行(例如线程崩溃后不会导致进程本身也发生崩溃),从而保证不同服务间的独立运行。
在一种可能的实现方式中,虚拟化环境包括虚拟机或沙箱,用于为目标线程提供隔离环境以及运行时环境,从而确保目标线程与第一进程之间的隔离运行,且保证目标线程在第一进程内的顺利运行。此外,目标线程用来写入目标数据的目标地址可以为虚拟化环境的堆外内存,堆外内存位于第一进程对应的内存空间内。
在本方案中,由于目标线程跑在虚拟化环境上,目标线程在运行时使用的是堆内的虚拟内存地址。对于第一进程而言,第一进程并不认识目标线程运行时所使用的虚拟内存地址,如果第一进程要访问该虚拟内存地址往往还需要额外的繁琐操作。然而,虚拟化环境的堆外内存则是第一进程可以直接访问的,因此通过将目标数据写入在堆外内存,能够方便第一进程快速地获取到目标数据,提高数据传输的效率。
并且,由于堆外内存本身是分配给进程的内存空间,因此进程可以通过访问自身对应的内存空间来实现与线程之间的数据交互,从而确保不同服务间高效的数据传输,避免执行序列化、协议编解码以及反序列化等过程,有效地提高了数据传输效率。
在一种可能的实现方式中,在第一进程加载动态链接库之前,为了实现动态链接库的构建,可以是先对目标服务的源代码进行编译,得到字节码,或者是直接获取预先提供的目标服务的字节码;然后,对目标服务的字节码和字节码运行时所依赖的库文件执行编译,得到机器码;并且,将机器码与虚拟化环境的机器码进行编译链接,得到动态链接库。也就是说,在编译链接得到的动态链接库中实际上是包括目标服务的机器码、目标服务所依赖的库文件的机器码以及虚拟化环境的机器码。
在本方案中,由于机器码是能够直接被计算机硬件所识别且运行的,因此在第一进程调用动态链接库之后,能够通过直接运行动态链接库中的机器码来实现虚拟化环境的创建以及目标线程的启动,无需再执行字节码的编译过程,从而提高目标线程的启动性能。
在一种可能的实现方式中,在第一进程从目标地址获取目标数据之后,第一进程删除目标线程。即,在第一进程获取到目标线程所生成的目标数据之后,目标线程已完成第一进程所指示的工作,第一进程暂时不再需要获取目标线程所生成的数据。因此,第一进程可以是将目标线程删除,从而腾出空闲的计算资源和内存资源,有助于节省设备的计算资源以及内存资源。
在一种可能的实现方式中,在第一进程删除目标线程后,第一进程可以删除虚拟化环境,例如第一进程删除用于运行目标线程的虚拟机或沙箱。由于虚拟化环境主要是用于运行提供目标服务的目标线程,因此在删除目标线程之后,虚拟化环境也就没有实际用途了,进而可以将虚拟化环境也一并删除,从而腾出更多的计算资源和内存资源。
或者,第一进程将虚拟化环境释放至资源池,其中被释放至资源池的虚拟化环境中仅包括目标服务的代码。也就是说,虚拟化环境并没有被删除,而是仅仅删除原先在虚拟化环境中所运行的目标线程,且虚拟化环境中还保留有目标服务的代码,能够通过运行目标服务的代码来实现运行目标线程。在将虚拟化环境释放至资源池的情况下,如果第一进程后续需要继续获取目标线程所生成的数据,则可以是直接从资源池中获取虚拟化环境并在虚拟化环境中快速地启动目标线程,而不再需要执行调用动态链接库来创建虚拟化环境的过程,能够提高在第一进程内启动目标服务的效率。
在一种可能的实现方式中,目标地址具体可以是目标线程申请的。在目标线程完成目标数据的写入后,第一进程接收目标线程发送的目标地址,从而获取到目标地址。
本方案中,由目标线程来申请用于写入目标数据的目标地址并在完成目标数据的写入后向第一进程返回目标地址,能够使得第一进程通过读取自身对应的内存空间中的数据即可获得目标线程所传递的数据,提高了数据传输效率。并且,由生成目标数据的目标线程来申请目标地址(即由数据生成者来申请写入数据的地址),能够实现按需申请地址,提高内存空间的利用率,且便于实现内存空间的管理。
在一种可能的实现方式中,目标地址是第一进程申请的,且第一进程预先向目标线程传递了用于写入目标数据的目标地址。在目标线程完成目标数据的写入后,第一进程接收目标线程发送的通知消息,该通知消息用于指示目标线程完成目标数据的写入。然后,第一进程获取预先向目标线程所传递的目标地址,从而确定从目标地址中获取目标线程所生成的目标数据。
本方案中,由第一进程来提前申请用于写入目标数据的目标地址并向目标线程传递目标地址,能够使得目标线程严格按照第一进程所提供的内存空间中的目标地址来写入数据,便于第一进程实现自身的内存空间的管理,且确保第一进程能够快速地获取目标线程所生成的目标数据,提高数据传输的效率。
在一种可能的实现方式中,目标服务的源代码与第一进程的源代码是基于不同的编程语言所编写的。由于第一进程所提供的服务与目标服务并不相同,且不同的服务在开发时往往可能会根据实际需求来采用相应的编程语言,因此目标服务的源代码与第一进程的源代码可以是基于不同的编程语言所编写的。例如,第一进程的源代码是基于C++语言所编写的,而目标服务的源代码则可以是基于Java语言或Python语言等语言所编写的。
在一种可能的实现方式中,第一进程用于提供与目标服务不同的服务。例如,该数据传输方法具体可以是应用于微服务架构,且第一进程用于提供大数据分析服务,目标线程所提供的目标服务则可以为数据读写服务。
在一种可能的实现方式中,第一进程可以是通过调用动态链接库来创建虚拟化环境和目标线程。其中,动态链接库包括虚拟化环境的代码和目标服务的代码。动态链接库是无法直接运行的,需要在进程调用时才能够实现在进程内运行。触发调用动态链接库的主体可以是第一进程中已运行的任意一个或多个线程。
本方案中,通过将目标服务的代码和虚拟化环境的代码编译为动态链接库的形式,能够使得另一个服务的进程在运行时可以调用动态链接库来创建虚拟化环境且在虚拟化环境内运行提供目标服务的线程。并且,由于提供目标服务的线程实际上是运行于进程对应的内存空间内,因此线程与进程可以视为一体,从而能够保证线程与进程都能够访问同一片内存空间的地址,从而基于同一片内存空间的地址执行数据读写来实现不同服务间的数据传输,且数据传输期间无需执行序列化、协议编解码以及反序列化等过程,有效地提高了数据传输效率。
第二方面,提供一种数据传输装置,包括:处理模块,用于使得第一进程中在运行过程中创建虚拟化环境以及在虚拟化环境中运行的目标线程,目标线程用于提供目标服务,目标线程运行于第一进程对应的内存空间内;获取模块,用于使得第一进程获取目标地址,目标地址为第一进程和目标线程均能够访问的内存地址;处理模块,还用于使得第一进程在目标地址中读取或写入目标数据;其中,在第一进程是在目标地址中读取目标数据的情况下,目标数据是目标线程执行数据处理操作后写入到目标地址的数据;在第一进程是在目标地址中写入目标数据的情况下,目标数据为第一进程传递给目标线程的数据。
在一种可能的实现方式中,虚拟化环境包括虚拟机或沙箱,目标地址为虚拟化环境的堆外内存,堆外内存位于第一进程对应的内存空间内。
在一种可能的实现方式中,处理模块,还用于:对目标服务的字节码和字节码运行时所依赖的库文件执行编译,得到机器码;将机器码与虚拟化环境的机器码进行链接,得到动态链接库。
在一种可能的实现方式中,在第一进程从目标地址获取目标数据之后,处理模块,还用于使得第一进程删除目标线程。
在一种可能的实现方式中,在第一进程删除目标线程后,处理模块,还用于使得:第一进程删除虚拟化环境;或者,第一进程将虚拟化环境释放至资源池,其中被释放至资源池的虚拟化环境中仅包括目标服务的代码。
在一种可能的实现方式中,目标地址是目标线程申请的,获取模块,还用于使得:
在目标线程完成目标数据的写入后,第一进程接收目标线程发送的目标地址。
在一种可能的实现方式中,目标地址是第一进程申请的,获取模块,还用于使得第一进程接收目标线程发送的通知消息,通知消息用于指示目标线程完成目标数据的写入;第一进程获取预先向目标线程所传递的目标地址。
在一种可能的实现方式中,目标服务的源代码与第一进程的源代码是基于不同的编程语言所编写的。
在一种可能的实现方式中,第一进程用于提供与目标服务不同的服务。
在一种可能的实现方式中,第一进程可以是通过调用动态链接库来创建虚拟化环境和目标线程,动态链接库包括虚拟化环境的代码和目标线程的代码。
第三方面,提供一种数据传输装置,可以包括处理器,处理器和存储器耦合,存储器存储有程序指令,当存储器存储的程序指令被处理器执行时实现上述第一方面或第一方面任一实现方式的方法。对于处理器执行第一方面的各个可能实现方式中的步骤,具体均可以参阅第一方面,此处不再赘述。
第四方面,提供了一种计算机可读存储介质,计算机可读存储介质中存储有计算机程序,当其在计算机上运行时,使得计算机执行上述第一方面任一实现方式的方法。
第五方面,提供一种电路系统,电路系统包括处理电路,处理电路配置为执行上述第一方面任一实现方式的方法。
第六方面,提供一种计算机程序产品,当其在计算机上运行时,使得计算机执行上述第一方面任一实现方式的方法。
第七方面,提供一种芯片系统,该芯片系统包括处理器,用于支持服务器实现上述第一方面任一实现方式中所涉及的功能,例如,处理上述方法中所涉及的数据和/或信息。在一种可能的设计中,芯片系统还包括存储器,存储器,用于保存服务器必要的程序指令和数据。该芯片系统,可以由芯片构成,也可以包括芯片和其他分立器件。
上述第二方面至第七方面的有益效果可以参考上述第一方面的介绍,在此不再赘述。
图1为本申请提供的一种服务间实现数据传输的过程;
图2为本申请提供的一种系统架构的示意图;
图3为本申请提供的一种数据传输方法的流程示意图;
图4为相关技术中的一种服务间执行数据传输的示意图;
图5为本申请提供的一种数据传输方案与相关技术的对比示意图;
图6为本申请提供的一种编译动态链接库的流程示意图;
图7为本申请提供的一种进程A调用动态链接库的流程示意图;
图8为本申请提供的一种销毁虚拟机的示意图;
图9为本申请提供的一种释放虚拟机至资源池的示意图;
图10A为本申请提供的一种进程A调用Hudi引擎执行读取操作的流程示意图;
图10B为本申请提供的一种进程A调用Hudi引擎执行读取操作的另一流程意图;
图11为本申请提供的一种在虚拟机内运行Hudi引擎的示意图;
图12A为本申请提供的一种进程A调用Hudi引擎执行写入操作的流程示意图;
图12B为本申请提供的一种进程A调用Hudi引擎执行写入操作的另一流程意图;
图13为本申请提供的一种数据传输装置的结构示意图;
图14为本申请提供的一种计算设备的结构示意图;
图15为本申请提供的一种计算设备集群的结构示意图;
图16为本申请提供的另一种计算设备集群的结构示意图;
图17为本申请提供的一种计算机可读存储介质的结构示意图。
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。
本申请的说明书和权利要求书及上述附图中的术语“第一”、“第二”、“第三”、“第四”等(如果存在)是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。应该理解这样使用的数据在适当情况下可以互换,以便这里描述的实施例能够以除了在这里图示或描述的内容以外的顺序实施。
此外,术语“包括”和“具有”以及他们的任何变形,意图在于覆盖不排他的包含,例如,包含了一系列步骤或单元的过程、方法、系统、产品或设备不必限于清楚地列出的那些步骤或单元,而是可包括没有清楚地列出的或对于这些过程、方法、产品或设备固有的其它步骤或单元。
为了便于理解,以下先介绍本申请实施例涉及的一些技术术语。
(1)微服务架构
微服务架构(或简称为微服务)是一种云原生架构,在单个应用中包含众多松散耦合且可单独部署的小型服务。简单来说,微服务架构是一种软件架构模式,其中应用程序被分解为小型、自治的服务单元,这些服务单元可以独立部署、扩展和维护。每个服务都运行在自己的进程中,可以使用进程间通信机制相互通信。
微服务架构的核心思想是将应用程序分解为多个小型服务,每个服务都具有独立的功能和责任。每个服务都可以独立开发、测试、部署和扩展,从而提高了应用程序的可维护性、可扩展性和灵活性。此外,微服务还使得不同的服务可以使用不同的开发语言,从而使得开发人员可以选择最适合其需求的开发语言。
(2)进程(Process)
进程是计算机中的程序关于某数据集合上的一次运行活动,是系统进行资源分配的基本单位,是操作系统结构的基础。
(3)线程(thread)
线程是操作系统能够进行运算调度的最小单位。它被包含在进程之中,是进程中的实际运作单位。一条线程指的是进程中一个单一顺序的控制流,一个进程中可以并发多个线程,每条线程并行执行不同的任务。
通常,在一个进程中可以包含多个线程,多个线程均可以利用进程所拥有的资源。在引入线程的操作系统中,通常都是把进程作为分配资源的基本单位,而把线程作为独立运行和独立调度的基本单位。
(4)序列化(Serialization)
序列化是将对象的状态信息转换为可以存储或传输的形式的过程。在序列化期间,对象将其当前状态写入到临时或持久性存储区。以后,可以通过从存储区中读取或反序列化对象的状态,重新创建该对象。
(5)反序列化
反序列化是指将序列化后的数据进行解码和还原,恢复为原始的数据结构或对象的过程。反序列化是序列化的逆过程。在序列化中,对象的状态信息被转换为字节流以便于存储或传输,而在反序列化中,这些字节流将被重新转换为原始对象的状态。反序列化操作可以用于对象恢复、分布式应用、远程调用等场景,使得对象可以从存储的字节流中还原其状态,或在不同的计算机之间进行传输后,接收方可以通过反序列化操作将字节序列转换为可操作的对象。
(6)源代码
源代码(也称源程序)是指未编译的按照一定的程序设计语言规范书写的文本文件,是一系列人类可读的计算机语言指令。在现代程序语言中,源代码最为常用的格式是文本文件,这种典型格式的目的是为了编译出计算机程序。计算机源代码的最终目的是将人类可读的文本翻译成为计算机可以执行的二进制指令,这种过程叫做编译,通过编译器完成。
(7)字节码
字节码是一种包含执行程序、由一序列op代码/数据对组成的二进制文件。相比于硬件能够直接执行的机器指令代码,字节码实际上是一种中间代码,即需要由软件代码进行解释执行的指令编码,而无法在硬件上直接执行。
(8)机器码
机器码通常是指机器指令,是计算机硬件(例如中央处理器(Central Processing Unit,CPU))能直接识别并执行的指令,它的表现形式是二进制编码。机器码通常由操作码和操作数两部分组成,操作码指出该机器码所要完成的操作,即机器码的功能;操作数指出参与运算的对象,以及运算结果所存放的位置等。
(9)虚拟机
本实施例中,虚拟机是编程语言中的一种重要工具(例如Java虚拟机),本质上是一种软件模块,能够为特定语言下的代码提供运行环境并实现代码的隔离运行。
此外,虚拟机实例是指在硬件设备(例如处理器)上运行的虚拟机,即虚拟机实例是指一个运行中的虚拟机。基于同一份虚拟机的软件代码,可以快速地创建多个相同配置的虚拟机实例。
(10)沙箱
在本申请中,沙箱是一种用于运行程序代码的隔离环境,能够提供程序代码运行所依赖的运行环境,且保证该运行环境与外部是隔离的,从而实现程序代码的隔离运行。
(11)动态链接库
动态链接库是在操作系统中实现共享函数库概念的一种实作方式。动态链接库是为了实现代码的重用而出现的,动态链接库实际上都是包括一些独立的文件,例如能被可执行程序调用来完成某些工作的函数。动态链接库通常都是不能直接运行的,只有在其他模块调用动态链接库中的函数时,才能发挥作用。
(12)堆内内存
虚拟机在执行程序代码的过程中会把它在主存中管理的内存划成多个区域,每个区域放不同类型的数据,其中占用空间最大的那部分则为堆内内存。其中,堆内内存中存放所有对象的实例,这一块区域在虚拟机启动时就被创建,被虚拟机内的所有线程共享,是垃圾收集器的主要工作区域。
(13)堆外内存(Off-heap memory)
堆外内存是指在虚拟机的堆内内存(on-heap memory)之外分配和使用的内存空间。堆外内存不受垃圾收集器(Garbage Collection,GC)管理,通常由应用程序的开发人员直接控制。堆外内存主要用于处理需要直接控制内存分配的场景。堆外内存的分配和释放通常通过手动编程实现,例如使用特定的应用程序编程接口(Application Programming Interface,API)来实现。
目前,在微服务架构下,服务是以进程的形式来运行的,因此两个服务之间的通信本质上就是两个进程之间的通信。并且,两个服务往往是需要支持跨服务器部署的,因此在两个服务跨服务器执行数据交互时,数据传输期间往往需要执行序列化、协议编解码以及反序列化等过程,导致服务之间的数据传输效率较低。
请参阅图1,图1为本申请提供的一种服务间实现数据传输的过程。如图1所示,服务A以进程A的形式运行,服务B以进程B的形式运行,且服务A与服务B之间需要执行数据传输。在数据传输过程中,进程A中的请求对象A对需要传输的请求数据执行序列化,得到序列化数据。然后,对序列化数据按照通信协议进行编码,得到编码后的数据,且将编码后的数据发送给进程B。进程B在获取到编码后的数据之后,对编码后的数据按照通信协议进行解码以及反序列化,从而使得请求对象B能够获得进程A传输的请求数据。
在进程B对进程A所传输的请求数据完成数据处理操作,并生成相应的响应数据后,进程B中的响应对象B对需要传输的响应数据执行序列化,得到序列化数据。然后,对序列化数据按照通信协议进行编码,得到编码后的数据,且将编码后的数据发送给进程A。进程A在获取到编码后的数据之后,对编码后的数据按照通信协议进行解码以及反序列化,从而使得响应对象B能够获得进程B传输的响应数据。
也就是说,在服务间进行数据传输的过程中,需要执行序列化、协议编解码以及反序列化等过程,导致服务之间的数据传输效率较低。
有鉴于此,本申请提供一种数据传输方法,提供某一服务的进程在运行时创建虚拟化环境,并且在虚拟化环境内运行提供目标服务的线程。由于提供目标服务的线程实际上是运行于进程对应的内存空间内,因此线程与进程可以视为一体,从而能够保证线程与进程都能够访问同一片内存空间的地址,进而基于同一片内存空间的地址执行数据读写来实现不同服务间的数据传输,且数据传输期间无需执行序列化、协议编解码以及反序列化等过程,有效地提高了数据传输效率。即,本方案的本质是将对等的两个进程之间的数据交互变换为进程与进程内的线程之间的数据交互,从而免去进程间繁琐的数据传输过程,提高数据传输效率。
此外,通过将提供目标服务的线程运行于虚拟化环境内,能够实现线程的隔离,保证线程的运行并不会影响到进程本身的运行(例如线程崩溃后不会导致进程本身也发生崩溃),从而保证不同服务间的独立运行。
请参阅图2,图2为本申请提供的一种系统架构的示意图。如图2所示,在系统架构中,执行设备101例如可以为物理主机或物理服务器等设备。并且,执行设备201与数据存储系统202通信连接,用于获取数据存储系统202中所存储的程序代码,以实现本申请提供的数据传输方法。其中,数据存储系统202例如可以是由部署于执行设备201上的存储设备实现,例如执行设备201为物理服务器,数据存储系统202为物理服务器上所部署的硬盘。数据存储系统202也可以是由独立于执行设备之外的存储设备实现,例如执行设备201为计算服务器,数据存储系统202则为专门存储程序代码的数据服务器。
执行设备201在工作期间,可以从数据存储系统202中获得程序代码,并且基于本申请实施例提供的数据传输方法在执行设备201上运行进程并实现进程内的数据传输。
请参阅图3,图3为本申请提供的一种数据传输方法的流程示意图。如图3所示,该数据传输方法包括以下的步骤301-303。
步骤301,第一进程中在运行过程中创建虚拟化环境以及在虚拟化环境中运行的目标线程,目标线程用于提供目标服务,目标线程运行于第一进程对应的内存空间内。
在本申请中,该数据传输方法例如可以是应用于微服务架构或其他服务架构下。第一进程可以是微服务架构下某一个服务的运行形式,即第一进程用于在微服务架构下提供某一种服务。
在第一进程的运行过程中,当第一进程需要获取由另一个服务(即目标服务)所提供的数据,第一进程可以调用动态链接库,从而实现在第一进程内运行目标服务。其中,第一进程所提供的服务与目标服务是不同的。此外,触发调用动态链接库的主体可以是第一进程中已运行的任意一个或多个线程。例如,当第一进程中的某一个线程需要获取目标服务所提供的数据时,该线程则可以是触发调用动态链接库。
具体地,动态链接库中包括虚拟化环境的代码和目标服务的代码,在调用动态链接库后,能够实现创建虚拟化环境并运行目标服务。并且,动态链接库是无法直接运行的,需要在进程调用时才能够实现在进程内运行。此外,动态链接库可以是由不同的进程所调用,从而实现在不同的进程运行并为不同的进程提供相应的服务。
在调用动态链接库后,第一进程可以基于动态链接库中所包括的虚拟化环境的代码来创建虚拟化环境,并且在虚拟化环境内运行目标服务的代码,从而实现在虚拟化环境中运行用于提供目标服务的目标线程。由于目标线程是第一进程调用动态链接库后创建并运行的,因此目标线程实际上是运行于第一进程对应的内存空间中(即操作系统分配给第一进程的内存空间),即运行中的目标线程是属于第一进程的线程。具体地,目标线程可以是包括一个或多个线程,即由目标线程所包括的一个或多个线程来提供目标服务。可选的,第一进程也可以是通过调用静态链接库来创建虚拟化环境和目标线程,本申请对此并不做具体限定。
在第一进程通过虚拟化环境运行目标线程之后,第一进程能够向目标线程传递相应的指令,从而使得目标线程能够基于第一进程所传递的指令来执行数据处理操作并得到对应的目标数据。其中,第一进程可以是通过函数调用的方式或者是消息通知的方式来向目标线程传递相应的指令。也就是说,目标线程是基于第一进程所发送的请求数据来执行数据处理操作,并将执行数据处理操作所得到的目标数据(即响应数据)写入于目标地址中,以便于第一进程从目标地址中获取到目标数据。
或者,第一进程可以向目标线程传递相应的指令,以指示目标线程从第一进程指定的目标地址中获取第一进程写入到目标地址中的目标数据。
在目标线程运行于虚拟化环境的情况下,目标线程实际上是隔离运行的,即目标线程的运行并不会影响到第一进程的正常运行。例如,在目标线程异常崩溃的情况下,并不会导致第一进程也发生异常崩溃。因此,第一进程和目标线程可以是独立地提供不同的服务,且保证第一进程所提供的服务并不会受到目标线程的影响,进而确保目标线程崩溃的情况下仍能够通过第一进程提供正常的服务,保证本方案不会因为在第一进程中引入目标线程而影响第一进程本身的正常运行。
可选的,上述的虚拟化环境可以包括虚拟机或沙箱。在本申请中,虚拟化环境一方面可以为目标线程提供隔离环境,以确保目标线程与第一进程之间的隔离运行;虚拟化环境另一方面则可以是为目标线程提供运行时环境,确保目标线程能够正常地运行,尤其是在第一进程的源代码与目标线程对应的源代码采用不同语言编写的情况下,基于虚拟化环境能够保证目标线程可以在第一进程内顺利执行。
步骤302,第一进程获取目标地址,目标地址为第一进程和目标线程均能够访问的内存地址。
在目标线程向第一进程传递数据的情况下,当目标线程完成将目标数据写入于内存空间的目标地址之后,第一进程可以获取写入目标数据的目标地址,以便于从目标地址中取出目标数据。
在第一进程向目标线程传递数据的情况下,第一进程也可以获取用于写入目标数据的目标地址,以便于向第一进程所生成的目标数据写入到目标地址中,以便于目标线程从目标地址中取出目标数据。
其中,第一进程获取目标地址的方式可以有多种。以下将以目标线程向第一进程传递数据的情况为例,介绍第一进程如何获取目标地址。
在一种可能的实现方式中,目标地址是目标线程申请的。
例如,目标线程在执行数据处理操作之前,可以提前通过调用操作系统的接口来申请一块用于写入目标数据的内存,从而得到操作系统在第一进程对应的内存空间内为目标线程所分配的目标地址。这样,目标线程在执行数据处理操作的过程中,目标线程可以持续地将执行数据处理操作所得到的数据写入至目标地址中,从而使得目标地址能够存储由完成数据处理操作所得到的目标数据。
又例如,在目标线程完成数据处理操作之后,目标线程向操作系统申请一块用于写入目标数据的内存,并且在操作系统向目标线程返回该目标地址之后,目标线程则将执行数据处理操作所得到的目标数据写入至该目标地址中。
在目标地址是目标线程申请的情况下,在目标线程完成目标数据的写入后,目标线程可以向第一进程传递目标地址,以指示目标线程写入目标数据的地址。即,第一进程通过接收目标线程发送的目标地址,来实现目标地址的获取。例如,目标线程可以是向第一进程发送通知消息,该通知消息中包括目标地址,该通知消息具体用于指示目标线程已完成目标数据的写入且目标数据是写入于目标地址中。又例如,在第一进程通过函数调用的方式向目标线程传递指令的情况下,目标线程则可以是在完成目标数据的写入后直接将目标地址返回给第一进程,从而使得第一进程获取到目标地址。
本方案中,由目标线程来申请用于写入目标数据的目标地址并在完成目标数据的写入后向第一进程返回目标地址,能够使得第一进程通过读取自身对应的内存空间中的数据即可获得目标线程所传递的数据,提高了数据传输效率。并且,由生成目标数据的目标线程来申请目标地址(即由数据生成者来申请写入数据的地址),能够实现按需申请地址,提高内存空间的利用率,且便于实现内存空间的管理。
在另一种可能的实现方式中,目标地址是第一进程申请的,且第一进程需要将申请到的目标地址传递给目标线程。
例如,第一进程在调用目标线程来执行数据处理操作之前,可以通过调用操作系统接口或其他的方式来申请用于存储目标线程生成数据的内存空间,从而申请得到该目标地址。那么,在第一进程调用目标线程来执行数据处理操作时,第一进程可以向目标线程传递该目标地址,以指示目标线程将生成的目标数据写入于目标地址中。这样一来,目标线程在执行数据处理操作的过程中,目标线程可以持续地将执行数据处理操作所得到的数据写入至目标地址中。在目标线程完成数据处理操作之后,第一进程可以接收目标线程发送的通知消息,通知消息用于指示目标线程完成目标数据的写入。基于该通知消息,第一进程获取预先向目标线程所传递的目标地址,从而确定从目标地址中获取目标线程所生成的目标数据。
又或者,在第一进程预先为目标线程申请得到目标地址的情况下,第一进程在调用目标线程执行数据处理操作时,并不向目标线程传递该目标地址。在目标线程在执行数据处理操作时,先基于一块缓存空间来存储持续生成的数据;在目标线程完成数据处理操作之后,目标线程再向第一进程返回已完成数据处理的反馈消息。这样,第一进程在确认目标线程完成数据处理后,将提前申请得到的目标地址传递给目标线程,以使得目标线程将缓存的目标数据拷贝至目标地址中。在目标线程完成将目标数据拷贝至目标地址之后,目标线程向第一进程发送通知消息,从而通知第一进程已完成在目标地址中写入目标数据。
本方案中,由第一进程来提前申请用于写入目标数据的目标地址并向目标线程传递目标地址,能够使得目标线程严格按照第一进程所提供的内存空间中的目标地址来写入数据,便于第一进程实现自身的内存空间的管理,且确保第一进程能够快速地获取目标线程所生成的目标数据,提高数据传输的效率。
类似地,在第一进程向目标线程传递数据的情况下,目标地址也可以是第一进程申请的,或者是目标线程申请的。
可选的,在虚拟化环境为虚拟机或沙箱的情况下,目标地址具体为虚拟化环境的堆外内存。具体来说,尽管第一进程通过调用动态链接库在第一进程内运行了目标线程之后,目标线程所使用的都是第一进程的内存,但由于目标线程跑在虚拟化环境上,因此目标线程在运行时使用的是堆内的虚拟内存地址。对于第一进程而言,第一进程并不认识目标线程运行时所使用的虚拟内存地址,如果第一进程要访问该虚拟内存地址往往还需要额外的繁琐操作。然而,虚拟化环境的堆外内存则是第一进程可以直接访问的,因此这里将目标数据写入在堆外内存,能够方便第一进程快速地获取到目标数据,提高数据传输的效率。
可选的,在不使用堆外内存来进行数据传输的情况下,还可以是采用内存映射技术,将虚拟化环境中的某块堆内内存和第一进程对应的实际内存地址建立映射关系。这样,目标线程可以将目标数据放入配置了映射关系的堆内内存中,从而使得第一进程通过在外部访问对应映射的实际内存地址来获取到目标数据。
此外,目标地址也可以是第一进程对应的内存空间之外的地址,即目标地址并不位于第一进程对应的内存空间内。例如,目标地址可以是由第一进程向操作系统所申请的一块在第一进程对应的内存空间之外的内存地址,专门用于实现第一进程与目标线程之间的数据传输。
步骤303,第一进程在目标地址中读取或写入目标数据。
其中,在第一进程是在目标地址中读取目标数据的情况下,目标数据是目标线程执行数据处理操作后写入到目标地址的数据;在第一进程是在目标地址中写入目标数据的情况下,目标数据为第一进程传递给目标线程的数据。
具体来说,在第一进程是在目标地址中读取目标数据的情况下,在获取到目标地址之后,第一进程则可以通过读取目标地址中的数据来获取目标线程存入目标地址的目标数据。由于第一进程与目标线程分别是用于提供不同的服务,因此第一进程从目标地址获取到目标线程所存入的目标数据之后,相当于是完成了两个服务之间的数据传输过程。并且,由于目标线程是通过调用动态链接库的形式嵌入到第一进程中来执行,因此第一进程可以通过直接访问自身已分配的内存来获得目标线程所生成的数据,避免了执行序列化、协议编解码以及反序列化等繁琐的数据传输过程,有效地提高了数据传输效率。
在第一进程是在目标地址中写入目标数据的情况下,第一进程可以往目标地址中写入需要传递给目标线程的目标数据。然后,第一进程可以向目标线程发送指令(比如通过函数调用的方式来发送指令),以指示目标线程从目标地址中读取第一进程所传输给目标线程的目标数据。这样,当目标线程基于第一进程所发送的目标地址,从目标地址中读取目标数据时,则完成了第一进程向目标线程传输数据的过程。
可选的,在第一进程从目标地址获取目标数据之后,第一进程可以删除目标线程。可以理解的是,由于在本申请中用于提供目标服务的目标线程是运行于第一进程中,因为目标线程所生成的数据主要是提供给第一进程,而不太可能会提供给其他的进程。因此,在第一进程获取到目标线程所生成的目标数据之后,目标线程已完成第一进程所指示的工作,第一进程暂时不再需要获取目标线程所生成的数据。这样,第一进程可以是将目标线程删除,从而腾出空闲的计算资源和内存资源,有助于节省设备的计算资源以及内存资源。
可选的,在第一进程删除目标线程后,第一进程可以是删除虚拟化环境,例如第一进程删除用于运行目标线程的虚拟机或沙箱。由于虚拟化环境主要是用于运行提供目标服务的目标线程,因此在删除目标线程之后,虚拟化环境也就没有实际用途了,进而可以将虚拟化环境也一并删除,从而腾出更多的计算资源和内存资源。
或者,在计算资源和内存资源充足的情况下,第一进程可以将虚拟化环境释放至资源池。其中,被释放至资源池的虚拟化环境中仅包括目标服务的代码。也就是说,虚拟化环境并没有被删除,而是仅仅删除原先在虚拟化环境中所运行的目标线程,且虚拟化环境中还保留有目标服务的代码,能够通过运行目标服务的代码来实现运行目标线程。在将虚拟化环境释放至资源池的情况下,如果第一进程后续需要继续获取目标线程所生成的数据,则可以是直接从资源池中获取虚拟化环境并在虚拟化环境中快速地启动目标线程,而不再需要执行调用动态链接库来创建虚拟化环境的过程,能够提高在第一进程内启动目标服务的效率。
以上介绍了第一进程通过调用动态链接库来运行提供目标服务的目标线程的过程,以下将介绍如何生成动态链接库的过程。
在生成动态链接库的过程中,可以是先对目标服务的源代码进行编译,得到字节码;或者,直接获取开发人员所提供的目标服务的字节码。然后,对目标服务的字节码和字节码运行时所依赖的库文件执行编译,得到机器码。最后,将编译得到的机器码与虚拟化环境的机器码进行编译链接,得到动态链接库。其中,虚拟化环境的机器码可以是由开发人员提供,也可以是对开发人员所提供的虚拟化环境的源代码进行编译后获得的。也就是说,在编译链接得到的动态链接库中实际上是包括目标服务的机器码、目标服务所依赖的库文件的机器码以及虚拟化环境的机器码。
在本方案中,由于机器码是能够直接被计算机硬件所识别且运行的,因此在第一进程调用动态链接库之后,能够通过直接运行动态链接库中的机器码来实现虚拟化环境的创建以及目标线程的启动,无需再执行字节码的编译过程,从而提高目标线程的启动性能。
当然,在一些可能的实施例中,在生成动态链接库时,也可以是将目标服务的字节码与虚拟化环境(比如虚拟机)的机器码编译链接在一起,从而使得虚拟机在运行时再对目标服务的字节码进行编译运行,进而实现启动目标线程。
可选的,目标服务的源代码与第一进程的源代码是基于不同的编程语言所编写的。由于第一进程所提供的服务与目标服务并不相同,且不同的服务在开发时往往可能会根据实际需求来采用相应的编程语言,因此目标服务的源代码与第一进程的源代码很有可能是基于不同的编程语言所编写的。例如,第一进程的源代码是基于C++语言所编写的,而目标服务的源代码则可以是基于Java语言或Python语言所编写的。
在目标服务的源代码与第一进程的源代码是基于不同的编程语言所编写的情况下,第一进程中往往难以直接嵌入运行目标服务,因此本申请中是通过调用动态链接库来先创建虚拟化环境,由虚拟化环境为目标服务提供运行时所依赖的环境后,再在虚拟化环境中运行目标服务的代码,从而实现启动并运行提供目标服务的目标线程,确保在了第一进程内运行基于其他编程语言所编写的线程。
以上介绍了本申请提供的一种数据传输方法,为了便于理解,以下将结合具体例子详细介绍该数据传输方法在微服务架构下的具体执行过程。
具体来说,在虚拟化、云计算高速发展的情况下,人工智能(Artificial Intelligence,AI)和大数据间的数据流动往往是跨服务的。当数据在不同服务间传输时,数据发送端往往需要对数据执行序列化、编码和传输,数据接收端则需要对接收到的数据执行解码和反序列化,从而带来较长的时间开销,导致数据传输的效率较低。在性能敏感的场景下,服务间较低的数据传输效率会带来不好的用户体验。基于此,针对服务间传输效率低的问题,本申请提供一种数据传输方法,以提高服务间数据传输的效率。
示例性地,请参阅图4,图4为相关技术中的一种服务间执行数据传输的示意图。如图4所示,在AI、大数据或数据库等场景下,大数据分析服务以进程A的形式运行,数据读写服务以进程B的形式运行,且进程A需要通过进程B来读写数据库内的数据。其中,进程A和进程B为独立部署,进程A用于提供大数据分析服务,进程B则用于完成数据的落盘和读取。进程A与进程B之间可以通过远程过程调用(Remote Procedure Call,RPC)来进行通信,从而使得进程A能够通过进程B对数据库执行数据读写。
示例性地,请参阅图5,图5为本申请提供的一种数据传输方案与相关技术的对比示意图。如图5所示,相关技术中实际上是将两个不同服务分别以独立的进程来运行,且基于进程间通信的方式来实现服务间的数据传输。在本申请提供的数据传输方案中,是将数据读写服务的代码与虚拟机或沙箱的代码编译链接为动态链接库,且以进程A的形式运行大数据分析服务,从而使得进程A能够在运行过程中通过调用动态链接库在进程A中以线程的方式运行数据读写服务,进而将两个服务间的数据传输转换为进程内的内存访问操作。
具体地,请参阅图6,图6为本申请提供的一种编译动态链接库的流程示意图。如图6所示,在本申请中,Hudi具体为一个大数据的组件,能够用于提供数据的读写服务。针对于采用Java语言所编写的Hudi源代码,可以先使用Java编译器将Hudi源代码编译成Java Class文件,也就是Java字节码。可选的,在已经获得开发人员提供的Hudi字节码的情况下,也可以是不再需要执行执行源代码的编译过程,而是直接对Hudi字节码执行后续的编译流程。
然后,使用编译器(例如本机镜像生成器(GraalVM Native Image Generator))将Java字节码和其依赖的库文件(Libraries)编译成机器码。即,对Hudi字节码执行提前编译(Ahead Of Time,AOT),从而实现将Hudi字节码编译为机器码。
在得到Hudi的机器码之后,将机器码与虚拟机代码(例如Substate VM的代码)以及Java开发工具包(Java Development ToolKit,JDK)进行编译链接,生成动态链接库Hudi.so。其中,虚拟机代码可以包括虚拟机Substate VM的代码以及Hudi运行时所依赖的组件和库等执行环境的代码。Java开发工具包则包括Java运行环境、Java工具以及Java基础类库等内容。
最终,进程A在运行时通过调用动态链接库,实现在进程A内部创建虚拟机并在虚拟机内运行Hudi线程。也就是说,Hudi组件实际上是被编译为动态链接库Hudi.so嵌入到进程中,从而实现将相关技术中进程A与Hudi进程之间的通信转换为进程A与动态链接库Hudi.so之间的通信。
请参阅图7,图7为本申请提供的一种进程A调用动态链接库的流程示意图。如图7所示,在编译得到动态链接库之后,可以由运行中的进程A来调用动态链接库Hudi.so,从而使得进程A能够完成一次Hudi所提供的数据表读取服务。具体地,进程A调用动态链接库的过程具体可以包括以下的步骤701-706。
步骤701,进程A调用动态链接库Hudi.so。
在进程A的运行过程中,当进程A需要对数据库中的数据进行读写操作时,进程A可以调用动态链接库Hudi.so。
步骤702,进程A基于动态链接库Hudi.so创建虚拟机。
由于动态链接库Hudi.so包括有虚拟机的代码,因此进程A可以通过运行虚拟机的代码来创建虚拟机。在本申请中,进程A所创建的虚拟机为一个轻量级虚拟机,例如为Substrate VM。其中,轻量级虚拟机启动迅速,具有一定的隔离度,同时带有目标必要的运行时环境,但一般不带有操作系统。
步骤703,进程A在虚拟机内初始化Hudi引擎。
基于Hudi的机器码,进程A可以在虚拟机内初始化Hudi引擎。其中,该Hudi引擎是以线程的形式运行于进程A内。即,Hudi引擎相当于上述实施例中的目标线程,进程A相当于上述实施例中的第一进程。
需要说明的是,在相关技术中,Hudi引擎是Java原生的,运行在Java虚拟机上,启动步骤比较多(例如包括加载Java虚拟机可执行文件、从文件系统加载类、验证Hudi字节码、解释Hudi字节码、运行静态初始化器、编译Hudi字节码以及运行编译得到的机器码)。因此,相关技术中Hudi引擎的启动耗时往往是秒级的(实测1440ms)。在本申请中,动态链接库Hudi.so是经过AOT编译后得到的,因此在启动Hudi实例时,只需要加载可执行文件,立刻就能启动优化后的机器码,大大缩减了启动时间(实测78ms),确保了服务响应的效率。
此外,除了启动时间的优化,本申请实施还可以做到对Hudi所使用内存的精细管理。在Java原生方案中,每个Hudi实例共享所在Java虚拟机进程的内存,无法精细化管理。例如,假设给Java虚拟机分配了32G内存,那么无论多少个Hudi实例,都只能共享这32G内存,从而导致在Hudi实例较多的场景,容易出现内存溢出而导致Hudi无法正常工作。基于经过AOT编译后的动态链接库Hudi.so所启动的Hudi实例,每个Hudi实例都运行在独立的虚拟机上,且每个虚拟机独立分配内存,从而对Hudi实例的内存使用执行精细化的管理。
步骤704,进程A调用Hudi引擎执行读写操作。
在Hudi引擎完成初始化操作后,进程A可以通过函数调用或者是消息通知的方式来调用Hudi引擎执行读写操作。这样,Hudi引擎能够基于进程A的指示,对数据库执行相应的数据读写操作。
步骤705,在完成读写操作后,进程A关闭Hudi引擎。
在完成读写操作后,进程A先释放Hudi引擎所申请的资源(比如堆外内存),然后关闭Hudi引擎,从而释放所有与Hudi引擎相关的资源。
步骤706,进程A销毁虚拟机或释放虚拟机至资源池。
在关闭Hudi引擎后,进程A可以销毁虚拟机,从而释放虚拟机相关的所有资源。或者,进程A可以释放虚拟机至资源池中,以便于后续在需要调用Hudi引擎时,能够申请资源池中的虚拟机并在虚拟机中快速启动Hudi引擎,而不再需要重新调用动态链接库Hudi.so。
示例性地,请参阅图8,图8为本申请提供的一种销毁虚拟机的示意图。如图8所示,在调用动态链接库Hudi.so之后,进程A可以创建一个或多个虚拟机(比如图8中的虚拟机1和虚拟机2),且不同的虚拟机中可以是运行不同的Hudi实例。在任意一个虚拟机中,包括有用于存储Hudi镜像(即Hudi的机器码)的堆内存,用于运行Hudi镜像的运行时堆内存,以及预留内存空间。在销毁一个虚拟机(例如图8中的虚拟机2)之后,虚拟机中所占据了所有内存均被释放,且虚拟机本身也被删除。
请参阅图9,图9为本申请提供的一种释放虚拟机至资源池的示意图。如图9所示,在将进程A中已创建的虚拟机2释放至资源池时,虚拟机2仍会占据一定的内存(即Hudi镜像堆内存),以保存Hudi镜像。这样一来,在进程A还需要调用Hudi引擎来执行数据读写操作时,可以在资源池中申请一个空间的虚拟机,并基于虚拟机中所保留的Hudi镜像快速地启动Hudi引擎,从而避免执行重新创建虚拟机的过程。
可以参阅图10A,图10A为本申请提供的一种进程A调用Hudi引擎执行读取操作的流程意图。如图10A所示,上述的步骤704具体可以包括以下的步骤7041-7044。
步骤7041,进程A向Hudi引擎发送数据读取请求。
在进程A调用Hudi引擎时,可以向Hudi引擎发送数据读取请求,以请求Hudi引擎读取数据库中的某一个数据表中的数据(即上述实施例所介绍的目标数据)。
步骤7042,Hudi引擎申请堆外内存,并将从数据库读取到的数据写入至堆外内存。
在获取到数据读取请求后,Hudi引擎先通过调用操作系统接口来申请堆外内存。其中,由于Hudi引擎是嵌入到进程A中的,因此Hudi引擎所申请到的堆外内存同样为进程A的内存。基于申请到的堆外内存,Hudi引擎从数据库读取相应的数据,并将读取到的数据写入至堆外内存中。
示例性地,请参阅图11,图11为本申请提供的一种在虚拟机内运行Hudi引擎的示意图。如图11所示,在分配给虚拟机的内存之外,Hudi引擎还申请了堆外内存,该堆外内存位于虚拟机所管理的内存之外,但还是位于操作系统分配给进程A的内存空间内。
步骤7043,Hudi引擎向进程A返回堆外内存的地址。
在Hudi引擎完成数据的读取后,Hudi引擎可以向进程A返回堆外内存的地址(即上述实施例所介绍的目标地址),以便于进程A基于堆外内存的地址来获取数据。
步骤7044,进程A读取堆外内存中的数据。
在获取到堆外内存的地址后,由于堆外内存属于进程A所对应的内存空间,因此进程A可以基于堆外内存的地址直接读取堆外内存中的数据。
需要说明的是,图10A对应的实施例所介绍的是在进程A通过Hudi引擎来读取数据库的数据时,由Hudi引擎来申请堆外内存并向进程A返回堆外内存的地址。在一些可能的实施例中,也可以是由进程A来申请堆外内存并向Hudi引擎返回堆外内存的地址。
示例性地,请参阅图10B,图10B为本申请提供的一种进程A调用Hudi引擎执行读取操作的另一流程意图。如图10B所示,图10B所示的实施例与图10A所示的实施例之间的区别是:进程A先向操作系统申请内存地址,然后向Hudi引擎发送数据读取请求并将申请到的内存地址携带在数据读取请求中;这样,Hudi引擎能够基于数据读取请求中所携带的内存地址,将从数据库读取到的数据写入至内存地址中。最后,Hudi引擎向进程A返回通知消息,以指示Hudi引擎已经将数据写入到堆外内存,从而触发进程A读取内存地址中的数据。
可以参阅图12A,图12A为本申请提供的一种进程A调用Hudi引擎执行写入操作的流程意图。如图12A所示,上述的步骤704具体可以包括以下的步骤7045-7048。
步骤7045,进程A申请内存地址。
在进程A需要通过Hudi引擎往数据库写入数据时,进程A可以是先通过调用操作系统接口来申请内存地址,以便于将写入至数据库的数据写入至内存地址中来传递给Hudi引擎。
步骤7046,进程A将需要写入到数据库的数据写入至所申请的内存地址。
在申请得到内存地址之后,进程A将需要写入到数据库的数据写入至所申请的内存地址(即上述的目标地址)中。
步骤7047,进程A向Hudi引擎发送数据写入请求,并在数据写入请求中携带所申请的内存地址。
在完成将数据写入至内存地址之后,进程A则可以向Hudi引擎发送数据写入请求,并在数据写入请求中携带所申请的内存地址,以指示Hudi引擎将内存地址中的数据写入到数据库中。
步骤7048,Hudi引擎读取内存地址中的数据,并将读取到的数据写入至数据库中。
在接收到数据写入请求后,Hudi引擎可以基于数据写入请求中所携带的内存地址,读取该内存地址中的数据,并将读取到的数据写入至数据库中,从而完成数据写入操作。
需要说明的是,图12A对应的实施例所介绍的是在进程A通过Hudi引擎来往数据库写入数据时,由进程A来申请内存地址并向Hudi引擎返回内存地址。在一些可能的实施例中,也可以是由Hudi引擎来申请内存地址并向进程A返回所申请的内存地址。
示例性地,请参阅图12B,图12B为本申请提供的一种进程A调用Hudi引擎执行写入操作的另一流程意图。如图12B所示,图12B所示的实施例与图12A所示的实施例之间的区别是:进程A向Hudi引擎发送数据写入请求;然后,Hudi引擎申请堆外内存并将所申请到的堆外内存的地址返回给进程A。这样,进程A可以将需要写入到数据库的数据写入至Hudi引擎所申请的堆外内存中,并向Hudi引擎发送通知消息,以指示进程A已经完成往堆外内存中写入数据。最后,Hudi引擎可以读取堆外内存中的数据,并将读取到的数据写入至数据库中。
在本申请中,使用轻量级虚拟机将某个服务嵌入到另一个服务对应的进程中,本质上是避免了数据在不同系统中的传递,因此在大数据、AI、数据库等领域有广泛的使用场景。除此以外,在近数据计算场景下也可以实现数据间的高效传递。例如,假设在近数据计算场景下,存储服务器上的数据需要传输到某个计算服务器上去运算,此时可以采用本申请所提供的方案,在存储服务器上直接启动一个轻量级虚拟机,将计算服务器上对应的计算服务部署在轻量级虚拟机上来完成对应的计算,从而避免数据在两个系统间的流动,节省了数据传输的时间。需要说明的是,在上述的例子中,是采用本申请的方案来缩短服务器间的数据传输时间,本申请的方案在芯片间或者其他器件间也同样可以应用。
以上详细介绍了本申请提供的方法,接下来将介绍本申请提供的用于执行上述方法的设备。
请参阅图13,图13为本申请提供的一种数据传输装置的结构示意图。如图13所示,该数据传输装置,包括:处理模块1301,用于使得第一进程中在运行过程中创建虚拟化环境以及在虚拟化环境中运行的目标线程,目标线程用于提供目标服务,目标线程运行于第一进程对应的内存空间内;获取模块1302,用于使得第一进程获取目标地址,目标地址为第一进程和目标线程均能够访问的内存地址;处理模块1301,还用于使得第一进程在目标地址中读取或写入目标数据;其中,在第一进程是在目标地址中读取目标数据的情况下,目标数据是目标线程执行数据处理操作后写入到目标地址的数据;在第一进程是在目标地址中写入目标数据的情况下,目标数据为第一进程传递给目标线程的数据。
在一种可能的实现方式中,虚拟化环境包括虚拟机或沙箱,目标地址为虚拟化环境的堆外内存,堆外内存位于第一进程对应的内存空间内。
在一种可能的实现方式中,处理模块1301,还用于:对目标服务的字节码和字节码运行时所依赖的库文件执行编译,得到机器码;将机器码与虚拟化环境的机器码进行编译链接,得到动态链接库。
在一种可能的实现方式中,在第一进程从目标地址获取目标数据之后,处理模块1301,还用于使得第一进程删除目标线程。
在一种可能的实现方式中,在第一进程删除目标线程后,处理模块1301,还用于使得:第一进程删除虚拟化环境;或者,第一进程将虚拟化环境释放至资源池,其中被释放至资源池的虚拟化环境中仅包括目标服务的代码。
在一种可能的实现方式中,目标地址是目标线程申请的,获取模块1302,还用于使得:
在目标线程完成目标数据的写入后,第一进程接收目标线程发送的目标地址。
在一种可能的实现方式中,目标地址是第一进程申请的,获取模块1302,还用于使得第一进程接收目标线程发送的通知消息,通知消息用于指示目标线程完成目标数据的写入;第一进程获取预先向目标线程所传递的目标地址。
在一种可能的实现方式中,目标服务的源代码与第一进程的源代码是基于不同的编程语言所编写的。
在一种可能的实现方式中,第一进程用于提供与目标服务不同的服务。
在一种可能的实现方式中,第一进程可以是通过调用动态链接库来创建虚拟化环境和目标线程,动态链接库包括虚拟化环境的代码和目标线程的代码。
其中,获取模块1302或处理模块1301均可以通过软件实现,或者可以通过硬件实现。示例性的,接下来以处理模块1301为例,介绍处理模块1301的实现方式。类似的,获取模块1302的实现方式可以参考处理模块1301的实现方式。
模块作为软件功能单元的一种举例,处理模块1301可以包括运行在计算实例上的代码。其中,计算实例可以包括物理主机(计算设备)、虚拟机、容器中的至少一种。进一步地,上述计算实例可以是一台或者多台。例如,A模块可以包括运行在多个主机/虚拟机/容器上的代码。需要说明的是,用于运行该代码的多个主机/虚拟机/容器可以分布在相同的区域(region)中,也可以分布在不同的region中。进一步地,用于运行该代码的多个主机/虚拟机/容器可以分布在相同的可用区(availability zone,AZ)中,也可以分布在不同的AZ中,每个AZ包括一个数据中心或多个地理位置相近的数据中心。其中,通常一个region可以包括多个AZ。
同样,用于运行该代码的多个主机/虚拟机/容器可以分布在同一个虚拟私有云(virtual private cloud,VPC)中,也可以分布在多个VPC中。其中,通常一个VPC设置在一个region内,同一region内两个VPC之间,以及不同region的VPC之间跨区通信需在每个VPC内设置通信网关,经通信网关实现VPC之间的互连。
模块作为硬件功能单元的一种举例,处理模块1301可以包括至少一个计算设备,如服务器等。或者,处理模块1301也可以是利用中央处理单元(central processing unit,CPU)实现,也可以利用专用集成电路(application-specific integrated circuit,ASIC)实现、或可编程逻辑器件(programmable logic device,PLD)实现的设备等。其中,上述PLD可以是复杂程序逻辑器件(complex programmable logical device,CPLD)、现场可编程门阵列(field-programmable gate array,FPGA)、通用阵列逻辑(generic array logic,GAL)、数据处理单元(data processing unit,DPU)、神经网络处理单元(Neural Network Processing Unit,NPU)、片上系统(system on chip,SoC)、卸载卡、加速卡或其任意组合实现。
处理模块1301包括的多个计算设备可以分布在相同的region中,也可以分布在不同的region中。处理模块1301包括的多个计算设备可以分布在相同的AZ中,也可以分布在不同的AZ中。同样,处理模块1301包括的多个计算设备可以分布在同一个VPC中,也可以分布在多个VPC中。其中,多个计算设备可以是服务器、ASIC、PLD、CPLD、FPGA、GAL、DPU、NPU、SoC、卸载卡、加速卡等计算设备的任意组合。
请参阅图14,图14为本申请提供的一种计算设备的结构示意图。图14所示的计算设备1400可以用于执行本实施例提供的数据传输方法。如图14所示,计算设备1400包括:总线1402、处理器1404、存储器1406和通信接口1408。处理器1404、存储器1406和通信接口1408之间通过总线1402通信。计算设备1400可以是服务器或终端设备。应理解,本申请不限定计算设备1400中的处理器、存储器的个数。
总线1402可以是外设部件互连标准(peripheral component interconnect,PCI)总线或扩展工业标准结构(extended industry standard architecture,EISA)总线等。总线可以分为地址总线、数据总线、控制总线等。为便于表示,图14中仅用一条线表示,但并不表示仅有一根总线或一种类型的总线。总线1402可包括在计算设备1400各个部件(例如,存储器1406、处理器1404、通信接口1408)之间传送信息的通路。
处理器1404可以包括中央处理器(central processing unit,CPU)、图形处理器(graphics processing unit,GPU)、微处理器(micro processor,MP)或者数字信号处理器(digital signal processor,DSP)等处理器中的任意一种或多种。
存储器1406可以包括易失性存储器(volatile memory),例如随机存取存储器(random access memory,RAM)。处理器1404还可以包括非易失性存储器(non-volatile memory),例如只读存储器(read-only memory,ROM),快闪存储器,机械硬盘(hard disk drive,HDD)或固态硬盘(solid state drive,SSD)。
存储器1406中存储有可执行的程序代码,处理器1404执行该可执行的程序代码以分别实现前述获取模块和处理模块的功能,从而实现上述的模型处理方法。也即,存储器1406上存有用于执行模型处理方法的指令。
通信接口1408使用例如但不限于网络接口卡、收发器一类的收发模块,来实现计算设备1400与其他设备或通信网络之间的通信。
应理解,根据本申请的计算设备1400用于执行如图3至图12B的数据传输方法,并可以对应于执行根据本申请的方法中的相应主体,为了简洁,在此不再赘述。
本申请还提供了一种计算设备集群。该计算设备集群包括至少一台计算设备。该计算设备可以是服务器,例如是中心服务器、边缘服务器,或者是本地数据中心中的本地服务器。在一些实施例中,计算设备也可以是台式机、笔记本电脑或者智能手机等终端设备。
请参阅图15,图15为本申请提供的一种计算设备集群的结构示意图。如图15所示,计算设备集群包括至少一个计算设备1400。计算设备集群中的一个或多个计算设备1400中的存储器1406中可以存有相同的用于执行数据传输方法的指令。
在一些可能的实现方式中,该计算设备集群中的一个或多个计算设备1400的存储器1406中也可以分别存有用于执行数据传输方法的部分指令。换言之,一个或多个计算设备1400的组合可以共同执行用于执行数据传输方法的指令。
需要说明的是,计算设备集群中的不同的计算设备1400中的存储器1406可以存储不同的指令,分别用于执行数据处理装置的部分功能。也即,不同的计算设备1400中的存储器1406存储的指令可以实现上述的获取模块和处理模块中的一个或多个模块的功能。
在一些可能的实现方式中,计算设备集群中的一个或多个计算设备可以通过网络连接。其中,网络可以是广域网或局域网等等。图16示出了一种可能的实现方式。图16为本申请提供的另一种计算设备集群的结构示意图。如图16所示,在计算设备集群1600中,两个计算设备1400A和1400B之间通过网络进行连接。具体地,通过各个计算设备中的通信接口与网络进行连接。在这一类可能的实现方式中,计算设备1400A中的存储器1406中存有执行获取模块的功能的指令。同时,计算设备1400B中的存储器1406中存有执行处理模块的功能的指令。
应理解,图16中示出的计算设备1400A的功能也可以由多个计算设备1400完成。同样,计算设备1400B的功能也可以由多个计算设备1400完成。
应理解,本申请中的计算设备1400或计算设备集群1600可对应于本申请图13中的数据传输装置,并可以对应于执行本申请图3中数据传输方法的相应主体。并且,计算设备1400或计算设备集群1600中的各个模块的上述和其它操作和/或功能分别为了实现图3中数据传输方法的相应流程,为了简洁,在此不再赘述。
可以参阅图17,图17为本申请提供的一种计算机可读存储介质的结构示意图。本申请还提供了一种计算机可读存储介质,在一些实施例中,上述图3所公开的方法可以实施为以机器可读格式被编码在计算机可读存储介质上或者被编码在其它非瞬时性介质或者制品上的计算机程序指令。
图17示意性地示出根据这里展示的至少一些实施例而布置的示例计算机可读存储介质的概念性局部视图,示例计算机可读存储介质包括用于在计算设备上执行计算机进程的计算机程序。在一个实施例中,计算机可读存储介质1700是使用信号承载介质1701来提供的。信号承载介质1701可以包括一个或多个程序指令1702,其当被一个或多个处理器运行时可以提供以上针对图3描述的功能或者部分功能。
在一些示例中,信号承载介质1701可以包含计算机可读介质1703,诸如但不限于,硬盘驱动器、紧密盘(CD)、数字视频光盘(DVD)、数字磁带、存储器、ROM或RAM等等。
在一些实施方式中,信号承载介质1701可以包含计算机可记录介质1704,诸如但不限于,存储器、读/写(R/W)CD、R/W DVD、等等。在一些实施方式中,信号承载介质1701可以包含通信介质1705,诸如但不限于,数字和/或模拟通信介质(例如,光纤电缆、波导、有线通信链路、无线通信链路、等等)。因此,例如,信号承载介质1701可以由无线形式的通信介质1705(例如,遵守IEEE 1602.X标准或者其它传输协议的无线通信介质)来传达。
一个或多个程序指令1702可以是,例如,计算机可执行指令或者逻辑实施指令。在一些示例中,计算设备的计算设备可以被配置为,响应于通过计算机可读介质1703、计算机可记录介质1704、和/或通信介质1705中的一个或多个传达到计算设备的程序指令1702,提供各种操作、功能、或者动作。
应理解,本申请中的计算机可读存储介质1700可以是部署于图13所介绍的数据传输装置,或者本申请的计算设备1400或计算设备集群1600上。这样,本申请提供的数据传输装置、计算设备1400或计算设备集群1600通过读取计算机可读存储介质1700上的一个或多个程序指令1702,来实现图3所介绍的数据传输方法。
另外需说明的是,以上所描述的装置实施例仅仅是示意性的,其中作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部模块来实现本实施例方案的目的。另外,本申请提供的装置实施例附图中,模块之间的连接关系表示它们之间具有通信连接,具体可以实现为一条或多条通信总线或信号线。
通过以上的实施方式的描述,所属领域的技术人员可以清楚地了解到本申请可借助软件加必需的通用硬件的方式来实现,当然也可以通过专用硬件包括专用集成电路、专用CPU、专用存储器、专用元器件等来实现。一般情况下,凡由计算机程序完成的功能都可以很容易地用相应的硬件来实现,而且,用来实现同一功能的具体硬件结构也可以是多种多样的,例如模拟电路、数字电路或专用电路等。但是,对本申请而言更多情况下软件程序实现是更佳的实施方式。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在可读取的存储介质中,如计算机的软盘、U盘、移动硬盘、ROM、RAM、磁碟或者光盘等,包括若干指令用以使得一台计算机设备(可以是个人计算机,训练设备,或者网络设备等)执行本申请各个实施例的方法。
在上述实施例中,可以全部或部分地通过软件、硬件、固件或者其任意组合来实现。当使用软件实现时,可以全部或部分地以计算机程序产品的形式实现。
计算机程序产品包括一个或多个计算机指令。在计算机上加载和执行计算机程序指令时,全部或部分地产生按照本申请的流程或功能。计算机可以是通用计算机、专用计算机、计算机网络、或者其他可编程装置。计算机指令可以存储在计算机可读存储介质中,或者从一个计算机可读存储介质向另一计算机可读存储介质传输,例如,计算机指令可以从一个网站站点、计算机、训练设备或数据中心通过有线(例如同轴电缆、光纤、数字用户线)或无线(例如红外、无线、微波等)方式向另一个网站站点、计算机、训练设备或数据中心进行传输。计算机可读存储介质可以是计算机能够存储的任何可用介质或者是包含一个或多个可用介质集成的训练设备、数据中心等数据存储设备。可用介质可以是磁性介质,(例如,软盘、硬盘、磁带)、光介质(例如,DVD)、或者半导体介质(例如固态硬盘(Solid State Disk,SSD))等。
以上,仅为本发明本申请的具体实施方式。熟悉本技术领域的技术人员根据本发明本申请提供的具体实施方式,可想到变化或替换,都应涵盖在本发明本申请的保护范围之内。
Claims (23)
- 一种数据传输方法,其特征在于,包括:第一进程在运行过程中创建虚拟化环境以及在所述虚拟化环境中运行的目标线程,所述目标线程用于提供目标服务,所述目标线程运行于所述第一进程对应的内存空间内;所述第一进程获取目标地址,所述目标地址为所述第一进程和所述目标线程均能够访问的内存地址;所述第一进程在所述目标地址中读取或写入目标数据;其中,在所述第一进程是在所述目标地址中读取所述目标数据的情况下,所述目标数据是所述目标线程执行数据处理操作后写入到所述目标地址的数据;在所述第一进程是在所述目标地址中写入所述目标数据的情况下,所述目标数据为所述第一进程传递给所述目标线程的数据。
- 根据权利要求1所述的方法,其特征在于,所述虚拟化环境包括虚拟机或沙箱,所述目标地址为所述虚拟化环境的堆外内存,所述堆外内存位于第一进程对应的内存空间内。
- 根据权利要求1或2所述的方法,其特征在于,所述方法还包括:对所述目标服务的字节码和所述字节码运行时所依赖的库文件执行编译,得到机器码;将所述机器码与所述虚拟化环境的机器码进行链接,得到所述动态链接库。
- 根据权利要求1-3任意一项所述的方法,其特征在于,在所述第一进程从所述目标地址获取所述目标数据之后,所述方法还包括:所述第一进程删除所述目标线程。
- 根据权利要求4所述的方法,其特征在于,在所述第一进程删除所述目标线程后,所述方法还包括:所述第一进程删除所述虚拟化环境;或者,所述第一进程将所述虚拟化环境释放至资源池,其中被释放至所述资源池的所述虚拟化环境中仅包括所述目标服务的代码。
- 根据权利要求1-5任意一项所述的方法,其特征在于,所述目标地址是所述目标线程申请的,所述第一进程获取所述目标地址,包括:在所述目标线程完成所述目标数据的写入后,所述第一进程接收所述目标线程发送的所述目标地址。
- 根据权利要求1-5任意一项所述的方法,其特征在于,所述目标地址是所述第一进程申请的,所述第一进程获取所述目标地址,包括:所述第一进程接收所述目标线程发送的通知消息,所述通知消息用于指示所述目标线程完成所述目标数据的写入;所述第一进程获取预先向所述目标线程所传递的所述目标地址。
- 根据权利要求1-7任意一项所述的方法,其特征在于,所述目标服务的源代码与所述第一进程的源代码是基于不同的编程语言所编写的。
- 根据权利要求1-8任意一项所述的方法,其特征在于,所述第一进程用于提供与所述目标服务不同的服务。
- 根据权利要求1-9任意一项所述的方法,其特征在于,所述第一进程是通过调用动态链接库来创建所述虚拟化环境以及所述目标线程,所述动态链接库包括所述虚拟化环境的代码和所述目标线程的代码。
- 一种数据传输装置,其特征在于,包括:处理模块,用于使得第一进程在运行过程中创建虚拟化环境以及在所述虚拟化环境中运行的目标线程,所述目标线程用于提供目标服务,所述目标线程运行于所述第一进程对应的内存空间内;获取模块,用于使得所述第一进程获取目标地址,所述目标地址为所述第一进程和所述目标线程均能够访问的内存地址;所述处理模块,还用于使得所述第一进程在所述目标地址中读取或写入目标数据;其中,在所述第一进程是在所述目标地址中读取所述目标数据的情况下,所述目标数据是所述目标线程执行数据处理操作后写入到所述目标地址的数据;在所述第一进程是在所述目标地址中写入所述目标数据的情况下,所述目标数据为所述第一进程传递给所述目标线程的数据。
- 根据权利要求11所述的装置,其特征在于,所述虚拟化环境包括虚拟机或沙箱,所述目标地址为所述虚拟化环境的堆外内存,所述堆外内存位于第一进程对应的内存空间内。
- 根据权利要求11或12所述的装置,其特征在于,所述处理模块,还用于:对所述目标服务的字节码和所述字节码运行时所依赖的库文件执行编译,得到机器码;将所述机器码与所述虚拟化环境的机器码进行链接,得到所述动态链接库。
- 根据权利要求11-13任意一项所述的装置,其特征在于,在所述第一进程从所述目标地址获取所述目标数据之后,所述处理模块,还用于使得所述第一进程删除所述目标线程。
- 根据权利要求14所述的装置,其特征在于,在所述第一进程删除所述目标线程后,所述处理模块,还用于使得:所述第一进程删除所述虚拟化环境;或者,所述第一进程将所述虚拟化环境释放至资源池,其中被释放至所述资源池的所述虚拟化环境中仅包括所述目标服务的代码。
- 根据权利要求11-15任意一项所述的装置,其特征在于,所述目标地址是所述目标线程申请的,所述获取模块,还用于使得:在所述目标线程完成所述目标数据的写入后,所述第一进程接收所述目标线程发送的所述目标地址。
- 根据权利要求11-15任意一项所述的装置,其特征在于,所述目标地址是所述第一进程申请的,所述获取模块,还用于使得:所述第一进程接收所述目标线程发送的通知消息,所述通知消息用于指示所述目标线程完成所述目标数据的写入;所述第一进程获取预先向所述目标线程所传递的所述目标地址。
- 根据权利要求11-17任意一项所述的装置,其特征在于,所述目标服务的源代码与所述第一进程的源代码是基于不同的编程语言所编写的。
- 根据权利要求11-18任意一项所述的装置,其特征在于,所述第一进程用于提供与所述目标服务不同的服务。
- 根据权利要求11-19任意一项所述的装置,其特征在于,所述第一进程是通过调用动态链接库来创建所述虚拟化环境以及所述目标线程,所述动态链接库包括所述虚拟化环境的代码和所述目标线程的代码。
- 一种数据传输装置,其特征在于,包括存储器和处理器;所述存储器存储有代码,所述处理器被配置为执行所述代码,当所述代码被执行时,所述装置执行如权利要求1至10任一项所述的方法。
- 一种计算机存储介质,其特征在于,所述计算机存储介质存储有指令,所述指令在由计算机执行时使得所述计算机实施权利要求1至10任意一项所述的方法。
- 一种计算机程序产品,其特征在于,所述计算机程序产品存储有指令,所述指令在由计算机执行时使得所述计算机实施权利要求1至10任意一项所述的方法。
Applications Claiming Priority (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202410895764.5A CN121277722A (zh) | 2024-07-04 | 2024-07-04 | 一种数据传输方法及相关装置 |
| CN202410895764.5 | 2024-07-04 |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2026007397A1 true WO2026007397A1 (zh) | 2026-01-08 |
Family
ID=98226551
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/CN2025/075468 Pending WO2026007397A1 (zh) | 2024-07-04 | 2025-01-27 | 一种数据传输方法及相关装置 |
Country Status (2)
| Country | Link |
|---|---|
| CN (1) | CN121277722A (zh) |
| WO (1) | WO2026007397A1 (zh) |
Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20110061062A1 (en) * | 2009-07-29 | 2011-03-10 | Echostar Technologies L.L.C. | Communication among execution threads of at least one electronic device |
| CN104216768A (zh) * | 2014-09-22 | 2014-12-17 | 北京金山安全软件有限公司 | 一种数据处理方法及装置 |
| CN116832431A (zh) * | 2022-03-23 | 2023-10-03 | 深圳市腾讯网络信息技术有限公司 | 在后台服务器上并发执行多个线程的方法 |
| CN117389755A (zh) * | 2023-09-06 | 2024-01-12 | 北京恺望数据科技有限公司 | 一种多线程共享内存方法及装置 |
-
2024
- 2024-07-04 CN CN202410895764.5A patent/CN121277722A/zh active Pending
-
2025
- 2025-01-27 WO PCT/CN2025/075468 patent/WO2026007397A1/zh active Pending
Patent Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20110061062A1 (en) * | 2009-07-29 | 2011-03-10 | Echostar Technologies L.L.C. | Communication among execution threads of at least one electronic device |
| CN104216768A (zh) * | 2014-09-22 | 2014-12-17 | 北京金山安全软件有限公司 | 一种数据处理方法及装置 |
| CN116832431A (zh) * | 2022-03-23 | 2023-10-03 | 深圳市腾讯网络信息技术有限公司 | 在后台服务器上并发执行多个线程的方法 |
| CN117389755A (zh) * | 2023-09-06 | 2024-01-12 | 北京恺望数据科技有限公司 | 一种多线程共享内存方法及装置 |
Also Published As
| Publication number | Publication date |
|---|---|
| CN121277722A (zh) | 2026-01-06 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN113986515B (zh) | 为插件运行创建沙箱环境的方法和装置以及计算设备 | |
| EP3900308A1 (en) | Input/output processing in a distributed storage node with rdma | |
| US20230297352A1 (en) | Method for Starting Serverless Container and Related Device | |
| KR20100058670A (ko) | 크로스-시스템의 프록시-기반 태스크 오프로딩을 위한 장치, 시스템 및 방법 | |
| TWI715762B (zh) | 虛擬機器創建方法和裝置 | |
| CN116107764B (zh) | 数据处理方法及系统 | |
| CN115136133A (zh) | 按需代码执行的单次使用执行环境 | |
| US9250917B2 (en) | Auto-cloudifying applications via runtime modifications | |
| CN115454509A (zh) | 异构操作系统部署方法、系统、电子设备及存储介质 | |
| CN118605960A (zh) | 一种实例的启动加速方法及相关装置 | |
| CN116382713A (zh) | 构建应用镜像的方法、系统、设备和存储介质 | |
| WO2026007397A1 (zh) | 一种数据传输方法及相关装置 | |
| US11907176B2 (en) | Container-based virtualization for testing database system | |
| WO2025060449A1 (zh) | 应用程序运行方法、节点及计算设备集群 | |
| CN119847779A (zh) | 数据处理方法、电子设备和可读存储介质 | |
| US11989569B2 (en) | Unikernel provisioning | |
| CN115718588A (zh) | 发布网络服务的方法、装置、存储介质及处理器 | |
| CN117130591A (zh) | 一种代码生成方法、系统及相关设备 | |
| US11340949B2 (en) | Method and node for managing a request for hardware acceleration by means of an accelerator device | |
| US20200348962A1 (en) | Memory-fabric-based processor context switching system | |
| JP7271957B2 (ja) | 動的リンク装置、動的ロード装置、計算機システム、動的リンク方法、動的ロード方法、動的リンクプログラム、および動的ロードプログラム | |
| US11537457B2 (en) | Low latency remoting to accelerators | |
| US20240160501A1 (en) | Interoperability between actor frameworks and asynchronous frameworks | |
| WO2025247101A1 (zh) | 一种微前端中应用的加载方法及相关装置 | |
| CN120276786A (zh) | 一种应用启动加速方法及相关装置 |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| 121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 25831760 Country of ref document: EP Kind code of ref document: A1 |