Data processing method and apparatus

By monitoring the jump frequency at the top of the stack and migrating stack frames when necessary, combined with segmentation and copying expansion methods, the performance degradation caused by hot functions in high-concurrency scenarios is solved, achieving more efficient stack expansion and system stability.

WO2026066303A1PCT designated stage Publication Date: 2026-04-02HUAWEI TECH CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Filing Date
2025-06-23
Publication Date
2026-04-02

AI Technical Summary

Technical Problem

In high-concurrency scenarios, existing stack expansion techniques suffer from performance degradation due to hot functions, especially in functions with frequent jumps, where the performance overhead of segmented stacks is significant.

Method used

By monitoring the jump frequency at the top of the stack, the stack frame at the top of the stack is migrated to the newly allocated storage space only when preset conditions are met (such as the number of jumps or the frequency reaching a threshold). Combined with segmentation and copy expansion methods, segmentation at hot functions is avoided, thus improving performance.

Benefits of technology

It effectively avoids performance bottlenecks at hotspot functions, improves system operating efficiency and stability, and is compatible with multi-language mixed stack scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2025102747_02042026_PF_FP_ABST
    Figure CN2025102747_02042026_PF_FP_ABST
Patent Text Reader

Abstract

A data processing method. The method comprising: acquiring first information, the first information being related to the number of times of jumping, by a stack top position in a call stack, from a first storage space to a second storage space, wherein the first storage space is a space allocated to the call stack, and the second storage space is a capacity expansion space of the first storage space; when the first information satisfies a preset condition, allocating a third storage space to the call stack; and migrating stack frames located at the stack top position in the first storage space and stack frames in the second storage space to the third storage space. In the present application, when it is determined that the information related to the number of times of jumping, by the stack top position, from the first storage space to the second storage space does not meet the preset condition, the stack frames of the capacity expansion space and the stack frames located at the stack top position in the first storage space can be copied to a newly allocated storage space, so that no stack frames of hot functions are present at segmentation points of the storage spaces, thereby improving system performance.
Need to check novelty before this filing date? Find Prior Art

Description

Data processing method and apparatus thereof

[0001] The present application claims priority from the Chinese patent application No. 202411337947.1 filed on September 24, 2024, and entitled "A data processing method and apparatus thereof", the content of which is incorporated herein by reference in its entirety. TECHNICAL FIELD

[0002] The present application relates to the field of information technology, in particular to a data processing method and apparatus thereof. BACKGROUND

[0003] A call stack is a storage space allocated in memory for code and data in an executable file during program execution. The call stack includes multiple stack frames, and each stack frame corresponds to a function. The functions corresponding to two adjacent stack frames have a calling relationship.

[0004] Almost all high-level programming languages (such as Java, Golang, Javascript, etc.) have the ability to execute concurrently. In large server, cloud, AI computing and other scenarios, high concurrency has become a normalized scenario. In a high concurrency scenario, most concurrent threads require a small call stack, and a small number of concurrent threads require a large call stack. In this conflict scenario, in order to meet the needs of a small number of concurrent threads, a large initial stack size needs to be set for all threads to meet all execution situations.

[0005] In order to optimize this scenario, the concept of stack expansion is introduced. On the basis of stack expansion, a small initial stack size can be set to meet the running requirements of most threads. At the same time, for a small number of threads that require a large stack, they have the ability to expand the runtime stack. This optimization can exchange a small amount of execution time for a large amount of memory gain. The mainstream of stack expansion technology is segmented stack.

[0006] Among them, the segmented stack allocates a new memory space when expanding, splices it on the old stack, and connects it through some jump functions stub. Its characteristics lie in the simple and fast implementation scheme, and the expansion time is relatively short. The defect is that the business execution needs to jump at the stack segmentation point, which brings performance overhead. If there is a hot function (that is, a function that frequently jumps) at this point, the system's running performance will be reduced. SUMMARY

[0007] The present application provides a data processing method and apparatus thereof, which can prevent the existence of a stack frame of a hot function at the segmentation point of the storage space when running the call stack, thereby improving the performance of the system when running the call stack.

[0008] In a first aspect, the present application provides a data processing method, the method comprising: obtaining first information, the first information being related to a number of times that a top position in a call stack jumps from a first storage space to a second storage space; the first storage space being a space allocated to the call stack, and the second storage space being an expansion space of the first storage space; when the first information satisfies a preset condition, allocating a third storage space to the call stack; and migrating a stack frame at the top position in the first storage space and stack frames in the second storage space to the third storage space.

[0009] In the present application, the stack frame at the top position can be understood as a continuous stack frame in the call stack including the top position, and the stack frame at the top position is closer to the top than other stack frames.

