WO2020211363A1 - 提高程序加载效率的方法、装置、计算机设备和存储介质 - Google Patents

提高程序加载效率的方法、装置、计算机设备和存储介质 Download PDF

Info

Publication number
WO2020211363A1
WO2020211363A1 PCT/CN2019/118166 CN2019118166W WO2020211363A1 WO 2020211363 A1 WO2020211363 A1 WO 2020211363A1 CN 2019118166 W CN2019118166 W CN 2019118166W WO 2020211363 A1 WO2020211363 A1 WO 2020211363A1
Authority
WO
WIPO (PCT)
Prior art keywords
program
data block
cache space
stored
call
Prior art date
Application number
PCT/CN2019/118166
Other languages
English (en)
French (fr)
Inventor
赵骏
Original Assignee
平安科技(深圳)有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 平安科技(深圳)有限公司 filed Critical 平安科技(深圳)有限公司
Publication of WO2020211363A1 publication Critical patent/WO2020211363A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating

Definitions

  • This application relates to the technical field of computer programs, and in particular to a method, device, computer equipment, and storage medium for improving program loading efficiency.
  • the user saves the program on the functional computing platform.
  • the program can be called by sending the corresponding request.
  • the functional computing platform provides the user with the host server resources needed to run the program.
  • the basic process of general implementation is to detect and call Whether the program is stored in the cache space, if it is in the cache space, it is called directly from the cache, if it is not in the cache space, the program is called in the database, and then the program is injected into Docker in real time (Docker is an open source application container engine) , Execute the program code, return the execution result to the user, and store the program in the cache space for the next program call, but this single processing method will cause the program to load slowly and the performance of the function computing platform is low.
  • Docker is an open source application container engine
  • the main purpose of this application is to provide a method, device, computer equipment and storage medium for improving the efficiency of program loading, aiming to solve the disadvantages of slow program loading efficiency and low performance of the function computing platform.
  • this application proposes a method for improving the efficiency of program loading, including:
  • the programs associated with the data blocks that are sorted before are sequentially stored in the cache space, and the programs stored in the cache space will not overflow the cache to determine whether the first program can be stored in the cache space in advance.
  • step of generating the first data block associated with the first program includes:
  • the call count, program name, and call time of the first program are acquired to generate the first data block associated with the first program, where the call count is one by default.
  • step of judging whether the first program meets the preset condition includes:
  • step of sorting the first data block and the second data block with the first priority according to the preset sorting rule includes:
  • the data blocks are sorted in descending order according to the call count, and if there are data blocks with the same call count, they are sorted in descending order of time according to the call time.
  • the method further includes:
  • the programs associated with the previously sorted data blocks are sequentially stored in the cache space, and the programs stored in the cache space will not overflow the cache, and it is determined whether the first program can replace the second program.
  • the method further includes:
  • the method further includes:
  • the call count in the first data block is incremented by one, and the call time is updated.
  • This application also proposes a device for improving the efficiency of program loading, including:
  • the first detection module is used to detect whether the first program is stored in the cache space when the first program is called;
  • the second detection module is used to detect whether there is a first data block associated with the first program if the detection result of the first detection module is negative.
  • the first data block records the call count, program name, and call time of the first program Call count
  • a generating module configured to generate a first data block associated with the first program if the detection result of the second detection module is negative;
  • the first sorting module is used to obtain all the second data blocks associated with the second program stored in the cache space, and sort the first data blocks and the second data blocks with the first priority according to a preset sorting rule;
  • the storage module is used to sequentially store the programs associated with the data blocks that are sorted in the first priority order in the cache space, and the programs stored in the cache space will not overflow the cache to determine whether the first program can be stored in advance To the cache space.
  • This application also proposes a computer device, including a memory and a processor, the memory stores computer-readable instructions, and the processor implements the steps of any one of the above methods when the computer-readable instructions are executed by the processor.
  • the present application also provides a computer-readable storage medium on which computer-readable instructions are stored, and when the computer-readable instructions are executed by a processor, the steps of any one of the above methods are implemented.
  • the beneficial effects of a method, device, computer equipment, and storage medium for improving the efficiency of program loading are: through data blocks associated with the program, the data blocks are prioritized, and priority is given according to the priority ranking situation.
  • the program corresponding to the relatively high-level data block is stored in the cache space in advance.
  • the function computing platform calls the program with high priority and frequently called, it can be called directly from the cache, saving the time of searching the program in the database and avoiding priority.
  • Very low and infrequently called programs should also be stored in the cache space or may replace the program in the cache space to improve the efficiency of program loading and improve the performance of the function computing platform.
  • FIG. 1 is a schematic diagram of steps of a method for improving program loading efficiency in this application
  • FIG. 2 is a schematic flowchart of a device for improving program loading efficiency in this application
  • FIG. 3 is a schematic block diagram of the structure of an embodiment of a computer device of this application.
  • an embodiment of the present application provides a method for improving program loading efficiency, including:
  • S5. According to the first priority sorting order, sequentially store the programs associated with the data blocks that are sorted before in the cache space, where the programs stored in the cache space will not overflow the cache, to determine whether the first program can be stored in the cache space in advance .
  • step S1 when the function computing platform calls the program, it first checks whether the called program is stored in the cache space. If the program has been stored in the cache space, it can be called directly from the cache space to improve the efficiency of program loading. .
  • step S2 if the called program is not stored in the cache space, it can be considered whether the called program is called for the first time or it has been called before but has not reached the condition of being stored in the cache space.
  • the data block associated with the program is called to determine which of the above situations is, and the data block associated with the program is a data structure used to record the frequency of the program being called by the function computing platform.
  • the data block can be represented by the statement ⁇ count:5,function:aaa,timestamp:20181029120159 ⁇ , where count represents the call count, function represents the program name, timestamp represents the call time, and the above data block record means that the program name is The "aaa" program was called 5 times, and the last time it was called was 12:01:59 on October 29, 2018.
  • step S3 if the called program does not have an associated data block, it can be determined that the called program is called for the first time, and then a data block associated with the program is generated, and then it can be judged whether the program can be stored in Cache space.
  • step S4 to determine whether the called program can be stored in the cache space, it is only necessary to compare with all the programs stored in the cache space. Therefore, the data blocks associated with all programs in the cache space are obtained.
  • the block is associated with the program.
  • the data block associated with the called program and the data block associated with the program in the cache space are prioritized according to predetermined rules. The purpose is also to perform a priority on the called program and all programs in the cache space.
  • Priority sorting the priority sorting order of data blocks is the priority sorting order of the corresponding program.
  • the program in the front has a higher priority than the program in the back, that is, the more important or frequently called.
  • step S5 if the priority of the program in the front is relatively high, the call is relatively frequent, and the program is called many times in the past, the frequency of being called in the future is also better. Therefore, according to the priority order of the data blocks, The program corresponding to the data block in the front is stored in the cache space in advance.
  • the specific number of programs in the front is loaded into the cache space, which depends on the specific cache space.
  • the program stored in the cache space Will not overflow the cache. If the cache space is full after 100 programs are stored, then the program corresponding to the data blocks with a priority of one to one hundred is stored in the cache space in advance.
  • the first 100 data blocks correspond to the program Compared with the programs that are ranked behind, they have higher priority.
  • the ones that are called frequently are more likely to be used frequently. If the data block associated with the called program is just within one hundred, then the called The program can be stored in the cache space.
  • the program that is already in the cache space that is, the program with high priority, can be called directly in the cache space, without the need to query from the database.
  • Calling the program reducing the steps of the function computing platform calling the program, can save the calling time, while avoiding the operation of storing the program in the cache space or possibly replacing the program in the cache space with a very low priority and relatively unimportant program, improving the program The efficiency of loading improves the performance of the function computing platform.
  • step S1 it further includes:
  • step S11 if the called program is in the cache space, the function computing platform can directly call the program in the cache space. At the same time, because the called program is in the cache space, it can indicate that the program is the first data block associated with it. Yes, when calling the program, the data block associated with the program should be updated at the same time.
  • the data block is ⁇ count:5,function:aaa,timestamp:20181029120159 ⁇ , the next time the program named "aaa" is calculated by the function
  • the calling count count is increased by 1, that is, the calling calculation count becomes 6, and the calling time timestamp is updated to the latest calling time, and the program has been stored in the cache space, and the call again will not replace the stored in the cache space.
  • step S2 it further includes:
  • S23 According to the second priority sorting order, sequentially store the programs associated with the data blocks that are sorted before in the cache space, where the programs stored in the cache space will not overflow the cache, and determine whether the first program needs to replace the second program.
  • step S3 it includes:
  • the preset conditions limit the programs that can be stored in the cache space in advance, and the necessary programs are stored in the cache space.
  • the call count, program name, and call time of the program are obtained to generate the data block associated with it.
  • the call count defaults to one, and the program generates the associated data block.
  • Data blocks will only participate in priority sorting to determine whether the program needs to be stored in the cache space in advance. For programs that do not meet the requirements, no data blocks associated with it will be generated. If they are not involved in sorting, they will not be stored in the cache space in advance. Programs that do not meet the preset conditions should also be stored in the cache space, or operations that may replace the cache space, so as to improve the efficiency of program loading and improve the performance of the function computing platform.
  • step 31 it includes:
  • S311 Determine whether the file size of the first program is less than a preset threshold
  • the threshold of the file size of the program is artificially set. For example, if the threshold is set to 100MB, it is Only when the file size is less than 100Mb is it suitable to be stored in the cache space.
  • This mark can be marked on the function computing platform when the user uploads the program.
  • the function computing platform has Important mark check function.
  • step S4 includes:
  • the preset rules are mainly based on the historical access frequency of the program to determine the sorting of the data blocks.
  • the sorting can be implemented as follows: Each data block has a call count, and the data blocks are sorted from large to small according to the call count.
  • the call time is obtained, and the call time is sorted in descending order according to the call time, that is, the data block with the earlier call time is ranked behind the data block with the later call time, and then the call time continues earlier Sort according to the call count and other data blocks, in order to finalize the priority of the data block.
  • the reason why the data block with the earlier call time is ranked behind the data block with the later call time is because it has waited longer and did not wait for the first time.
  • the second call in terms of probability, the probability of it being called next time will be smaller.
  • step S1 it further includes:
  • the program information includes the program name, code language, file type, and file quantity;
  • the user first uploads the written program to the functional computing platform and saves it.
  • the program information of the uploaded program will be entered on the functional computing platform, and the user will determine
  • the functional computing platform receives the program information uploaded by the user, and according to the storage rules, determines whether the code language is a scripting language or a non-scripting language, whether the number of files is multiple or a single, and whether the file type is compressed or uncompressed, to determine what to execute
  • the stored files are named according to the received program name.
  • the preset storage rules can store the code language, file type, number of files, etc. in a list. The list can be as shown in Table 1-1.
  • the program information received by the function computing platform is that the code language is a script language, the number of files is multiple, and the file type is a non-compressed package.
  • the received program information is queried in the storage rule table to be packaged and compressed first, and then converted into base64 format, then the function computing platform packs and compresses multiple program files uploaded by the user to form a whole, and then converts to base64 format and stores it in the database Set a program name for the whole file.
  • the program name set is also the program name in the program information uploaded by the user.
  • Subsequent users can use this program name to call all program files of this program on the function computing platform, which reduces Search time for multiple program files, improve program loading efficiency, and improve the performance of the function computing platform.
  • the code language is a script language
  • the program is directly converted to base64 format and stored in the database. This is because the script language does not need to be compiled, and directly converted to base64 format can reduce compression and decompression
  • different programs use different access methods according to the actual situation to improve program loading efficiency and improve the performance of the function computing platform, and the final format is converted to base64 format.
  • Base64 is a kind of binary data based on 64 printable characters. Method, can also save storage space.
  • an embodiment of the present application also provides a device for improving the efficiency of program loading, including:
  • the first detection module 1 is used to detect whether the first program is stored in the cache space when the first program is called;
  • the second detection module 2 is used to detect whether there is a first data block associated with the first program if the detection result of the first detection module is negative, and the first data block records the call count, program name and call of the first program Time call count;
  • the generating module 3 is configured to generate a first data block associated with the first program if the detection result of the second detection module is negative;
  • the first sorting module 4 is configured to obtain all the second data blocks associated with the second program stored in the cache space, and sort the first data blocks and the second data blocks with the first priority according to a preset sorting rule;
  • the storage module 5 is used to sequentially store the programs associated with the data blocks that are sorted in the first priority order in the cache space, and the programs stored in the cache space will not overflow the cache to determine whether the first program can be pre-ordered Stored in the cache space.
  • first detection module 1 when the function computing platform calls a program, it first checks whether the called program is stored in the cache space. If the program is already stored in the cache space, it can be called directly from the cache space to improve Program loading efficiency.
  • the called program if the called program is not stored in the cache space, it can be considered whether the called program is called for the first time or it has been called before but has not reached the condition of being stored in the cache space, so check whether it exists
  • the data block associated with the called program is used to determine which of the above situations is, and the data block associated with the program is a data structure used to record the frequency of the program being called by the function computing platform.
  • the data block can be represented by the statement ⁇ count:5,function:aaa,timestamp:20181029120159 ⁇ , where count represents the call count, function represents the program name, timestamp represents the call time, and the above data block record means that the program name is The "aaa" program was called 5 times, and the last time it was called was 12:01:59 on October 29, 2018.
  • the called program if the called program does not have an associated data block, it can be determined that the called program is called for the first time, then a data block associated with the program is generated, and then it can be determined whether the program can be stored To the cache space.
  • the first sorting module 4 determines whether the called program can be stored in the cache space, it only needs to compare with all the programs that have been stored in the cache space, so the data blocks associated with all programs in the cache space are obtained. Since the data block is associated with the program, the data block associated with the called program and the data block associated with the program in the cache space are prioritized according to predetermined rules. The purpose is also to prioritize the called program and the data block in the cache space. All programs are sorted by priority.
  • the data block priority sorting order is the priority sorting order of the corresponding program. The program in the front has a higher priority than the program in the back, that is, the more important or the call Frequent.
  • the priority of the program ranked in the front is relatively high, the call is relatively frequent, and the program is called many times in the past, the frequency of being called in the future is also better. Therefore, according to the priority order of the data blocks, The programs corresponding to the data blocks that are ranked in the front are stored in the cache space in advance. The specific number of programs that are ranked in the front is loaded into the cache space, which depends on the specific cache space, and the ones stored in the cache space The program will not overflow the cache.
  • the program corresponding to the data blocks with the first priority order of one to one hundred will be stored in the cache space in advance, the first one hundred data
  • the corresponding program of the block has a higher priority than the program in the back. It is called frequently, and it is more likely to be used frequently. If the data block associated with the called program is just within one hundred, then The called program can be stored in the cache space.
  • the function computing platform calls the program, the program that is already in the cache space, that is, the program with high priority, can be called directly in the cache space, without the need to call the database again.
  • Query calling programs reducing the steps of calling programs on the function computing platform, saving calling time, and avoiding operations that are stored in the cache space or may replace programs in the cache space for programs with very low priority and relatively unimportant.
  • the efficiency of program loading improves the performance of the function computing platform.
  • the first update module if the detection result of the first detection module is yes, adds one to the call count in the first data block, and updates the call time.
  • the function computing platform can directly call the program in the cache space.
  • the called program is in the cache space, it can indicate that the program is the first related program.
  • the data block associated with the program should be updated at the same time.
  • the data block is ⁇ count:5,function:aaa,timestamp:20181029120159 ⁇ , the next time the program named "aaa" is If the function calculation platform is called, the call count count is increased by 1, that is, the call calculation count becomes 6, and the call time timestamp is updated to the latest call time, and the program has been stored in the cache space, and the call will not be replaced in the cache space. Therefore, there is no need to prioritize the data block after updating the record content of the data block.
  • the second update module if the detection result of the second detection module is yes, increment the call count in the first data block by one, and update the call time;
  • the second sorting module is configured to obtain the second data block, and re-sort the first data block and the second data block according to the preset rule with the second priority;
  • the replacement module is used to store the programs associated with the data blocks that are sorted first in the buffer space according to the second priority sorting order, and the programs stored in the buffer space will not overflow the buffer, and judge whether the first program needs to replace the second program.
  • the generating module 3 it includes:
  • the judging sub-module is used to judge whether the first program meets the preset condition
  • the preset conditions limit the programs that can be stored in the cache space in advance.
  • the call count, program name, and call time of the program are obtained to generate the data block associated with it.
  • the call count defaults to one, and the program generates the data block associated with it.
  • It will participate in priority sorting to determine whether the program needs to be stored in the cache space in advance. For programs that do not meet the requirements, the associated data block will not be generated, and the sorting will not be pre-stored in the cache space to avoid non-compliance.
  • Programs with preset conditions should also be stored in the cache space, or operations that may replace the cache space, to improve the efficiency of program loading and improve the performance of the function computing platform.
  • judgment sub-module includes:
  • the first judging unit is used to judge whether the file size of the first program is less than a preset threshold
  • the second judgment unit is used to judge whether the first program is marked as important by the user if the judgment result of the first judgment unit is yes;
  • the judging unit is configured to determine that the first program meets the preset condition if the judgment result of the second judging unit is yes.
  • the threshold of the file size of the program is artificially set. For example, if the threshold is set to 100MB, it is Only when the file size is less than 100Mb is it suitable to be stored in the cache space.
  • This mark can be marked on the function computing platform when the user uploads the program.
  • the function computing platform has Important mark check function.
  • the first sorting module 4 includes:
  • the sorting sub-module is used to sort the data blocks from large to small according to the call count. If there are data blocks with the same call count, they are sorted in descending order of time according to the call time.
  • the preset rules mainly determine the sorting of data blocks based on the historical access frequency of the program.
  • the sorting can be implemented as follows: each data block has a call count, and the data is sorted from large to small according to the call count.
  • the call time is obtained, and the call time is sorted in descending order according to the call time, that is, the data block with the earlier call time is ranked behind the data block with the later call time, and then the call time is earlier
  • the call time is earlier
  • the reason why the data block with the earlier call time is ranked behind the data block with the later call time is because it has waited for a longer time without waiting. In the second call, in terms of probability, the probability of it being called next time will be lower.
  • the receiving module is used to receive the first program and program information uploaded by the user, the program information package program name, code language, file type and file quantity;
  • the storage module is used to store the first program in the database according to the program information according to a preset storage rule.
  • the user first uploads the written program to the functional computing platform and saves it.
  • the program information of the uploaded program will be entered on the functional computing platform, and the user will determine
  • the functional computing platform receives the program information uploaded by the user, and according to the storage rules, determines whether the code language is a scripting language or a non-scripting language, whether the number of files is multiple or a single, and whether the file type is compressed or uncompressed, to determine what to execute
  • the stored files are named according to the received program name.
  • the preset storage rules can store the code language, file type, number of files, etc. in a list. The list can be as shown in Table 1-1.
  • the program information received by the function computing platform is that the code language is a script language, the number of files is multiple, and the file type is a non-compressed package.
  • the received program information is queried in the storage rule table to be packaged and compressed first, and then converted into base64 format, then the function computing platform packs and compresses multiple program files uploaded by the user to form a whole, and then converts to base64 format and stores it in the database Set a program name for the whole file.
  • the program name set is also the program name in the program information uploaded by the user.
  • an embodiment of the present application also provides a computer device.
  • the computer device may be a server, and its internal structure may be as shown in FIG. 3.
  • the computer equipment includes a processor, a memory, a network interface and a database connected through a system bus. Among them, the computer designed processor is used to provide calculation and control capabilities.
  • the memory of the computer device includes a non-volatile storage medium and an internal memory.
  • the non-volatile storage medium stores an operating system, computer readable instructions, and a database.
  • the internal memory provides an environment for the operation of the operating system and computer-readable instructions in the non-volatile storage medium.
  • the database of the computer equipment is used to store configuration item information and other data.
  • the network interface of the computer device is used to communicate with an external terminal through a network connection.
  • FIG. 3 is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied.
  • An embodiment of the present application further provides a computer-readable storage medium.
  • the readable storage medium may be a non-volatile readable storage medium or a volatile readable storage medium on which computer-readable instructions are stored.
  • the processes of the above-mentioned method embodiments are executed.
  • the above are only the preferred embodiments of this application, and do not limit the scope of this application. Any equivalent structure or equivalent process transformation made using the content of this application description and drawings, or directly or indirectly applied to other related The technical field is equally included in the scope of patent protection of this application.

