SYSTEM AND METHOD FOR RUNTIME ADAPTABLE APPLICATIONS
20190377560 ยท 2019-12-12
Inventors
Cpc classification
G06F9/44505
PHYSICS
International classification
Abstract
A platform host for deploying a runtime adaptable application has in-line application scope parameters and is capable of interacting with code selection logic when executed. The platform host includes one or more processors coupled to a non-transitory processor-readable storage medium having processor-executable instructions that, when executed by the processor, cause the platform host to: instantiate the code selection logic in an execution platform, the code selection logic being based, at least in part, on the in-line application scope parameters; determine values of platform configuration parameters at runtime, and execute the runtime adaptable application based on the code selection logic and the values of the platform configuration parameters.
Claims
1. A platform host for deploying a runtime adaptable application, which has in-line application scope parameters and is capable of interacting with code selection logic when executed, the platform host comprising one or more processors coupled to a non-transitory processor-readable storage medium having processor-executable instructions that, when executed by the processor, cause the platform host to: instantiate the code selection logic in an execution platform, the code selection logic being based, at least in part, on the in-line application scope parameters; determine values of platform configuration parameters at runtime, and execute the runtime adaptable application based on the code selection logic and the values of the platform configuration parameters.
2. The platform host according to claim 1, wherein the application scope parameters are based on one or more of syntax constructs or annotations.
3. The platform host according to claim 1, wherein the combination of at least two of the in-line application scope parameters, the code selection logic, and the values of the platform configuration parameters correspond to at least one runtime state.
4. The platform host according to claim 1, wherein the runtime adaptable application has at least one conditional program flow having at least one alternative function that is dependent on a triggering runtime state, and wherein, when executed by the processor, the processor-executable instructions cause the platform host to execute the at least one alternative function when the triggering runtime state is determined based on the code selection logic and the values of the platform configuration parameters.
5. An engine for a runtime adaptable application, the engine comprising: a compiler configured to analyze an input program, which has application logic defining alternative functions associated with a functionality and in-line function metadata associated with the alternative functions, and to generate the runtime adaptable application based on the input program.
6. The engine according to claim 5, wherein the in-line function metadata comprises at least one of hints about implementation or conditional performance of each of the alternative functions.
7. The engine according to claim 5, wherein the application logic does not include calls to the plurality of alternative functions nor selection logic for selecting from among the alternative functions.
8. The engine according to claim 5, further comprising an option scoring library configured to evaluate the alternative functions based on the in-line function metadata and determine a score for each of the alternative functions, wherein the compiler is configured to generate the runtime adaptable application with a call to the engine to determine how to implement the functionality based on the score for each of the alternative functions.
9. The engine according to claim 8, wherein the compiler comprises a code generation template library having code for inclusion in the runtime adaptable application, the code having references to the option scoring library, and wherein the compiler is configured to determine whether to include a particular piece of code from the code generation template library in the runtime adaptable application based on the input program.
10. The engine according to claim 9 further comprising an option invocation mechanism, wherein the code of the code generation template library has references to the option invocation mechanism, wherein the compiler is configured to generate the runtime adaptable application to include calls to at least one of the option invocation mechanism or the option scoring library, wherein the option invocation mechanism is configured to receive a call from a host executing the runtime adaptable application, and wherein the engine is configured to determine the score of each of the alternative functions, select a function of the alternative functions having the highest score, and implement the function selected in response to receiving the call.
11. The engine according to claim 10, wherein the option scoring library is configured to select the option with a highest score, evaluated at runtime, based on the in-line function metadata and runtime values associated with a platform executing the runtime adaptable application,
12. The engine according to claim 5, wherein the compiler is configured select one of the alternative functions to implement the functionality using dynamic dependency injection.
13. The engine according to claim 5, wherein the compiler comprises an annotations and syntax library which defines metadata for use as the in-line function metadata, the annotations and syntax library providing descriptions of criteria for use in evaluating the alternative functions at runtime.
14. The engine according to claim 5, wherein the engine is part of an application developer's development environment.
15. The engine according to claim 5, wherein the engine is part of a host, hosting an execution platform that is configured to execute the runtime adaptable application.
Description
BRIEF DESCRIPTION OF THE DRAWINGS
[0009] The present invention will be described in even greater detail below based on the exemplary figures. The invention is not limited to the exemplary embodiments. All features described and/or illustrated herein can be used alone or combined in different combinations in embodiments of the invention. The features and advantages of various embodiments of the present invention will become apparent by reading the following detailed description with reference to the attached drawings which illustrate the following:
[0010]
[0011]
[0012]
[0013]
[0014]
[0015]
DETAILED DESCRIPTION
[0016] Embodiments of the present invention provide methods for generating applications that can be seamlessly adapted at runtime. Embodiments can include multi-option functionalities and can be forced to execute at runtime those options that are selected by logic of the hosting execution environment. Embodiments also provide new programming syntax elements and annotations, as well as an engine that auto-generates code for the option selection logic; thus eliminating the need for an application developer to write option selection logic. The present invention thereby reduces development effort and enables more fine-grained runtime performance optimization by the application hosting platform as compared to other approaches.
[0017] To help illustrate aspects of embodiments of the present invention, consider
[0018] Here, there can be a series of conditional program flows for the software application 101, as well as a series of (potentially unknown to the developer) external factors that might determine the most efficient combination of program flows. Furthermore, these associations might be completely different depending on where the application is running (which is also unknown to the application developer).
[0019] Table I includes a few examples of runtime state parameters and the implications that these state parameters could have, depending both on the PaaS system and the application itself.
TABLE-US-00001 TABLE I Example runtime states and their possible implications: Runtime State Possible Problem Possible Adaptation CPU overload Update sent too Use rule-based instead of artificial of server late to vehicle. intelligence (AI)-based data (actual or processing. predicted). Huge crowd in Certain Deactivate video data and only use an area. algorithms radio frequency (RF)-based crowd become estimation. inefficient or too resource- consuming. AI accelerator CPU based Use shallow learning algorithm (GPU or computation is too instead of deep learning to process dedicated slow to adhere to video frames. ASIC) not latency available on requirements. host. Limited Video frames arrive First request video resolution bandwidth on delayed and cannot reduction. If this is not wireless be processed in enough to keep latency network time. requirements, use sub-sampling to link to street reduce bandwidth usage further. cameras due to interference. Memory on Application process Less memory-intensive options are host is becomes too slow used for the currently used exhausted. due to exhaustive programs and algorithms swapping to disk.
[0020]
[0021] The developer defined system 200 of
[0022] The application 210 is designed to run on (be deployed at) a host 220. The host 220 can be, for example, a cloud or edge computer node. The host 220 can run other applications 211 as well as the application 210. The host 220 can include an execution platform 222 and host configuration 224. A system-wide controller 230 configures the host, which can occur post-deployment, at runtime. The system-wide controller 230 may be an edge computing orchestrator.
[0023]
[0024] According to this model, configuration parameters, on which the choice of the program flow will depend, are defined in the scope of the application 210 and/or in the scope of the platform 222 (e.g., selectBasedOnAppAndHostConfigurationO). For example, the developer may provide the application configuration 214 and the system-wide controller 230 may provide the host configuration as the configuration parameters. The combination of the values of these parameters correspond to different runtime states.
[0025] The application developer 201 prepares code selection logic (CODE_SELECTION_LOGIC), which defines how the program flow depends on the configuration parameters. Alternative program flows can be also parametrized (via the input argument), so that the value of input can also be affected by the CODE_SELECTION_LOGIC (i.e. practically leading to more than three alternatives in the example shown).
[0026] The application logic 212 is packaged together with its CODE_SELECTION_LOGIC as the application 210, and the application 210 is deployed on the host 220 (e.g., the host of the PaaS) for execution. The application 210 may also include the application configuration 214 as part of the package.
[0027] The host 220 (which deploys the application 210) and the values of the host configuration parameters 224 can change at runtime. Depending on the deployment and the state of the configuration parameters, the CODE_SELECTION_LOGIC can make different decisions, which can lead to different program flows each time the application 210 is executed.
[0028] Implementing highly adaptable software applications in the way described in connection with
[0029] Therefore, this model becomes inefficient and difficult to implement when the possible runtime states and their implications are complex or unknown to the software application developer. This, in turn, leads to software applications being implemented with either a low degree of adaptability or with wrong or inefficient logic for selecting among the possible program flows (or modes).
[0030] In contrast to the model of
[0031] Embodiments of the present invention provide selection logic (i.e., the logic that determines how the program flow and the runtime function parameters depend on runtime states) that is exported to the platform without the application developer having to know anything about this logic or any respective application programming interfaces (APIs) of the platform.
[0032]
[0033] The adaptable application system 300 of
[0034] The adaptable application system 300 also includes a host 320 and a system-wide controller 330. The system-wide controller 330 may be an edge computing orchestrator that configures (e.g., configures post-deployment) the host 320. The host 320 may be a cloud or edge computer node. The host 320 runs the adaptable application 310, and can run other applications 311. The host includes an execution platform 322 and host configuration parameters 324. The applications 310, 311 are executed on the execution platform 322.
[0035] In the adaptable application system 300, some configuration parameters on which the choice of the program flow will depend are defined in the scope of the platform (e.g., the particular execution platform 322 executing the adaptable application 310). In embodiments, the application-scope parameters are provided in-line next to the respective code parts. For example, as shown in
[0036] The in-line application-scope parameters are based on syntax constructs or annotations. Annotations and syntax constructs can be used to code functions that have multiple options and to describe some criteria that will be used for the evaluation of the options at runtime. The introduction of programming syntax elements and annotations that allow for the definition and usage of multi-option functions in a way that the selection logic (for selecting among the options) is seamlessly exported from the application to the hosting platform. The use of annotations and syntax constructs of embodiments of the invention drastically simplifies the configuration-related program parts of the application. The combinations of the values of these parameters correspond with different runtime states.
[0037] A platform developer (which may be distinct from the application developer) provides code selection logic (CODE_SELECTION_LOGIC) that defines the way in which the program flow depends on the configuration parameters. The platform developer (and CODE_SELECTION_LOGIC) can exploit the in-line application developer hints (e.g., as inferred by the annotations and syntax constructs). The CODE_SELECTION_LOGIC is included in the execution platform 322 on the host 320.
[0038] In embodiments, the adaptable application 310 is packaged without any CODE_SELECTION_LOGIC and deployed on the host 320 (e.g., the host of the PaaS) for execution. The adaptable application 310 is able to interact with the CODE_SELECTION_LOGIC module in the execution platform 322 of the host 320. The CODE_SELECTION_LOGIC module can be pluggable and potentially different for every host.
[0039] The host of the application and the values of the platform configuration parameters can change at runtime, which causes the CODE_SELECTION_LOGIC to make different decisions and can lead to different program flows each time the adaptable application 311 is executed.
[0040] Alternative program flows can be also parametrized so that the value of the input of the alternative functions can also be set by the CODE_SELECTION_LOGIC (i.e. leading to additional alternative program flows). In embodiments, this parametrization can be also done by the platform logic (e.g., execution platform 322) based on the runtime states.
[0041] The example adaptable application 310 shown in
[0042] For each of the three alternative functions, the developer 301 includes in-line application-scope parameters that are based on syntax constructs or annotations. As shown in
[0043] The adaptable application 310 is packaged for deployment at a host 320. While the adaptable application system 300 illustrates a single host 320, embodiments of the present invention are not so limited and can included multiple hosts. Indeed, the conditional program flows may be conditioned on features of the particular host (or execution platform) executing the adaptable application 310.
[0044] A platform developer provides code selection logic (CODE_SELECTION_LOGIC) in the execution platform 322 on which the adaptable application 310 is deployed. The CODE_SELECTION_LOGIC defines the way in which the alternative functions doA( ), doB( ), and doC( ) will be executed at runtime. The platform developer can use (exploit) the in-line application developer hints included in the in-line application-scope parameters of the adaptable application logic 312 to construct the CODE SELECTION LOGIC. The CODE SELECTION LOGIC can be different for each host 320 and each deployment of the adaptable application 310.
[0045] The adaptable application 310 is able to interact with the CODE_SELECTION_LOGIC module in the execution platform 322 of the host 320 to execute the conditional program flows based on the CODE_SELECTION_LOGIC, the host configuration 324, and runtime states. That is, depending on the current conditions at runtime and the CODE_SELECTION_LOGIC, a particular one of the alternative functions doA( ); doB( ); or doC( ) is executed by the execution platform 322.
[0046]
[0047]
[0048] The compiler 441 (DivProg Compiler) analyzes an input program and generates an output program that includes conditional statements. For example, the compiler 441 (DivProg Compiler) can analyze a programmed application 405, which is programed by the developer 401, and create a generated application 410 that contains all the required conditional statements. The application logic 404 of the programmed application 405 may be similar to the application logic 312 of the application 310 shown in
[0049] In an embodiment, the programmed application 405 (input program), preferably its application logic 404, contains an abstract function (e.g., doX, here indicated by the @Alt annotation). The abstract function contains no implementation and is used at every position of the code where alternative program flows are possible. Each possible alternative flow, hereinafter called option, is implemented in a separate function, which includes hints about the functionality that it implements (e.g., the same as doX) and some criteria for its selection or not (here indicated by the attributes of the @Option annotation).
[0050] The options are never called inside the programmed application 405 (input program) and there is also no selection logic (i.e., conditional statements) for selecting among the options. This aspect of embodiments provides that options can be added anytime into the programmed application 405 (input program) without the requirement to change any single line of the rest of the programed application logic 404 (input program code) for the new options to be available at runtime.
[0051] The generated application 410 (output program) is enriched by auto-generated implementations of all abstract functions (such as doX in
[0052] The option scoring library 442 includes option scoring logic (OSL) 443 and the OSL's API 444. The option scoring library 442 evaluates options in a generic waythat is without knowing anything about the functionality, the names, the logic, or the semantics of the options-based only on criteria provided as in-line function metadata (such as the attributes of the @Option annotation) and on runtime values of platform parameters.
[0053] For the option scoring library 442, the OSL API 444 is identical in all DivProg instances of the same system. The OSL 443 of an engine 440 (DivProg Engine) may (but is not required to) use all the metadata provided with an option when it computes the score of the option. The OSL 443 of each engine 442 (DivProg Engine) should assign higher scores to options that are more appropriate to use given the current runtime state. Each execution environment (e.g., execution platform 422) may have a different implementation of the OSL 443.
[0054] In some embodiments, the engine 440 (DivProg Engine) and the generated application 410 can be part of the host 420 (instead of the application developer's development environment as it is shown in
[0055]
[0056] In this embodiment, alternative concrete functions are identified by the in-line annotation @Option. In
[0057] The in-line annotations of embodiments are not limited to identifying options and functionalities. For example, as shown in
[0058] As shown in
[0059] The application logic 409 includes calls to the OSL API 441. These calls are invokable by the host 420 at runtime when the generate application 410 is deployed on the execution platform 422. The DivProg Engine 440 generates these calls based on in-line annotations, libraries, templates, etc.; they are not explicitly provided by the developer in the programmed application 405. In the example shown in
[0060] According to embodiments, the option scoring library 442 can be different when implemented on the host 420 as compared to when implemented in the development environment, and can be different depending on which of a plurality of hosts deploying the generated application 410. The option scoring library 442 may receive values from the host configuration 424 to determine which of the alternative functionalities are invoked at runtime. For example, as shown in
[0061] In some embodiments, the generation of code that scans the possible options (as functions) and calls one of them (see also Option Invocation Mechanism discussed in connection with
[0062]
[0063] The engine 540 (DivProg Engine) includes a compiler 541 (DivProg Compiler) and an option scoring library 542. The engine 540 receives a developed application 505 (input program), analyzes the developed application 505, and generates a generated application 510 (an output program) that includes conditional statements.
[0064] In embodiments, the compiler 541 (DivProg Compiler) includes an annotations and syntax library 550, a code parser 552, a templating engine 554, and a code generation template 556. The annotations and syntax library 550 may also include a criteria data model 551. In embodiments, the criteria data model 551 may include criteria parameters or settings used by the annotations and syntax library 550.
[0065] In embodiments, the option scoring library 542 includes option scoring logic (OSL) 543 and an OSL API 544. The OSL 543 may include a criteria data model 560 and scoring functions 562. The criteria data model 560, in embodiments, may include criteria parameters or settings used by the option scoring library 542 together with the logic or algorithms of the scoring functions 562 to provide a score.
[0066] In embodiments, the engine 540 (DivProg Engine) includes an option invocation mechanism (OIM) 570, that includes an OIM library.
[0067]
[0068] At Operation 1, the engine 450 is instantiated with the code generation template 556 for the code that shall be auto-generated (generated application 510) based on the application developer code (developed application 505). The code generation template 556 may be permanent in the compiler 541. The to-be-generated code has references to an Option Invocation Mechanism (OIM) library associated with the OIM 570 (for the runtime invocation of the function that will be evaluated to be most appropriate) and the OSL API 544 (for finding the most appropriate function at runtime, based on host/platform logic).
[0069] In an embodiment, the OIM is reflection. Reflection is used in object-oriented programming for retrieving and using at runtime functions/methods that are not known at compile time. Reflection allows inspection of classes, interfaces, fields and methods at runtime without knowing the names of the interfaces, fields, methods at compile time. It also allows instantiation of new objects and invocation of methods.
[0070] In Operation 2, an application developer uses DivProg annotations and syntax to code functions that have multiple options and to describe criteria that will be used for the evaluation of the options at runtime. In embodiments, the implementations of the options are isolated from the rest of the code, which simply uses the name of the generic functionality at every position where the multi-option function shall be called.
[0071] In Operation 3, the developed application 505 is passed to the code parser 552 (DivProg Code Parser) for analyzing the multi-option functions.
[0072] In Operation 4, the parsing results of the code parser 552 (e.g., list of options, criteria, etc.) and at least one code generation template 556 are passed to the templating engine 554 (the templating engine 554 is a code generator).
[0073] In Operation 5, the code generation result of the templating engine 554 is packaged as the generated application 510 to be deployed on a host/PaaS.
[0074] In Operation 6, the generated application 510 includes auto-generated invocations to the OIM 570 and the OSL API 544. The invocations will take place at runtime, but against the OSL implementation of the host/PaaS, and not that of the development environment.
[0075] According to an embodiment, an implementation of a DivProg Engine may use Annotations @Alt, @Option (with various attributes) for specifying multi-option functionalities and their options, respectively. The DivProg Engine may also use Java Reflection as the OIM library. The DivProg Engine may also use Apache Velocity, a Java Annotation Processor, and a custom code generation program for implementing the code parser and the code generating templating engine.
[0076] As is readily understood from the provided description, embodiments of a system and programming model for developing adaptable applications may be used to implement a variety of software applications. For example, a diversifiable programming model (using a DivProg Engine of embodiments) can implement an application component that detects faces in an image. For such an application, the developer may have provided two different implementations for the face detection functionality: (1) an Open CV based implementation; and (2) a NeoFace based implementation. Here, the developer can include annotations with hints for use by the DivProg Engine to create a run-time adaptable face detection application. Below is an example of code implementing such an application:
TABLE-US-00002 package diversifiableProgramming; import diversifiableProgramming.diversifiableProgrammingSimpleTester.divProgImpl.detectFacesD ivProgImpl; public class diversifiableProgrammingSimpleTester { /** * Detects faces in an image. */ @Alt(functionality=DetectFaces) public byte[ ][ ] DetectFaces(String imgName, double scale) { return detectFacesDivProgImpl.dpDetectFacesImpl(this, imgName, scale); } /** * Detects faces in an image using OpenCV implementation. * @param dynargs * 1. Name of dynamic parameter * 2. Min value of parameter * 3. Max value of parameter * 4. Step size * 5. Min value utility * 6. Mac value utility */ @Option (functionality=DetectFaces, criteria={prefSite=edge, latency=2s, nw=true, security=procPrivateData}, dynargs={scale;480;800;20;10;50}) public byte[ ][ ] detectFacesOpenCV(String imgName, double scale) { } /** * Detects faces in an image using NeoFace implementation. */ @Option(functionality=DetectFaces, criteria={prefSite=edge, latency=2s, nw=false, security=procPrivateData}, dynargs={scale;520;800;20;20;50}) public byte[ ][ ] detectFacesNeoFace(String imgName, double scale) { } }
[0077]
[0078] Embodiments of the present invention provide the introduction of programming syntax elements and annotations that allow for the definition and usage of multi-option functions in a way that the selection logic (for selecting among the options) is seamlessly exported from the application to the hosting platform.
[0079] Embodiments of the present invention provide a method for generating applications that can be seamlessly adapted at runtime. For example the applications can be forced to execute those options of their multi-option functions which are selected by logic of the hosting execution environment.
[0080] Methods of embodiments may include an engine that accepts (as its input) programs in which it is specified (in a machine-readable way) which (concrete) functions are options of which (abstract) functionality. The above information, together with hints about the implementation details or (conditional) performance features of each option, is provided by using programming language constructs (such as annotations) that are reserved for this purpose.
[0081] Methods of embodiments also provide an application development environment, including an engine which generates the executable version of the application, which includes code for searching at runtime among all available options, using an API for evaluating the options, and using an option invocation mechanism to call the option with the highest evaluation.
[0082] The auto-generated application executable being deployed to a host which includes (custom, host-specific) implementations of the functions of the aforementioned API, whereby said implementations use the hints provided by the developer along with any other host configuration parameters and custom host logic in order to evaluate options of multi-option functions.
[0083] The present invention provides advantages and improvements in the area of computer systems, particularly adaptable applications, and more particularly applications that are highly adaptable at runtime. An advantage of embodiments is that they provide a platform that has many options for adapting/configuring applications at runtime. This makes applications highly adaptable and capable of satisfying demanding application performance requirements (e.g., because a developer need not know all runtime states a priori). Another advantage of embodiments is that developers can implement the functionality with less code and simpler code as compared to implementing that same functionality with defined optional flow programs that are defined only pre-deployment or using AOP.
[0084] The present invention also provides a system where the adaptable code is easier to write and is cooperatively written by the application and the platform developer, which is in contrast to the complex approach offered by runtime code replacement.
[0085] While the invention has been illustrated and described in detail in the drawings and foregoing description, such illustration and description are to be considered illustrative or exemplary and not restrictive. It will be understood that changes and modifications may be made by those of ordinary skill within the scope of the following claims. In particular, the present invention covers further embodiments with any combination of features from different embodiments described above and below. Additionally, statements made herein characterizing the invention refer to an embodiment of the invention and not necessarily all embodiments.
[0086] The terms used in the claims should be construed to have the broadest reasonable interpretation consistent with the foregoing description. For example, the use of the article a or the in introducing an element should not be interpreted as being exclusive of a plurality of elements. Likewise, the recitation of or should be interpreted as being inclusive, such that the recitation of A or B is not exclusive of A and B, unless it is clear from the context or the foregoing description that only one of A and B is intended. Further, the recitation of at least one of A, B and C should be interpreted as one or more of a group of elements consisting of A, B and C, and should not be interpreted as requiring at least one of each of the listed elements A, B and C, regardless of whether A, B and C are related as categories or otherwise. Moreover, the recitation of A, B and/or C or at least one of A, B or C should be interpreted as including any singular entity from the listed elements, e.g., A, any subset from the listed elements, e.g., A and B, or the entire list of elements A, B and C.