[0010] The stack-in and stack-out of the stack frame are similar to the process of the rising and falling of a water column, and follow the last-in first-out principle. Because the second storage space exists, when the stack frame is stacked in, the top position often jumps from the first storage space to the second storage space (that is, the water column rises to exceed the first storage space and enters the second storage space). When the number (or frequency) of times that the top position in the call stack jumps from the first storage space to the second storage space is greater than a threshold value, it can be considered that the stack frame of the hot function exists at the segmentation of the first storage space and the second storage space. In this case, if the stack frame corresponding to the hot function is still segmented, the performance will be reduced. In the present application, when the information related to the number of times that the top position jumps from the first storage space to the second storage space does not satisfy the preset condition, the expansion space and the stack frame at the top position in the first storage space are copied to a newly allocated storage space, so that the stack frame of the hot function does not exist at the segmentation of the storage space, and the performance of the system is improved.

[0011] In a possible implementation, the method further comprises: when the first storage space allocated to the call stack is full, allocating the second storage space to the call stack, and adding a first function to the stack frame at the top position in the first storage space, the first function being used to indicate that the top position jumps from the first storage space to a first address in the second storage space, and the first address corresponding to a starting storage position of the second storage space.

[0012] In a possible implementation, the first information is collected through the first function.

[0013] In a possible implementation, the preset condition is that the number of times is greater than a first threshold value or the frequency is greater than a second threshold value.

[0014] In a possible implementation, the method further includes: adding a second function in a stack frame located at a top position in the stack frames in the first storage space that are not migrated to the third storage space, the second function being used to indicate that the top position is jumped from the first storage space to a second address in the third storage space, the second address corresponding to a starting storage position of the third storage space.

[0015] In a possible implementation, the method further includes: obtaining second information, the second information being related to a number of times that a top position in a call stack is jumped from a first storage space to a third storage space; allocating a fourth storage space for the call stack when the second information satisfies a preset condition; and migrating a stack frame located at the top position in the first storage space and stack frames in the third storage space to the fourth storage space.

[0016] That is, segmented expansion is used when initial expansion. For a stack segment point of a hot function, a partial stack copy is used to transfer the segment point to obtain a suitable segment position; there is a large performance risk when simply using segmented stack expansion, which is in conflict with the technical contradiction of the segmented stack scheme itself which is fast and convenient to expand. In this application, single segmented expansion is used in most scenarios to quickly complete the expansion action; in a few hot scenarios, partial copy expansion avoids performance bottleneck points.

[0017] In a possible implementation, the stack frame located at the top position is a stack frame in a continuous space and does not include a stack frame corresponding to a function of a preset type, the preset type being a function of a programming language different from a programming language of the call function.

[0018] In this way, compatibility with scenarios such as ffi can be achieved.

[0019] In a second aspect, the present application provides a data processing apparatus, the apparatus comprising:

[0020] an information collection module configured to obtain first information, the first information being related to a number of times that a top position in a call stack is jumped from a first storage space to a second storage space; the first storage space being a space allocated to the call stack, and the second storage space being an expansion space of the first storage space;

[0021] an expansion module configured to allocate a third storage space for the call stack when the first information satisfies a preset condition; and migrate a stack frame located at the top position in the first storage space and stack frames in the second storage space to the third storage space.

[0022] In a possible implementation, the expansion module is further configured to:

[0023] when the first storage space allocated for the call stack is full, allocating the second storage space for the call stack, and adding a first function in a stack frame at a top position in the first storage space, the first function being used to indicate that the top position is jumped from the first storage space to a first address in the second storage space, the first address corresponding to a starting storage position of the second storage space.

[0024] In a possible implementation, the information collection module is specifically configured to:

[0025] The first function is used to collect the first information.

[0026] In a possible implementation, the preset condition is that the occurrence frequency is greater than a first threshold value or the occurrence frequency is greater than a second threshold value.

[0027] In a possible implementation, the capacity expansion module is further configured to:

[0028] add a second function in a stack frame at a top position in a stack frame that is not migrated to the third storage space in the first storage space, the second function being used to indicate that the top position is jumped from the first storage space to a second address in the third storage space, the second address corresponding to a starting storage position of the third storage space.

[0029] In a possible implementation, the capacity expansion module is further configured to:

[0030] obtain second information, the second information being related to the number of times that the top position in the call stack is jumped from the first storage space to the third storage space;

[0031] when the second information satisfies the preset condition, allocate a fourth storage space for the call stack;

[0032] migrate the stack frame at the top position in the first storage space and the stack frame in the third storage space to the fourth storage space.

[0033] In a possible implementation, the stack frame at the top position is a stack frame in continuous space and does not include a stack frame corresponding to a function of a preset type, the preset type being a function of a programming language different from a programming language of the call function.

[0034] In a third aspect, an embodiment of the present application provides a data processing apparatus, which can include a memory, a processor, and a bus system, wherein the memory is used to store a program, and the processor is used to execute the program in the memory to perform the method in the first aspect and any optional method thereof.

[0035] In a fourth aspect, the embodiments of the present application provide a computer readable storage medium, which stores a computer program. When the computer program is run on a computer, the computer is enabled to perform the method of the first aspect and any optional method thereof.

[0036] In a fifth aspect, the embodiments of the present application provide a computer program, which, when run on a computer, enables the computer to perform the method of the first aspect and any optional method thereof.