Abstract

本申请揭示了一种提高程序加载效率的方法、装置、计算机设备和存储介质,其中方法包括:当第一程序被调用时,检测第一程序是否存放在缓存空间;若否,则检测是否存在与第一程序关联的第一数据块,第一数据块记录第一程序的调用计数、程序名称和调用时间;若否,则生成与第一程序关联的第一数据块;获取存放在缓存空间中的所有第二程序关联的第二数据块,按照预设排序规则将第一数据块和第二数据块进行第一优先级排序;按照第一优先级排序顺序,依次将排序在前的数据块关联的程序存放到缓存空间,其中存放到缓存空间的程序不会溢出缓存,以确定第一程序是否可以预先存放到缓存空间。本申请提高程序加载效率,提高函数计算平台性能。

Description

提高程序加载效率的方法、装置、计算机设备和存储介质
本申请要求于2019年4月19日提交中国专利局、申请号为201910319067.4,发明名称为“提高程序加载效率的方法、装置、计算机设备和存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及计算机程序技术领域,特别涉及一种提高程序加载效率的方法、装置、计算机设备和存储介质。
背景技术
用户将程序保存在函数计算平台上,当需要程序执行时,通过发送对应的请求即可调用程序,函数计算平台为用户提供运行程序所需要的主机服务器资源,一般实现的基本过程是,检测调用程序是否存放在缓存空间,如果在缓存空间,则直接从缓存中调用,如果不在缓存空间,则到数据库中调用程序,然后将程序实时的注入到Docker(Docker是一个开源的应用容器引擎)中,执行程序代码,将执行的结果返回给用户,同时将程序存放到缓存空间用于下次的程序调用,但是这种单一的处理方式会导致程序加载效率比较慢,函数计算平台的性能低下。
技术问题
本申请的主要目的为提供一种提高程序加载效率的方法、装置、计算机设备和存储介质,旨在解决现有程序加载效率慢、函数计算平台性能低下的弊端。
技术解决方案
为了实现上述目的,本申请提出一种提高程序加载效率的方法,包括:
当第一程序被调用时,检测第一程序是否存放在缓存空间;
若不在缓存空间,则检测是否存在与第一程序关联的第一数据块,第一数据块记录第一程序的调用计数、程序名称和调用时间;
若不存在第一数据块,则生成与第一程序关联的第一数据块;
获取存放在缓存空间中的所有第二程序关联的第二数据块,按照预设排序规则将第一数据块和第二数据块进行第一优先级排序;
按照第一优先级排序顺序,依次将排序在前的数据块关联的程序存放到缓存空间,其中存放到缓存空间的程序不会溢出缓存,以确定第一程序是否可以预先存放到缓存空间。
进一步地,生成与第一程序关联的第一数据块的步骤中,包括:
判断第一程序是否满足预设条件;
若满足预设条件,则获取第一程序的调用计数、程序名称和调用时间,以生成与第一程序关联的第一数据块,其中调用计数默认为一。
进一步地,判断第一程序是否满足预设条件的步骤中,包括:
判断第一程序的文件大小是否小于预设阈值;
若小于预设阈值,则判断第一程序是否被用户标记为重要;
若标记为重要,则判定第一程序满足预设条件。
进一步地,按照预设排序规则将第一数据块和第二数据块进行第一优先级排序的步骤中,包括:
根据调用计数从大到小将数据块依次排序,其中若有调用计数相同的数据块,则根据调用时间按时间降序排序。
进一步地,检测是否存在与第一程序关联的第一数据块的步骤之后,还包括:
若存在第一数据块,则将第一数据块中的调用计数加一,并且更新调用时间;
获取第二数据块,重新根据预设规则将第一数据块和第二数据块进行第二优先级排序;
按照第二优先级排序顺序,依次将排序在前的数据块关联的程序存放到缓存空间,其中存放到缓存空间的程序不会溢出缓存,判断第一程序是否可以替换第二程序。
进一步地,获取存放在缓存空间中的所有第二程序关联的第二数据块的步骤之前,还包括:
判断缓存空间是否足够存放第一程序;
若足够存放,则将第一程序存放到缓存空间;
若不足够存放,则获取存放在缓存空间中的所有第二程序关联的第二数据块。
进一步地,当第一程序被调用时,检测第一程序是否存放在缓存空间的步骤之后,还包括:
若在缓存空间,则将第一数据块中的调用计数加一,并且更新调用时间。
本申请还提出一种提高程序加载效率的装置,包括:
第一检测模块,用于当第一程序被调用时,检测第一程序是否存放在缓存 空间;
第二检测模块,用于若第一检测模块的检测结果为否,则检测是否存在与第一程序关联的第一数据块,第一数据块记录第一程序的调用计数、程序名称和调用时间调用计数;
生成模块,用于若第二检测模块的检测结果为否,则生成与第一程序关联的第一数据块;
第一排序模块,用于获取存放在缓存空间中的所有第二程序关联的第二数据块,按照预设排序规则将第一数据块和第二数据块进行第一优先级排序;
存放模块,用于按照第一优先级排序顺序,依次将排序在前的数据块关联的程序存放到缓存空间,其中存放到缓存空间的程序不会溢出缓存,以确定第一程序是否可以预先存放到缓存空间。
本申请还提出一种计算机设备,包括存储器和处理器,存储器存储有计算机可读指令,处理器执行计算机可读指令时实现上述任一项方法的步骤。
本申请还提供一种计算机可读存储介质,其上存储有计算机可读指令,所述计算机可读指令被处理器执行时实现上述任一项方法的步骤。
有益效果
本申请中提供的一种提高程序加载效率的方法、装置、计算机设备和存储介质的有益效果为:通过与程序关联的数据块,并对数据块进行优先级排序,根据优先级排序情况将优先级相对高的数据块对应的程序预先存放到缓存空间,当函数计算平台调用优先级高、频繁调用的程序时,可以直接从缓存中调用,省去在数据库查找程序的时间,同时避免优先级很低、调用不频繁的程序也要进行存放到缓存空间、或可能替换缓存空间中的程序的操作,提高程序加载的效率,提高函数计算平台的性能。
附图说明
图1为本申请提高程序加载效率的方法的步骤示意图;
图2为本申请提高程序加载效率的装置的流程示意图;
图3为本申请计算机设备一实施例的结构示意框图。
本申请目的的实现、功能特点及优点将结合实施例,参照附图做进一步说明。
本发明的最佳实施方式
为了使本申请的目的、技术方案及优点更加清楚明白,以下结合附图及实 施例,对本申请进行进一步详细说明。应当理解,此处描述的具体实施例仅仅用以解释本申请,并不用于限定本申请。
参照图1,本申请一实施例中提供了一种提高程序加载效率的方法,包括:
S1、当第一程序被调用时,检测第一程序是否存放在缓存空间;
S2、若不在缓存空间,则检测是否存在与第一程序关联的第一数据块,第一数据块记录第一程序的调用计数、程序名称和调用时间;
S3、若不存在第一数据块,则生成与第一程序关联的第一数据块;
S4、获取存放在缓存空间中的所有第二程序关联的第二数据块,按照预设排序规则将第一数据块和第二数据块进行第一优先级排序;
S5、按照第一优先级排序顺序,依次将排序在前的数据块关联的程序存放到缓存空间,其中存放到缓存空间的程序不会溢出缓存,以确定第一程序是否可以预先存放到缓存空间。
在上述步骤S1中,函数计算平台在调用程序的时候,都是先检测调用的程序是否存放在缓存空间中,如果程序已存放在缓存空间,则可以直接从缓存空间中调用,提高程序加载效率。
在上述步骤S2中,若缓存空间中没有存放被调用的程序,则可以考虑被调用的程序是第一次调用还是之前有调用过但是没有达到存放在缓存空间的条件,所以检测是否存在与被调用程序关联的数据块来判断是上述的哪种情况,而与程序关联的数据块是用来记录程序被函数计算平台调用频率的数据结构。如数据块可以通过语句{count:5,function:aaa,timestamp:20181029120159}来表示,其中,count表示调用计数、function表示程序名称,timestamp表示调用时间,上面的数据块记录的意思是程序名称为“aaa”的程序被调用了5次,最近一次调用时间是2018年10月29日12点1分59秒。
在上述步骤S3中,若被调用的程序没有关联的数据块,则可以确定该被调用的程序是第一次调用,则生成与该程序关联的数据块,后续可以判断该程序是否可以存放到缓存空间。
在上述步骤S4中,要判断被调用的程序是否可以存放在缓存空间,只需要和已存放到缓存空间中的所有程序进行比较即可,因此获取缓存空间中所有程序关联的数据块,由于数据块是与程序关联的,按照预定规则将被调用程序关联的数据块和在缓存空间中的程序关联的据块进行优先级排序,目的也是对被调用的程序和在缓存空间中的所有程序进行优先级排序,数据块优先级排序顺 序即对应程序的优先级排序顺序,排在前面的程序相对于排在后面的程序来说优先级是比较高的,即比较重要的或是调用频繁的。
在上述步骤S5中,如排在前面的程序优先级相对比较高、调用相对比较频繁,程序过去被调用多次,那么将来被调用的频率也更好,因此根据数据块优先级排序顺序,依次将排在前面的数据块对应的程序预先存放到缓存空间,具体将排在前面的多少个程序加载到缓存空间中,这要看具体的缓存空间是多少来决定,其中存放到缓存空间的程序不会溢出缓存,如缓存空间在存放到100个程序后,缓存空间满了,那么就是将优先级排序一至一百的数据块对应的程序预先存放到缓存空间,前一百个数据块对应程序相对于排在后面的程序来说都是优先级高的,调用频繁的,有较大的可能会经常使用到,如果被调用的程序关联的数据块刚好排在一百以内,则被调用的程序可以存放到缓存空间,函数计算平台下次在调用程序的时候,对于调用已经在缓存空间中的程序,即优先级高的程序,可以直接在缓存空间中调用,而无需要再从数据库查询调用程序,减少函数计算平台调用程序的步骤,能节约调用时间,同时避免优先级很低、相对不重要的程序也要进行存放到缓存空间、或可能替换缓存空间中的程序的操作,提高程序加载的效率,提高函数计算平台的性能。
进一步地,在步骤S1之后,还包括:
S11、若在缓存空间,则将第一数据块中的调用计数加一,并且更新调用时间。
在上述步骤S11中,若被调用的程序在缓存空间,则函数计算平台可以直接在缓存空间调用程序,同时由于被调用的程序在缓存空间,则可以说明该程序是有关联的第一数据块的,在调用该程序的时候,要同时更新该程序关联的数据块,如数据块是{count:5,function:aaa,timestamp:20181029120159},下一次名为“aaa”的程序再被函数计算平台调用,则调用计数count加1,即调用计算count变成6,而调用时间timestamp更新为最新的调用时间,而且该程序已经存放在缓存空间,再次调用也不会更换存放在缓存空间中的其他程序,因此更新数据块的记录内容之后不需要进行数据块的优先级排序。
进一步地,在步骤S2之后,还包括:
S21、若存在第一数据块,则将第一数据块中的调用计数加一,并且更新调用时间;
S22、获取第二数据块,重新根据预设规则将第一数据块和第二数据块进行 第二优先级排序;
S23、按照第二优先级排序顺序,依次将排序在前的数据块关联的程序存放到缓存空间,其中存放到缓存空间的程序不会溢出缓存,判断第一程序是否需要替换第二程序。
在本实施例中,程序在调用时,存在与其关联的数据块,那么说明该程序之前被调用过,但是没有达到存放在缓存空间的优先级条件,在检测到程序被调用后,需要更新与其关联的数据块,然后获取所有在缓存空间的程序关联的数据块,重新根据预设排序规则将被调用程序的数据块和所有存放在缓存空间中程序关联的数据块进行优先级排序,目的是根据数据块排序找出相对优先级高的、重要的对应的程序,以调整程序的相对优先级,优先级排序排在前面的数据块关联的程序调用比较频繁、相对优先级比较高,这是因为程序过去被调用多次,那么将来被调用的频率也更好,重新按照优先级排序顺序,依次将排序在前的数据块关联的程序存放到缓存空间,其中存放到缓存空间的程序不会溢出缓存,以确定被调用的程序能否存放在缓存空间,即被调用的程序能否替换已存放在缓存空间中的某个程序,以保证存放到缓存空间的程序都是调用比较频繁的,都是相对优先级比较高的,函数计算平台经常调用上述程序可以省去在数据库的查找调用的时间,提高程序的加载效率。
进一步地,在步骤S3中,包括:
S31、判断第一程序是否满足预设条件;
S32、若满足预设条件,则获取第一程序的调用计数、程序名称和调用时间,以生成与第一程序关联的第一数据块,其中调用计数默认为一。
在本实施例中,由于缓存空间的空间容量有限,不可能每个程序都预先存放到缓存空间中,通过预设条件,限定可以预先存放到缓存空间中的程序,有必要的程序在其被第一次调用的时候,才会去获取程序的调用计数、程序名称和调用时间,以生成与其关联的数据块,当然由于是第一次调用,所以调用计数默认为一,程序生成与其关联的数据块才会参与优先级排序,以判断程序是否需要预先存放到缓存空间,对不符合要求的程序则不生成与其关联的数据块,不参与排序,也就不会预先存放到缓存空间,避免不符合预设条件的程序也要进行存放到缓存空间、或可能替换缓存空间的程序的操作,提高程序加载的效率,提高函数计算平台的性能。
进一步地,在步骤31之中,包括:
S311、判断第一程序的文件大小是否小于预设阈值;
S312、若小于预设阈值,则判断第一程序是否被用户标记为重要;
S313、若标记为重要,则判定第一程序满足预设条件。
在本实施例中,由于缓存空间的空间有限,程序如果太大,则不适合存放到缓存空间中,程序的文件大小的阈值为人为设定,如将阈值设定为100MB,即当程序的文件大小小于100Mb的时候才适合存放到缓存空间中。其次,当该程序被用户设置为重要、性能级别要求高的情况下,用户主观有使用程序的需求,这个标记可以在用户上传程序的时候在函数计算平台上进行标记,函数计算平台上设有重要标记勾选功能。当程序满足以上两种条件的情况下,判断程序满足预设条件,生成与程序关联数据块,可以进行优先级排序。
进一步地,步骤S4之中,包括:
S41、根据调用计数从大到小将数据块依次排序,其中若有调用计数相同的数据块,则根据调用时间按时间降序排序。
在上述步骤S41中,预设的规则主要根据程序的历史访问频率来确定数据块的排序,排序的实现方式可以如下:每个数据块都有一个调用计数,根据调用计数从大到小将数据块依次排序的时候,如果遇到调用计数相同的数据块则获取调用时间,根据调用时间按时间降序排序,即调用时间早的数据块排在调用时间晚的数据块后面,然后调用时间早的继续根据调用计数与其他数据块排序,以最终完成数据块的优先级排序,调用时间早的数据块排在调用时间晚的数据块后面的理由是因为它等待了更长的时间都没有等来第二次调用,从概率上讲,它下次被调用的几率会小一些。也可以是另一种排序实现方式:可以先根据调用计数从大到小将数据块依次排序,如果遇到调用计数相同的数据块则先默认排在该数据块前面,待数据块按照调用计数从大到小排序完之后,再将具有相同引用的数据块按照调用时间排序,调用时间早的数据块排在调用时间晚的数据块后面,最终完成数据块的排序。
进一步地,在步骤S1之前,还包括:
S12、接收用户上传的第一程序和程序信息,程序信息包括程序名称、代码语言、文件类型和文件数量;
S13、根据所述程序信息按照预设存储规则将所述第一程序存储在数据库中。
在本实施例中,要使用函数计算平台,用户首先要将编写好的程序上传到 函数计算平台中并保存,在用户上传程序时会在函数计算平台上输入上传程序的程序信息,待用户确定后,函数计算平台接收用户上传的程序信息,根据存储规则依次判断代码语言是脚本语言还是非脚本语言,文件数量是多个还是单个,文件类型是压缩包还是非压缩包,以确定要执行的存储步骤,储存的文件根据接收的程序名称命名,预设存储规则可以将代码语言、文件类型、文件数量等存储在一列表中,列表可以如下表1-1。
表1-1
Figure PCTCN2019118166-appb-000001
若程序功能比较复杂,需要多个程序文件来一起完成,用户将多个程序文件上传后,函数计算平台接收的程序信息为代码语言是脚本语言、文件数量是多个、文件类型是非压缩包,通过接收的程序信息在存储规则表中查询到要先打包压缩,再转化为base64格式,则函数计算平台将用户上传的多个程序文件打包压缩形成一个整体,再转化为base64格式后存储在数据库中,针对这整体文件设置一个程序名称,设置的程序名称也是通过用户上传的程序信息中的程序名称,后续用户在函数计算平台上可以通过这个程序名称来调用这程序的所有程序文件,这样减少查找多个程序文件的时间,提高程序加载效率,提高函数计算平台的性能。当用户上传的程序的文件数量是单个,而且代码语言是脚本语言,则直接将程序转换为base64格式存储在数据库中,这是由于脚本语言不用编译,直接转化为base64格式可以减少压缩也解压的过程,不同的程序根据实际情况采用不同的存取方式可以提高程序加载效率,提高函数计算平台的性能,而且最终格式转换为base64格式,base64就是一种基于64个可打印字符来表示二进制数据的方法,还可以节约存储空间。
参照图2,本申请一实施例中还提供了一种提高程序加载效率的装置,包括:
第一检测模块1,用于当第一程序被调用时,检测第一程序是否存放在缓存空间;
第二检测模块2,用于若第一检测模块的检测结果为否,则检测是否存在与第一程序关联的第一数据块,第一数据块记录第一程序的调用计数、程序名称和调用时间调用计数;
生成模块3,用于若第二检测模块的检测结果为否,则生成与第一程序关联的第一数据块;
第一排序模块4,用于获取存放在缓存空间中的所有第二程序关联的第二数据块,按照预设排序规则将第一数据块和第二数据块进行第一优先级排序;
存放模块5,用于按照第一优先级排序顺序,依次将排序在前的数据块关联的程序存放到缓存空间,其中存放到缓存空间的程序不会溢出缓存,以确定第一程序是否可以预先存放到缓存空间。
在上述第一检测模块1中,函数计算平台在调用程序的时候,都是先检测调用的程序是否存放在缓存空间中,如果程序已存放在缓存空间,则可以直接从缓存空间中调用,提高程序加载效率。
在上述第二检测模块2中若缓存空间中没有存放被调用的程序,则可以考虑被调用的程序是第一次调用还是之前有调用过但是没有达到存放在缓存空间的条件,所以检测是否存在与被调用程序关联的数据块来判断是上述的哪种情况,而设置的与程序关联的数据块是用来记录程序被函数计算平台调用频率的数据结构。如数据块可以通过语句{count:5,function:aaa,timestamp:20181029120159}来表示,其中,count表示调用计数、function表示程序名称,timestamp表示调用时间,上面的数据块记录的意思是程序名称为“aaa”的程序被调用了5次,最近一次调用时间是2018年10月29日12点1分59秒。
在上述生成模块3中,若被调用的程序没有关联的数据块,则可以确定该被调用的程序是第一次调用,则生成与该程序关联的数据块,后续可以判断该程序是否可以存放到缓存空间。
在上述第一排序模块4中,要判断被调用的程序是否可以存放在缓存空间,只需要和已存放到缓存空间中的所有程序进行比较即可,因此获取缓存空间中所有程序关联的数据块,由于数据块是与程序关联的,按照预定规则将被调用程序关联的数据块和在缓存空间中的程序关联的据块进行优先级排序,目的也是对被调用的程序和在缓存空间中的所有程序进行优先级排序,数据块优先级 排序顺序即对应程序的优先级排序顺序,排在前面的程序相对于排在后面的程序来说优先级是比较高的,即比较重要的或是调用频繁的。
在上述存放模块5中,如排在前面的程序优先级相对比较高、调用相对比较频繁,程序过去被调用多次,那么将来被调用的频率也更好,因此根据数据块优先级排序顺序,依次将排在前面的数据块对应的程序预先存放到缓存空间中,具体将排在前面的多少个程序加载到缓存空间,这要看具体的缓存空间是多少来决定,其中存放到缓存空间的程序不会溢出缓存,如缓存空间在存放到100个程序后,缓存空间满了,那么就是将第一优先级排序一至一百的数据块对应的程序预先存放到缓存空间,前一百个数据块对应程序相对于排在后面的程序来说都是优先级高的,调用频繁的,有较大的可能会经常使用到,如果被调用的程序关联的数据块刚好排在一百以内,则被调用的程序可以存放到缓存空间,函数计算平台在调用程序的时候,对于调用已经在缓存空间中的程序,即优先级高的程序,可以直接在缓存空间中调用,而无需要再从数据库查询调用程序,减少函数计算平台调用程序的步骤,能节约调用时间,同时避免优先级很低、相对不重要的程序也要进行存放到缓存空间、或可能替换缓存空间中的程序的操作,提高程序加载的效率,提高函数计算平台的性能。
进一步地,还包括:
第一更新模块,若第一检测模块的检测结果为是,则将第一数据块中的调用计数加一,并且更新调用时间。
在上述第一更新模块中,若被调用的程序在缓存空间,则函数计算平台可以直接在缓存空间调用程序,同时由于被调用的程序在缓存空间,则可以说明该程序是有关联的第一数据块的,在调用该程序的时候,要同时更新该程序关联的数据块,如数据块是{count:5,function:aaa,timestamp:20181029120159},下一次名为“aaa”的程序再被函数计算平台调用,则调用计数count加1,即调用计算count变成6,而调用时间timestamp更新为最新的调用时间,而且该程序已经存放在缓存空间,再次调用也不会更换存放在缓存空间中的其他程序,因此更新数据块的记录内容之后不需要进行数据块的优先级排序。
进一步地,还包括:
第二更新模块,若第二检测模块的检测结果为是,则将第一数据块中的调用计数加一,并且更新调用时间;
第二排序模块,用于获取第二数据块,重新根据预设规则将第一数据块和 第二数据块进行第二优先级排序;
替换模块,用于按照第二优先级排序顺序,依次将排序在前的数据块关联的程序存放到缓存空间,其中存放到缓存空间的程序不会溢出缓存,判断第一程序是否需要替换第二程序。
在本实施例中,程序在调用时,存在与其关联的数据块,那么说明该程序之前被调用过,但是没有达到存放在缓存空间的优先级条件,在检测到程序被调用后,需要更新与其关联的数据块,然后获取所有在缓存空间的程序关联的数据块,重新根据预设排序规则将被调用程序的数据块和所有存放在缓存空间中程序关联的数据块进行优先级排序,目的是根据数据块排序找出相对优先级高的、重要的对应的程序,以调整程序的相对优先级,优先级排序排在前面的数据块关联的程序调用比较频繁、相对优先级比较高,这是因为程序过去被调用多次,那么将来被调用的频率也更好,重新按照优先级排序顺序,依次将排序在前的数据块关联的程序存放到缓存空间,其中存放到缓存空间的程序不会溢出缓存,以确定被调用的程序能否存放在缓存空间,即被调用的程序能否替换已存放在缓存空间中的某个程序,以保证存放到缓存空间的程序都是调用比较频繁的,都是相对优先级比较高的,函数计算平台经常调用上述程序可以省去在数据库的查找调用的时间,提高程序的加载效率。
进一步地,在生成模块3中,包括:
判断子模块,用于判断第一程序是否满足预设条件;
生成子模块,用于若判断子模块的判断结果为是,则获取第一程序的调用计数、程序名称和调用时间,以生成与第一程序关联的第一数据块,其中调用计数默认为一。
在本实施例中,由于缓存空间容量有限,不可能每个程序都预先存放到缓存空间中,通过预设条件,限定可以预先存放到缓存空间中的程序,有必要的程序在其被第一次调用的时候,才会去获取程序的调用计数、程序名称和调用时间,以生成与其关联的数据块,当然由于是第一次调用,所以调用计数默认为一,程序生成与其关联的数据块才会参与优先级排序,以判断程序是否需要预先存放到缓存空间,对不符合要求的程序则不生成与其关联的数据块,不参与排序,也就不会预先存放到缓存空间,避免不符合预设条件的程序也要进行存放到缓存空间、或可能替换缓存空间的程序的操作,提高程序加载的效率,提高函数计算平台的性能。
进一步地,在判断子模块中,包括:
第一判断单元,用于判断第一程序的文件大小是否小于预设阈值;
第二判断单元,用于若第一判断单元的判断结果为是,则判断第一程序是否被用户标记为重要;
判定单元,用于若第二判断单元的判断结果为是,则判定第一程序满足预设条件。
在本实施例中,由于缓存空间的空间有限,程序如果太大,则不适合存放到缓存空间中,程序的文件大小的阈值为人为设定,如将阈值设定为100MB,即当程序的文件大小小于100Mb的时候才适合存放到缓存空间中。其次,当该程序被用户设置为重要、性能级别要求高的情况下,用户主观有使用程序的需求,这个标记可以在用户上传程序的时候在函数计算平台上进行标记,函数计算平台上设有重要标记勾选功能。当程序满足以上两种条件的情况下,判断程序满足预设条件,生成与程序关联数据块,可以进行优先级排序。
进一步地,在第一排序模块4中,包括:
排序子模块,用于根据调用计数从大到小将数据块依次排序,其中若有调用计数相同的数据块,则根据调用时间按时间降序排序。
在上述排序子模块中,预设的规则主要根据程序的历史访问频率来确定数据块的排序,排序的实现方式可以如下:每个数据块都有一个调用计数,根据调用计数从大到小将数据块依次排序的时候,如果遇到调用计数相同的数据块则获取调用时间,根据调用时间按时间降序排序,即调用时间早的数据块排在调用时间晚的数据块后面,然后调用时间早的继续根据调用计数与其他数据块排序,以最终完成数据块的优先级排序,调用时间早的数据块排在调用时间晚的数据块后面的理由是因为它等待了更长的时间都没有等来第二次调用,从概率上讲,它下次被调用的几率会小一些。也可以是另一种排序实现方式:根据调用计数从大到小将数据块依次排序,如果遇到调用计数相同的数据块则先默认排在该数据块前面,待数据块按照调用计数从大到小排序完之后,再将具有相同引用的数据块按照调用时间排序,调用时间早的数据块排在调用时间晚的数据块后面,最终完成数据块的排序。
进一步地,还包括:
接收模块,用于接收用户上传的第一程序和程序信息,程序信息包程序名称、代码语言、文件类型和文件数量;
存储模块,用于根据程序信息按照预设存储规则将第一程序存储在数据库中。
在本实施例中,要使用函数计算平台,用户首先要将编写好的程序上传到函数计算平台中并保存,在用户上传程序时会在函数计算平台上输入上传程序的程序信息,待用户确定后,函数计算平台接收用户上传的程序信息,根据存储规则依次判断代码语言是脚本语言还是非脚本语言,文件数量是多个还是单个,文件类型是压缩包还是非压缩包,以确定要执行的存储步骤,储存的文件根据接收的程序名称命名,预设存储规则可以将代码语言、文件类型、文件数量等存储在一列表中,列表可以如表1-1。
若程序功能比较复杂,需要多个程序文件来一起完成,用户将多个程序文件上传后,函数计算平台接收的程序信息为代码语言是脚本语言、文件数量是多个、文件类型是非压缩包,通过接收的程序信息在存储规则表中查询到要先打包压缩,再转化为base64格式,则函数计算平台将用户上传的多个程序文件打包压缩形成一个整体,再转化为base64格式后存储在数据库中,针对这整体文件设置一个程序名称,设置的程序名称也是通过用户上传的程序信息中程序名称,后续用户在函数计算平台上可以通过这个程序名称来调用这程序的所有程序文件,这样减少查找多个程序的时间,提高程序加载效率,提高函数计算平台的性能。当用户上传的程序的文件数量是单个,而且代码语言是脚本语言,则直接将程序文件转换为base64格式存储在数据库中,这是由于脚本语言不用编译,直接转化为base64格式可以减少压缩也解压的过程,不同的程序根据实际情况采用不同的存取方式可以提高程序加载效率,提高函数计算平台的性能,而且最终格式转换为base64格式,base64就是一种基于64个可打印字符来表示二进制数据的方法,还可以节约存储空间。
参照图3,本申请实施例中还提供一种计算机设备,该计算机设备可以是服务器,其内部结构可以如图3所示。该计算机设备包括通过系统总线连接的处理器、存储器、网络接口和数据库。其中,该计算机设计的处理器用于提供计算和控制能力。该计算机设备的存储器包括非易失性存储介质、内存储器。该非易失性存储介质存储有操作系统、计算机可读指令和数据库。该内存储器为非易失性存储介质中的操作系统和计算机可读指令的运行提供环境。该计算机设备的数据库用于存储配置项信息等数据。该计算机设备的网络接口用于与外部的终端通过网络连接通信。该计算机可读指令被处理器执行时执行如上述 各方法的实施例的流程。本领域技术人员可以理解,图3中示出的结构,仅仅是与本申请方案相关的部分结构的框图,并不构成对本申请方案所应用于其上的计算机设备的限定。
本申请一实施例还提供一种计算机可读存储介质,该可读存储介质可以是非易失性可读存储介质,也可以是易失性可读存储介质,其上存储有计算机可读指令,计算机可读指令被处理器执行时,执行如上述各方法的实施例的流程。以上所述仅为本申请的优选实施例,并非因此限制本申请的专利范围,凡是利用本申请说明书及附图内容所作的等效结构或等效流程变换,或直接或间接运用在其他相关的技术领域,均同理包括在本申请的专利保护范围内。