[0037] In a sixth aspect, the present application provides a chip system, which comprises a processor for supporting the execution of a data processing device to implement the functions involved in the above aspects, such as sending or processing data involved in the above method; or, information. In a possible design, the chip system further comprises a memory, and the memory is configured to store program instructions and data necessary for the execution device or the training device. The chip system can be composed of a chip, or can comprise a chip and other discrete devices. BRIEF DESCRIPTION OF DRAWINGS

[0038] FIG. 1 is a schematic diagram of a call stack;

[0039] FIG. 2 is a schematic diagram of stack expansion;

[0040] FIG. 3 is a schematic diagram of stack expansion;

[0041] FIG. 4 is a flow diagram of a data processing method provided by the embodiments of the present application;

[0042] FIGS. 5 and 6 are schematic diagrams of stack expansion;

[0043] FIG. 7 is a schematic diagram of an application architecture;

[0044] FIG. 8 is a schematic diagram of a structure of a data processing device provided by the embodiments of the present application;

[0045] FIG. 9 is a schematic diagram of a structure of a terminal device provided by the embodiments of the present application;

[0046] FIG. 10 is a schematic diagram of a structure of a server provided by the embodiments of the present application. DETAILED DESCRIPTION

[0047] The embodiments of the present application are described below in conjunction with the accompanying drawings. The terms used in the embodiment part of the present application are only used to explain the specific embodiments of the present application, and are not intended to limit the present application.

[0048] The embodiments of the present application are described below in conjunction with the accompanying drawings. Those skilled in the art can know that, as technology develops and new scenarios appear, the technical solutions provided by the embodiments of the present application are also applicable to similar technical problems.

[0049] The terms "first", "second", and the like, as used in the description and the claims of the application and the preceding paragraph, are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the terms so used are interchangeable under appropriate circumstances such that the embodiments of the application described herein are, for example, capable of use in either order. It is therefore intended that the application be interpreted to include all variations and modifications that fall within the generic scope of the application herein described. Furthermore, the terms "include", "have", and the like, as used in the description and the claims of the application are intended to be interpreted as encompassing the presence of stated elements but not excluding the presence of additional elements or ones that are not stated. The terms "comprise", "comprising", "include", "including", and the like, as used herein, specify the presence of stated features, integers, steps, or components but do not preclude the presence or addition of one or more other features, integers, steps, components, or groups thereof.

[0050] As used herein, the terms "substantially", "about", and the like, are utilized by candidates as approximate or loose terms, not as terms of degree, and are intended to account for the tolerance in, for example, measurements or calculations, that would be understood by those having ordinary skill in the art. Further, the use of "may" when describing embodiments herein is intended to convey that one or more embodiments of the application do not necessarily include that feature. As used herein, the terms "use", "using", and "used" can be considered synonymous with the terms "utilize", "utilizing", and "utilized", respectively. Additionally, the term "exemplary" is intended to refer to an instance or illustration.

[0051] First, the related terms in the embodiments of the application are explained:

[0052] (1) Stack frame: refers to the part of the stack space allocated for a function call. The stack frame corresponding to each function can be used to save the local variables of the function, the parameters passed to the called function, the return value of the function, and the return address of the function.

[0053] (2) Stack backtracking: also known as backstack. Refers to the process of backtracking each layer of function stack frame based on the program call stack.

[0054] (3) Mixed stack: when the high-level language code contains functions written in different high-level programming languages, or the programming language of the high-level language code is different from the programming language of the runtime function, during the running of this piece of high-level language code, the call stack created contains different types of stack frames, such stack is a mixed stack, in which the type of each stack frame matches the high-level programming language of the function corresponding to the stack frame.

[0055] (4) Return address: The return address refers to an instruction address at which the calling function should continue to execute after returning from the called function, i.e., the address of the next instruction of the calling point instruction (the instruction corresponding to the code at which the function call occurs), i.e., the return address contained in the stack frame corresponding to the called function points to the calling function.

[0056] (5) Runtime library: Also known as runtime environment, runtime system, or simply runtime, the runtime library is a code library that supports the execution of high-level language code, and in most scenarios, its programming language is different from the high-level language of the code to be executed.

[0057] (6) Runtime function: A function in the runtime, and in most scenarios, the function in the runtime library is different from the function in the high-level language program to be executed.

[0058] (7) Compiler: A tool used to compile the high-level language code to be executed and the runtime code library that supports the execution of the high-level language code. After compilation, both the high-level language code and the runtime code library become binary executable programs.

[0059] (8) Frame pointer (FP): Points to the bottom of the current stack frame.

[0060] (9) Stack pointer (SP): Points to the top of the call stack.

[0061] (10) Code logic: Product code written directly by programmers in a high-level language, enabling the code to achieve the intended behavior in the product. The product can be various terminal devices, such as mobile phones, computers, watches, bracelets, or vehicle-mounted terminals, etc.

[0062] (11) High-level programming language (HLPL): A programming language independent of machines and oriented to processes or objects. It is a programming language based on human daily language, using characters or characters that are easily accepted by ordinary people to represent, with high readability, to facilitate people with shallow computer cognition to roughly understand its content. It can include Basic, Java, C, C++, Python, etc. Assembly language is a programming language between high-level programming language and machine language (also known as machine code), and is not generally considered a high-level programming language.

[0063] (12) Stack expansion: In this article, it refers to the expansion of the runtime stack, i.e., when the runtime stack space is insufficient due to too many call levels, the runtime stack is expanded to support the program to continue running.

[0064] (13) Cross-language mixed call stack: refers to a runtime stack that stores frames of multiple programming languages at the same time.

[0065] Please refer to FIG. 1, which is a structural diagram of a program call stack in an embodiment of the present application. As shown in FIG. 1, the program call stack can include multiple stack frames. The structure of the call stack is described below by taking three adjacent stack frames (stack frame 1, stack frame 2, and stack frame 3) in the call stack as an example.

[0066] As shown in FIG. 1, from the bottom of the stack to the top of the stack, there are stack frame 3, stack frame 2, and stack frame 1 in turn, which correspond to function 3, function 2, and function 1 respectively, that is, stack frame 3 stores parameters related to function 3, stack frame 2 stores parameters related to function 2, and stack frame 1 stores parameters related to function 1. The calling relationship of the three functions is: function 3 calls function 2, and function 2 calls function 1.

[0067] Among them, each stack frame saves a return address, a frame pointer, and N parameters, where N is a positive integer. The return address in each stack frame points to the calling function of the function corresponding to the stack frame. For example, during the calling of function 2 to function 1, after the calling ends, the storage address of the next instruction of the calling point instruction is mapped as return address 1, which returns to function 2 after function 1 is executed, so that function 2 continues to run. The stack pointer FP points to the bottom of the current stack frame, for example, frame pointer 1 points to the bottom address of stack frame 1.

[0068] Almost all high-level programming languages (such as Java, Golang, Javascript, etc.) have the ability to execute concurrently, and in large server, cloud, AI computing, etc. scenarios, high concurrency has become a normalized scenario. In the high concurrency scenario, most concurrent threads require a small call stack, and a small number of concurrent threads require a large call stack. In this conflict scenario, in order to meet the needs of a small number of concurrent threads, a large initial stack size needs to be set for all threads to meet all execution situations.

[0069] In order to optimize this scenario, the concept of stack expansion is introduced. On the basis of stack expansion, a smaller initial stack size can be set to meet the running requirements of most threads. At the same time, for a small number of threads that require a large stack, they have the ability to expand the runtime stack. This optimization can exchange a small amount of execution time for a large amount of memory gain. The development mainstream of stack expansion technology is two main implementation methods: copy stack and segmented stack.

[0070] The copy stack is a new large memory address, the old stack content is copied to the new stack, the pointer content on the new stack is adjusted, and then the execution is switched to the new stack, as shown in the implementation schematic diagram of Fig. 2. The feature is that the business code is executed on a complete and continuous stack after copying, and the business is not aware. The defect is that the copying and pointer adjustment process is time-consuming and tedious, and the content in the ffi stack cannot be processed in the multi-language mixed stack scenario. As shown in the right side of Fig. 2, the content of the other language stack cannot be sensed when the own language makes an ffi call, and the pointer to be corrected cannot be found and corrected, so the copy stack will fail in this scenario.

[0071] The segmented stack is a new memory space, which is spliced on the old stack, and connected through some jump functions stub, as shown in the implementation schematic diagram of Fig. 3. The feature is that the implementation scheme is simple and fast, and the expansion time is short. The defect is that the business execution needs to jump at the stack segmentation point, which brings performance overhead, and if there is a hot function (that is, a function that frequently jumps) at this point, the running performance of the system will be reduced, as shown in the right side of Fig. 3.

[0072] To solve the above problems, the embodiment of the application provides a data processing method. The data processing method of the embodiment of the application will be described in detail below with reference to the drawings.

[0073] Referring to Fig. 4, Fig. 4 is a flowchart of a data processing method provided by the embodiment of the application, as shown in Fig. 4, the data processing method provided by the embodiment of the application can include steps 401 to 403, which will be described in detail below.

[0074] 401, obtain first information, the first information is related to the number of times that the top position of the call stack jumps from a first storage space to a second storage space; the first storage space is a space allocated to the call stack, and the second storage space is an expansion space of the first storage space;

[0075] The call stack can be created when a program is running, and the program can be a program written by a program developer using a high-level programming language, which can be Basic, Java, C, C++, or Python, etc. The application is not limited to this. The program can include multiple layers of functions with calling relationship, which can be written in one high-level programming language, or in multiple different high-level programming languages, which is not limited by the application.

[0076] In a possible implementation, a program written in a high-level language is compiled to obtain a compiled binary executable program; meanwhile, a runtime library written in a high-level language is compiled to obtain a compiled runtime code library (binary). Then, the compiled runtime code library is invoked by a processor or other hardware to run the binary executable file corresponding to the program and create a call stack, which includes a stack frame corresponding to each executed function in the running process.