Claims (20)

  1. 一种提高程序加载效率的方法,其特征在于,包括:
    当第一程序被调用时,检测所述第一程序是否存放在缓存空间;
    若不在缓存空间,则检测是否存在与所述第一程序关联的第一数据块,所述第一数据块记录所述第一程序的调用计数、程序名称和调用时间;
    若不存在所述第一数据块,则生成与所述第一程序关联的所述第一数据块;
    获取存放在缓存空间中的所有第二程序关联的第二数据块,按照预设排序规则将所述第一数据块和所述第二数据块进行第一优先级排序;
    按照第一优先级排序顺序,依次将排序在前的数据块关联的程序存放到缓存空间,其中存放到缓存空间的程序不会溢出缓存,以确定所述第一程序是否可以预先存放到缓存空间。
  2. 根据权利要求1所述的提高程序加载效率的方法,其特征在于,所述生成与所述第一程序关联的所述第一数据块的步骤中,包括:
    判断所述第一程序是否满足预设条件;
    若满足预设条件,则获取所述第一程序的所述调用计数、所述程序名称和所述调用时间,以生成与所述第一程序关联的所述第一数据块,其中所述调用计数默认为一。
  3. 根据权利要求2所述的提高程序加载效率的方法,其特征在于,所述判断所述第一程序是否满足预设条件的步骤中,包括:
    判断所述第一程序的文件大小是否小于预设阈值;
    若小于预设阈值,则判断所述第一程序是否被用户标记为重要;
    若标记为重要,则判定所述第一程序满足所述预设条件。
  4. 根据权利要求1所述的提高程序加载效率的方法,其特征在于,所述按照预设排序规则将所述第一数据块和所述第二数据块进行第一优先级排序的步骤中,包括:
    根据所述调用计数从大到小将数据块依次排序,其中若有所述调用计数相同的数据块,则根据所述调用时间按时间降序排序。
  5. 根据权利要求1所述的提高程序加载效率的方法,其特征在于,检测是否存在与所述第一程序关联的第一数据块的步骤之后,还包括:
    若存在所述第一数据块,则将所述第一数据块中的所述调用计数加一,并且更新所述调用时间;
    获取所述第二数据块,重新根据所述预设规则将所述第一数据块和所述第二数据块进行第二优先级排序;
    按照第二优先级排序顺序,依次将排序在前的数据块关联的程序存放到缓存空间,其中存放到缓存空间的程序不会溢出缓存,判断所述第一程序是否可以替换所述第二程序。
  6. 根据权利要求1所述的提高程序加载效率的方法,其特征在于,所述获取存放在缓存空间中的所有第二程序关联的第二数据块的步骤之前,还包括:
    判断缓存空间是否足够存放所述第一程序;
    若足够存放,则将所述第一程序存放到缓存空间;
    若不足够存放,则获取存放在缓存空间中的所有第二程序关联的第二数据块。
  7. 根据权利要求1所述的提高程序加载效率的方法,其特征在于,所述当第一程序被调用时,检测所述第一程序是否存放在缓存空间的步骤之后,还包括:
    若在缓存空间,则将所述第一数据块中的所述调用计数加一,并且更新所述调用时间。
  8. 一种提高程序加载效率的装置,其特征在于,包括:
    第一检测模块,用于当第一程序被调用时,检测所述第一程序是否存放在缓存空间;
    第二检测模块,用于若第一检测模块的检测结果为否,则检测是否存在与所述第一程序关联的第一数据块,所述第一数据块记录所述第一程序的调用计数、程序名称和调用时间调用计数;
    生成模块,用于若第二检测模块的检测结果为否,则生成与所述第一程序关联的所述第一数据块;
    第一排序模块,用于获取存放在缓存空间中的所有第二程序关联的第二数据块,按照预设排序规则将所述第一数据块和所述第二数据块进行第一优先级排序;
    存放模块,用于按照第一优先级排序顺序,依次将排序在前的数据块关联的程序存放到缓存空间,其中存放到缓存空间的程序不会溢出缓存,以确定所述第一程序是否可以预先存放到缓存空间。
  9. 根据权利要求8所述的提高程序加载效率的装置,其特征在于,所述 装置还包括:
    第一更新模块,用于若所述第一检测模块的检测结果为是,则将所述第一数据块中的所述调用计数加一,并且更新所述调用时间。
  10. 根据根据权利要求8所述的提高程序加载效率的装置,其特征在于,所述装置还包括:
    第二更新模块,用于若第二检测模块的检测结果为是,则将所述第一数据块中的所述调用计数加一,并且更新所述调用时间;
    第二排序模块,用于获取所述第二数据块,重新根据所述预设规则将所述第一数据块和所述第二数据块进行第二优先级排序;
    替换模块,用于按照第二优先级排序顺序,依次将排序在前的数据块关联的程序存放到缓存空间,其中存放到缓存空间的程序不会溢出缓存,判断所述第一程序是否可以替换所述第二程序。
  11. 根据权利要求8所述的提高程序加载效率的装置,其特征在于,所述生成模块,包括:
    判断子模块,用于判断所述第一程序是否满足预设条件;
    生成子模块,用于若判断子模块的判断结果为是,则获取所述第一程序的所述调用计数、所述程序名称和所述调用时间,以生成与所述第一程序关联的所述第一数据块,其中所述调用计数默认为一。
  12. 根据权利要求11所述的提高程序加载效率的装置,其特征在于,所述判断子模块包括:
    第一判断单元,用于判断所述第一程序的文件大小是否小于预设阈值;
    第二判断单元,用于若第一判断单元的判断结果为是,则判断所述第一程序是否被用户标记为重要;
    判定单元,用于若第二判断单元的判断结果为是,则判定所述第一程序满足所述预设条件。
  13. 根据权利要求8所述的提高程序加载效率的装置,其特征在于,所述第一排序模块包括:
    排序子模块,用于根据所述调用计数从大到小将数据块依次排序,其中若有所述调用计数相同的数据块,则根据所述调用时间按时间降序排序。
  14. 根据权利要求8所述的提高程序加载效率的装置,其特征在于,所述装置还包括:
    接收模块,用于接收用户上传的所述第一程序和程序信息,程序信息包程序名称、代码语言、文件类型和文件数量;
    存储模块,用于根据所述程序信息按照预设存储规则将所述第一程序存储在数据库中。
  15. 一种计算机设备,包括存储器和处理器,所述存储器中存储有计算机可读指令,其特征在于,所述处理器执行时实现提高程序加载效率的方法,该方法包括:
    当第一程序被调用时,检测所述第一程序是否存放在缓存空间;
    若不在缓存空间,则检测是否存在与所述第一程序关联的第一数据块,所述第一数据块记录所述第一程序的调用计数、程序名称和调用时间;
    若不存在所述第一数据块,则生成与所述第一程序关联的所述第一数据块;
    获取存放在缓存空间中的所有第二程序关联的第二数据块,按照预设排序规则将所述第一数据块和所述第二数据块进行第一优先级排序;
    按照第一优先级排序顺序,依次将排序在前的数据块关联的程序存放到缓存空间,其中存放到缓存空间的程序不会溢出缓存,以确定所述第一程序是否可以预先存放到缓存空间。
  16. 根据权利要求15所述的计算机设备,其特征在于,所述处理器执行所述生成与所述第一程序关联的所述第一数据块的步骤,包括:
    判断所述第一程序是否满足预设条件;
    若满足预设条件,则获取所述第一程序的所述调用计数、所述程序名称和所述调用时间,以生成与所述第一程序关联的所述第一数据块,其中所述调用计数默认为一。
  17. 根据权利要求16所述的计算机设备,其特征在于,所述处理器执行所述判断所述第一程序是否满足预设条件的步骤,包括:
    判断所述第一程序的文件大小是否小于预设阈值;
    若小于预设阈值,则判断所述第一程序是否被用户标记为重要;
    若标记为重要,则判定所述第一程序满足所述预设条件。
  18. 一种计算机可读存储介质,其上存储有计算机可读指令,其特征在于,所述计算机可读指令被处理器执行时实现提高程序加载效率的方法,其特征在于,所述方法包括:
    当第一程序被调用时,检测所述第一程序是否存放在缓存空间;
    若不在缓存空间,则检测是否存在与所述第一程序关联的第一数据块,所述第一数据块记录所述第一程序的调用计数、程序名称和调用时间;
    若不存在所述第一数据块,则生成与所述第一程序关联的所述第一数据块;
    获取存放在缓存空间中的所有第二程序关联的第二数据块,按照预设排序规则将所述第一数据块和所述第二数据块进行第一优先级排序;
    按照第一优先级排序顺序,依次将排序在前的数据块关联的程序存放到缓存空间,其中存放到缓存空间的程序不会溢出缓存,以确定所述第一程序是否可以预先存放到缓存空间。
  19. 根据权利要求18所述的计算机可读存储介质,其特征在于,所述处理器执行所述生成与所述第一程序关联的所述第一数据块的步骤,包括:
    判断所述第一程序是否满足预设条件;
    若满足预设条件,则获取所述第一程序的所述调用计数、所述程序名称和所述调用时间,以生成与所述第一程序关联的所述第一数据块,其中所述调用计数默认为一。
  20. 根据权利要求19所述的计算机可读存储介质,其特征在于,所述处理器执行所述判断所述第一程序是否满足预设条件的步骤,包括:
    判断所述第一程序的文件大小是否小于预设阈值;
    若小于预设阈值,则判断所述第一程序是否被用户标记为重要;
    若标记为重要,则判定所述第一程序满足所述预设条件。