[0077] The compiling process can include a preprocessing stage, a compiling stage, an assembling stage, and a linking stage, and the present application does not expand on the compiling process.

[0078] The binary executable program is machine language instructions that can be directly executed by a processor or other hardware, i.e., a binary executable file.

[0079] The runtime library can provide a corresponding running environment for the program. Specifically, the runtime library can include a code library, framework, platform, and the like required for program execution. It should be noted that the runtime library also needs to be compiled when the program is running, and then a corresponding running environment is provided for the program based on the compiled runtime library.

[0080] Specifically, in the process of executing the program based on the compiled runtime library, an interface provided by the runtime library can be invoked to call a corresponding function in the compiled runtime library to support the execution of the program.

[0081] A small initial stack size can be set to meet the running requirements of most threads, for example, it can be the first storage space in the embodiments of the present application, and when the first storage space allocated for the call stack is full, the second storage space can be allocated for the call stack, and a stack frame located at the top of the first storage space is increased by a first function, the first function is used to indicate that the top position is jumped from the first storage space to a first address in the second storage space, and the first address corresponds to the starting storage position of the second storage space.

[0082] The stack frame entering and exiting is similar to the process of a water column rising and falling, and follows the principle of last in first out. Due to the existence of the second storage space, when the stack frame enters, the stack top position often jumps from the first storage space to the second storage space (that is, the water column rises to exceed the first storage space and enters the second storage space). When the number (or frequency) of the stack top position jumping from the first storage space to the second storage space in the call stack is greater than a threshold value, it can be considered that there is a stack frame of a hot function at the segmentation of the first storage space and the second storage space. In this case, if the stack frame corresponding to the hot function is still segmented, the performance will be reduced. In the embodiment of the present application, when the information related to the number of times of the stack top position jumping from the first storage space to the second storage space does not satisfy the preset condition, the stack frame at the stack top position in the expansion space and the first storage space is copied to a newly allocated storage space, so that there is no case that the stack frame of the hot function exists at the segmentation of the storage space, thereby improving the performance of the system.

[0083] Referring to FIG. 5, when it is found that the stack frame is full, a new stack newA can be applied to expand the capacity in a segmented stack manner, and a glue layer stub function (that is, the first function in the embodiment of the present application) can be added at the jump position of the two stack frames.

[0084] 402. When the first information satisfies a preset condition, a third storage space is allocated for the call stack;

[0085] In a possible implementation, the first information can be collected through the first function. The first function can be used to count the number of times of execution jumps. When the count or frequency in the glue layer stub reaches a certain threshold value, it can be considered that there is a hot function at the segmentation.

[0086] 403. The stack frame at the stack top position in the first storage space and the stack frame in the second storage space are migrated to the third storage space.

[0087] The stack frame at the stack top position can be all stack frames in the first storage space.

[0088] Referring to FIG. 5, a new stack newB is applied. The newB stack copies part of the old stack top content to the new stack newB according to a heuristic algorithm strategy, and then continues to expand the stack in a segmented stack form.

[0089] In a possible implementation, a second function can be added in the stack frame at the top of the stack in the first storage space that is not migrated to the third storage space, the second function being used to indicate that the top of the stack is jumped from the first storage space to a second address in the third storage space, the second address corresponding to a starting storage position of the third storage space. Second information is acquired, the second information being related to a number of times that the top of the stack in the call stack is jumped from the first storage space to the third storage space; when the second information satisfies the preset condition, a fourth storage space is allocated for the call stack; and the stack frame at the top of the stack in the first storage space and the stack frame in the third storage space are migrated to the fourth storage space.

[0090] That is, segmented expansion is used when initial expansion. For the stack segment point of the hot function, the transfer of the segment point is performed in the manner of partial stack copying to obtain a suitable segment position; there is a large performance risk when simply using segmented stack expansion, which is in conflict with the technical contradiction of the segmented stack scheme itself that is fast and convenient to expand. In this application, single segmented expansion is used in most scenarios to quickly complete the expansion action; in a few hot scenarios, partial copy expansion avoids performance bottleneck points.

[0091] If a suitable segment point cannot be found all the time, the final segmented stack will degenerate into a full stack copy, which fully copies the old stack to the new stack, and finally evolves into a complete copy stack.

[0092] In a possible implementation, the stack frame at the top of the stack is a stack frame in a continuous space and does not include a stack frame corresponding to a function of a preset type, the preset type being a function that calls a programming language different from that of the calling function. For example, referring to FIG. 6, the cross-language stack frame can be regarded as the bottom of the stack content of the expandable stack. The ffi stack frame (stack frame corresponding to a function of a preset type) is taken as a segment point, the upper layer thereof being taken as an expandable and operable stack, and the itself and the lower layer thereof being taken as inoperable content. That is, the range of the copy stack is all the content after the ffi_a stack frame. In this way, in the scenario of using a continuous runtime stack, initial expansion can be quickly completed, and compatibility with scenarios such as ffi can be achieved.

[0093] Embodiments of the present application can be program codes deployed on a server or a terminal device. In runtime, the program codes of embodiments of the present application run in the host memory and need to help the application program to manage and expand the stack.

[0094] The program code of the embodiment of the present application can be used by an application program in the form of a static or dynamic library. During the running of the application program, if the stack space of the program is about to be exhausted, a runtime stack expansion algorithm provided by the embodiment of the present application is triggered, the program code for implementing the embodiment of the present application is executed, the runtime stack is expanded, and the program is supported to continue normal running.

[0095] Referring to FIG. 8, FIG. 8 is a structure diagram of a data processing apparatus provided by the embodiment of the present application. As shown in FIG. 8, the data processing apparatus provided by the embodiment of the present application comprises:

[0096] The information collection module 801 is configured to acquire first information, the first information being related to the number of times that the top position of the call stack jumps from the first storage space to the second storage space; the first storage space being a space allocated to the call stack, and the second storage space being an expansion space of the first storage space.

[0097] The specific introduction of the information collection module 801 can refer to the introduction of step 401 in the above embodiment, and the similar parts will not be described here.

[0098] The expansion module 802 is configured to allocate a third storage space to the call stack when the first information acquired by the information collection module 801 meets a preset condition; and migrate the stack frame at the top position in the first storage space and the stack frame in the second storage space to the third storage space.

[0099] The specific introduction of the expansion module 802 can refer to the introduction of steps 402 and 403 in the above embodiment, and the similar parts will not be described here.

[0100] In a possible implementation, the expansion module is further configured to:

[0101] allocate the second storage space to the call stack when the first storage space allocated to the call stack is full, and add a first function to the stack frame at the top position in the first storage space, the first function being used to indicate that the top position jumps from the first storage space to a first address in the second storage space, the first address corresponding to the starting storage position of the second storage space.

[0102] In a possible implementation, the information collection module is specifically configured to:

[0103] collect the first information through the first function.

[0104] In a possible implementation, the preset condition is that the number of times is greater than a first threshold or the frequency of occurrence is greater than a second threshold.

[0105] In a possible implementation, the capacity expansion module is further configured to:

[0106] add a second function in the stack frame located at the top of the stack in the stack frame that is not migrated to the third storage space in the first storage space, the second function being configured to indicate that the top of the stack is jumped from the first storage space to a second address in the third storage space, the second address corresponding to a starting storage location of the third storage space.

[0107] In a possible implementation, the capacity expansion module is further configured to:

[0108] obtain second information, the second information being related to a number of times that the top of the stack in the call stack is jumped from the first storage space to the third storage space;

[0109] when the second information satisfies the preset condition, allocate a fourth storage space for the call stack;

[0110] migrate the stack frame located at the top of the stack in the first storage space and the stack frame in the third storage space to the fourth storage space.

[0111] In a possible implementation, the stack frame located at the top of the stack is a stack frame in a continuous space and does not include a stack frame corresponding to a function of a preset type, the preset type being a function that calls a programming language different from a programming language of the function.

[0112] Next, a terminal device provided in an embodiment of the present application is introduced. Referring to FIG. 9, FIG. 9 is a structural schematic diagram of a terminal device provided in an embodiment of the present application. The terminal device 900 can specifically be a virtual reality (VR) device, a mobile phone, a tablet computer, a notebook computer, a smart wearable device, etc., which is not limited herein. Specifically, the terminal device 900 includes a receiver 901, a transmitter 902, a processor 903, and a memory 904 (wherein the number of processors 903 in the terminal device 900 can be one or more, and one processor is taken as an example in FIG. 9). The processor 903 can include an application processor 9031 and a communication processor 9032. In some embodiments of the present application, the receiver 901, the transmitter 902, the processor 903, and the memory 904 can be connected through a bus or other means.

[0113] The memory 904 can include read-only memory and random access memory, and provide instructions and data to the processor 903. A portion of the memory 904 can also include non-volatile random access memory (NVRAM). The memory 904 stores processor and operating instructions, executable modules, or data structures, or a subset thereof, or an extended set thereof, wherein the operating instructions can include various operating instructions for implementing various operations.

[0114] The processor 903 controls the operation of the execution device. In a specific application, various components of the execution device are coupled together through a bus system, which can include a data bus, a power bus, a control bus, and a state signal bus, etc. However, for the sake of clarity, all the buses are referred to as a bus system in the figure.

[0115] The method disclosed in the above embodiments of the present application can be applied in the processor 903 or implemented by the processor 903. The processor 903 can be an integrated circuit chip with a signal processing capability. In the implementation process, each step of the above method can be completed by an integrated logic circuit or an instruction in the form of software in the processor 903. The processor 903 mentioned above can be a general processor, a digital signal processor (DSP), a microprocessor, or a microcontroller, and can further include an application specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. The processor 903 can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of the present application. The general processor can be a microprocessor or the processor can also be any conventional processor. The steps of the method disclosed in combination with the embodiments of the present application can be directly embodied as a hardware code processor for execution, or a combination of hardware and software modules in the code processor for execution. The software module can be located in a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, or other mature storage media in the art. The storage medium is located in the memory 904, and the processor 903 reads the information in the memory 904 and combines the hardware to complete the steps of the above method.