PCT/CN2019/118166 2019-04-19 2019-11-13 提高程序加载效率的方法、装置、计算机设备和存储介质 WO2020211363A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910319067.4A CN110147258B (zh) 2019-04-19 2019-04-19 提高程序加载效率的方法、装置、计算机设备和存储介质
CN201910319067.4 2019-04-19

Publications (1)

Publication Number Publication Date
WO2020211363A1 true WO2020211363A1 (zh) 2020-10-22

Family

ID=67588544

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/118166 WO2020211363A1 (zh) 2019-04-19 2019-11-13 提高程序加载效率的方法、装置、计算机设备和存储介质

Country Status (2)

Country Link
CN (1) CN110147258B (zh)
WO (1) WO2020211363A1 (zh)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110147258B (zh) * 2019-04-19 2022-08-16 平安科技(深圳)有限公司 提高程序加载效率的方法、装置、计算机设备和存储介质
CN111596966A (zh) * 2020-04-27 2020-08-28 五八有限公司 一种子应用加载方法及装置
CN117311595A (zh) * 2022-06-23 2023-12-29 华为技术有限公司 数据处理方法、处理器、计算设备及装置

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6934699B1 (en) * 1999-09-01 2005-08-23 International Business Machines Corporation System and method for loading a cache with query results
CN108549556A (zh) * 2018-04-16 2018-09-18 腾讯科技(深圳)有限公司 一种应用程序加速方法、装置、终端及存储介质
CN110147258A (zh) * 2019-04-19 2019-08-20 平安科技(深圳)有限公司 提高程序加载效率的方法、装置、计算机设备和存储介质

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5212794A (en) * 1990-06-01 1993-05-18 Hewlett-Packard Company Method for optimizing computer code to provide more efficient execution on computers having cache memories
CN102541602A (zh) * 2011-12-28 2012-07-04 用友软件股份有限公司 界面的预加载装置和预加载方法
WO2013101138A1 (en) * 2011-12-30 2013-07-04 Intel Corporation Identifying and prioritizing critical instructions within processor circuitry
US9268573B2 (en) * 2012-11-02 2016-02-23 Michael Rolle Methods for decoding and dispatching program instructions
US9244827B2 (en) * 2013-09-25 2016-01-26 Intel Corporation Store address prediction for memory disambiguation in a processing device
CN107872523B (zh) * 2017-11-07 2020-04-17 Oppo广东移动通信有限公司 网络数据的加载方法、装置、存储介质及移动终端
CN109542530A (zh) * 2018-10-26 2019-03-29 深圳点猫科技有限公司 一种基于小程序架构的分级加载方法及装置

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6934699B1 (en) * 1999-09-01 2005-08-23 International Business Machines Corporation System and method for loading a cache with query results
CN108549556A (zh) * 2018-04-16 2018-09-18 腾讯科技(深圳)有限公司 一种应用程序加速方法、装置、终端及存储介质
CN110147258A (zh) * 2019-04-19 2019-08-20 平安科技(深圳)有限公司 提高程序加载效率的方法、装置、计算机设备和存储介质

Also Published As

Publication number Publication date
CN110147258B (zh) 2022-08-16
CN110147258A (zh) 2019-08-20

Similar Documents

Publication Publication Date Title
WO2020211363A1 (zh) 提高程序加载效率的方法、装置、计算机设备和存储介质
US7721288B2 (en) Organizing transmission of repository data
RU2663358C2 (ru) Устройство и способ кластерного хранения
US8005794B2 (en) Mechanism for data aggregation in a tracing framework
CN111367925A (zh) 数据动态实时更新方法、装置及存储介质
US9930113B2 (en) Data retrieval via a telecommunication network
CN107967135A (zh) 计算引擎实现方法、电子装置及存储介质
CN108536745B (zh) 基于Shell的数据表提取方法、终端、设备及存储介质
JP2007183916A (ja) モバイル機器におけるフォーム自動入力のための方法および装置
KR20230093420A (ko) 데이터 세트 및 노드 캐시 기반의 스케줄링 방법 및 장치
EP2674868A1 (en) Database update notification method
CN111198856A (zh) 文件管理方法、装置、计算机设备和存储介质
CN115617762A (zh) 文件存储方法及设备
CN108415998B (zh) 应用依赖关系更新方法、终端、设备及存储介质
CN113553339A (zh) 数据查询方法、中间件、电子装置和存储介质
CN111488736A (zh) 自学习分词方法、装置、计算机设备和存储介质
US10606805B2 (en) Object-level image query and retrieval
US11514236B1 (en) Indexing in a spreadsheet based data store using hybrid datatypes
CN112860736A (zh) 大数据查询优化方法、设备及可读存储介质
US11244000B2 (en) Information processing apparatus and non-transitory computer readable medium storing program for creating index for document retrieval
US7441252B2 (en) Cache control device, and method and computer program for the same
US9659041B2 (en) Model for capturing audit trail data with reduced probability of loss of critical data
US10235432B1 (en) Document retrieval using multiple sort orders
WO2021088686A1 (zh) 编译优化信息生成方法、装置及电子设备
US9256634B2 (en) Resuming big data transformations

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: 19925032

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 19925032

Country of ref document: EP

Kind code of ref document: A1