[0116] The receiver 901 can be configured to receive inputted digital or character information, and to generate signal input related to relevant settings and function control of the execution device. The transmitter 902 can be configured to output digital or character information through the first interface; the transmitter 902 can also be configured to send instructions to the disk group through the first interface to modify data in the disk group; and the transmitter 902 can further include a display device such as a display screen.

[0117] The server 1000 can include one or more central processing units (CPUs) 1010 (e.g., one or more processors) and memory 1032, and one or more storage media 1030 (e.g., one or more mass storage devices) storing applications 1042 or data 1044. The memory 1032 and the storage media 1030 can be volatile or non-volatile storage. The programs stored in the storage media 1030 can include one or more modules (not shown in the figure), each of which can include a series of instructions for operating the server. Further, the central processing unit 1010 can be configured to communicate with the storage media 1030 and execute the series of instructions in the storage media 1030 on the server 1000.

[0118] The server 1000 can further include one or more power supplies 1026, one or more wired or wireless network interfaces 1050, and one or more input / output interfaces 1058; or one or more operating systems 1041, such as Windows ServerTM, Mac OS XTM, UnixTM, LinuxTM, FreeBSDTM, etc.

[0119] In the embodiments of the present application, the central processing unit 1010 is configured to perform the actions in the above embodiments.

[0120] The embodiments of the present application further provide a computer program product, which, when running on a computer, causes the computer to perform the steps performed by the execution device as described above, or causes the computer to perform the steps performed by the training device as described above.

[0121] The embodiments of the present application further provide a computer-readable storage medium, which stores a program for signal processing, and when running on a computer, causes the computer to perform the steps performed by the execution device as described above, or causes the computer to perform the steps performed by the training device as described above.

[0122] The execution device, the training device or the terminal device provided by the embodiments of the present application can specifically be a chip, and the chip comprises a processing unit and a communication unit. The processing unit can be a processor, and the communication unit can be an input / output interface, a pin, a circuit or the like. The processing unit can execute computer execution instructions stored in a storage unit, so that the chip in the execution device executes the data processing method described in the above embodiments, or so that the chip in the training device executes the data processing method described in the above embodiments. Alternatively, the storage unit is a storage unit in the chip, such as a register, a cache or the like. The storage unit can also be a storage unit outside the chip in the wireless access device, such as a read-only memory (ROM) or other types of static storage devices that can store static information and instructions, a random access memory (RAM) or the like.

[0123] The processor mentioned in any of the above can be a general central processing unit, a microprocessor, an ASIC, or one or more integrated circuits for controlling execution of the above programs.

[0124] It should be further noted that the above-described device embodiments are only schematic, and the units described as separate components can or can not be physically separate, and the components shown as units can or can not be physical units, i.e. they can be located in one place or distributed on multiple network units. Part or all of the modules can be selected according to actual needs to achieve the purpose of the embodiments. In addition, the connection relationship between the modules in the device embodiments provided by the present application indicates that there is a communication connection between them, which can be implemented as one or more communication buses or signal lines.

[0125] Those skilled in the art can clearly understand that the application can be implemented by means of software plus necessary universal hardware, of course, also can be implemented by special hardware including special integrated circuit, special CPU, special memory, special component, etc. Generally, the functions completed by computer program can be easily implemented by corresponding hardware, and the specific hardware structure for implementing the same function can be various, such as analog circuit, digital circuit or special circuit, etc. However, for the application, the software program implementation is the better embodiment. Based on such understanding, the technical solutions of the application can be embodied in the form of software product, which is stored in a readable storage medium, such as a floppy disk, a U disk, a mobile hard disk, a ROM, a RAM, a magnetic disk or an optical disk, etc., including a plurality of instructions for making a computer device (which can be a personal computer, a training device, or a network device, etc.) execute the methods described in various embodiments of the application.

[0126] In the above embodiments, all or part of the embodiments can be implemented by software, hardware, firmware or any combination thereof. When implemented by software, all or part of the embodiments can be implemented in the form of a computer program product.

[0127] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of the application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another, for example, the computer instructions can be transmitted from one website, computer, training device or data center to another website, computer, training device or data center through wired (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (such as infrared, wireless, microwave, etc.) mode. The computer-readable storage medium can be any available medium that can be stored by a computer or a data storage device such as a training device, a data center, etc. integrated with one or more available media sets. The available medium can be a magnetic medium (such as a floppy disk, a hard disk, a magnetic tape), an optical medium (such as a DVD), or a semiconductor medium (such as a solid state disk (SSD)), etc.

Claims

1. A data processing method, characterized by, The method comprises: obtaining first information related to the number of times that the top position of a call stack jumps from a first storage space to a second storage space; the first storage space is a space allocated to the call stack, and the second storage space is an expansion space of the first storage space; allocating a third storage space for the call stack when the first information meets a preset condition; migrating the stack frame at the top position in the first storage space and the stack frame in the second storage space to the third storage space.

2. The method of claim 1, wherein, The method further comprises: allocating the second storage space for the call stack when the first storage space allocated for the call stack is full, and adding a first function to the stack frame at the top position in the first storage space, the first function being used to indicate that the top position jumps from the first storage space to a first address in the second storage space, the first address corresponding to the starting storage position of the second storage space.

3. The method of claim 2, wherein, The first information is obtained by: collecting the first information through the first function.

4. The method according to any one of claims 1 to 3, characterized in that, The preset condition is that the number of times is greater than a first threshold or the frequency is greater than a second threshold.

5. The method according to any one of claims 1 to 4, characterized in that, The method further comprises: adding a second function to the stack frame at the top position in the stack frame that has not been migrated to the third storage space in the first storage space, the second function being used to indicate that the top position jumps from the first storage space to a second address in the third storage space, the second address corresponding to the starting storage position of the third storage space.

6. The method of claim 5, wherein, The method further comprises: obtaining second information related to the number of times that the top position of a call stack jumps from a first storage space to a third storage space; allocating a fourth storage space for the call stack when the second information meets the preset condition; migrating the stack frame at the top position in the first storage space and the stack frame in the third storage space to the fourth storage space.

7. The method according to any one of claims 1 to 6, characterized in that, The stack frame at the top position is a stack frame in continuous space and does not include a stack frame corresponding to a function of a preset type, the preset type being a function of a programming language different from the programming language of the call function.

8. A data processing apparatus, characterized by, The device comprises: an information collection module configured to obtain first information related to the number of times that the top position of a call stack jumps from a first storage space to a second storage space; the first storage space is a space allocated to the call stack, and the second storage space is an expansion space of the first storage space; an expansion module configured to allocate a third storage space for the call stack when the first information meets a preset condition, and to migrate the stack frame at the top position in the first storage space and the stack frame in the second storage space to the third storage space.

9. The apparatus of claim 8, wherein, The expansion module is further configured to: when the first storage space allocated for the call stack is full, allocating the second storage space for the call stack, and adding a first function in a stack frame at a top position in the first storage space, the first function being used to indicate that the top position is jumped from the first storage space to a first address in the second storage space, the first address corresponding to a starting storage position of the second storage space.

10. The apparatus of claim 9, wherein, The information collection module is specifically configured to: collect the first information through the first function.

11. The apparatus of any one of claims 8 to 10, wherein, The preset condition is that the occurrence frequency is greater than a first threshold or the occurrence frequency is greater than a second threshold.

12. The apparatus of any one of claims 8 to 11, wherein, The capacity expansion module is further configured to: add a second function in a stack frame at a top position in a stack frame that is not migrated to the third storage space in the first storage space, the second function being used to indicate that the top position is jumped from the first storage space to a second address in the third storage space, the second address corresponding to a starting storage position of the third storage space.

13. The apparatus of claim 12, wherein, The capacity expansion module is further configured to: obtain second information, the second information being related to the number of times that the top position in the call stack is jumped from the first storage space to the third storage space; when the second information satisfies the preset condition, allocate a fourth storage space for the call stack; migrate the stack frame at the top position in the first storage space and the stack frame in the third storage space to the fourth storage space.

14. The apparatus of any one of claims 8 to 13, wherein, The stack frame at the top position is a stack frame in a continuous space and does not include a stack frame corresponding to a function of a preset type, the preset type being a programming language different from a programming language of the function.

15. A computer storage medium, comprising, The computer storage medium stores one or more instructions, which, when executed by one or more computers, cause the one or more computers to perform the operations of the method of any one of claims 1 to 7.

16. A computer program product, characterised in that, The computer storage medium stores one or more instructions, which, when executed by one or more computers, cause the one or more computers to perform the operations of the method of any one of claims 1 to 7.

17. A system, comprising: The computer storage medium stores one or more instructions, which, when executed by one or more computers, cause the one or more computers to perform the operations of the method of any one of claims 1 to 7. The computer storage medium stores one or more instructions, which, when executed by one or more computers, cause the one or more computers to perform the operations of the method of any one of claims 1 to 7. The computer storage medium stores one or more instructions, which, when executed by one or more computers, cause the one or more computers to perform the operations of the method of any one of claims 1 to 7.

18. A chip comprising a processor, characterized in that The computer storage medium stores one or more instructions, which, when executed by one or more computers, cause the one or more computers to perform the operations of the method of any one of claims 1 to 7.

Citation Information

Patent Citations

  • Processing method and system for thread stack

    CN106648549A

  • Program call stack creating method, stack backtracking method and device

    CN115774583A

  • Method and apparatus for controlling stack area in memory space

    US20030177328A1

  • Apparatus and method for dynamic instrumenting of code to minimize system perturbation

    US20040163077A1