Patent information
IP India · live recordAbstract
Disclosed herein is a method (600) for executing a plurality of rules in a rule engine, each rule comprising at least one condition and at least one action associated with the at least one condition. The method (600) comprises partitioning the plurality of rules into a plurality of batches, concurrently evaluating, prior to initiation of an action-execution phase, the at least one condition associated with each of the plurality of rules across the plurality of batches using a plurality of parallel execution threads, storing a condition-evaluation result for each rule, and synchronizing completion of the condition evaluations via a synchronization barrier. The method (600) further comprises initiating the action-execution phase subsequent to completion of the synchronization barrier, traversing the plurality of rules according to a predetermined rule-execution order, and sequentially executing or skipping the at least one action associated with each rule based on the stored condition-evaluation result.
Applicants
1Inventors
4Specification
Show full textCollapse
Description:FIELD OF INVENTION
[0001] The present disclosure relates to business rule engines for high-throughput distributed systems, and more particularly to a system and method for two-phase parallel condition evaluation and sequential action execution in a rule engine. BACKGROUND
[0002] Business rule engines are used in a variety of computing environments, including telecom platforms, e-commerce product-catalog systems, promotion and pricing engines, cart-compatibility checkers, recommendation systems, loyalty and campaign platforms, and eligibility and fraud-screening services. In such environments, a rule engine receives a set of rules, each rule including a condition and an associated action. The rule engine evaluates the condition of each rule against input data and, where the condition is satisfied, executes the associated action.
[0003] In many deployments, the order in which rule actions are executed affects the outcome. For example, in a promotional pricing engine, applying a percentage discount before a fixed-amount discount may yield a different final price than applying the same discounts in the reverse order. Maintaining a deterministic action-execution order is therefore desirable in such systems.
[0004] Existing rule engines generally follow one of two execution strategies. In a first strategy, rules are evaluated and acted upon sequentially, one rule at a time, in a defined order. While this approach preserves deterministic action ordering, the total execution time is the sum of the individual rule times, and each rule blocks the next. At high request volumes and large ruleset sizes, this sequential approach becomes a latency bottleneck. Sequential-only engines may be unable to meet low-latency service-level targets for high-concurrency interfaces such as product-catalog application programming interfaces (APIs).
[0005] In a second strategy, rules are evaluated and acted upon in parallel across multiple threads or processes. While this approach reduces total execution time, the order in which actions are executed becomes non-deterministic, because different threads may complete at different times depending on system load, thread scheduling, and condition complexity. Non-deterministic action ordering produces incorrect or inconsistent outcomes in applications where the order of action execution affects the result.
[0006] Some existing engines attempt to combine parallelism with ordering guarantees by introducing complex synchronization logic around individual rule executions. However, such approaches introduce synchronization overhead, increase implementation complexity, and remain susceptible to ordering errors under high concurrency.
[0007] Therefore, there exists a need for improved systems and methods to address at least one or more of the above-mentioned shortcomings and other related problems in the art. SUMMARY
[0008] This summary is provided to introduce a selection of concepts in a simplified form that are further described below in the detailed description. This summary is not intended to identify key features or essential features of the claimed subject matter, nor is it intended to be used as an aid in determining the scope of the claimed subject matter.
[0009] According to an embodiment of the present disclosure, a method for executing a plurality of rules in a rule engine is disclosed. Each rule includes at least one condition and at least one action associated with the at least one condition. The method includes partitioning the plurality of rules into a plurality of batches. The method also includes concurrently evaluating, prior to initiation of an action-execution phase, the at least one condition associated with each of the plurality of rules across the plurality of batches using a plurality of parallel execution threads. The method further includes storing, for each rule, a condition-evaluation result associated with the corresponding rule or a position of the corresponding rule within a predetermined rule-execution order. Furthermore, the method includes synchronizing completion of the concurrently performed condition evaluations across the plurality of batches via a synchronization barrier. Additionally, the method includes initiating the action-execution phase subsequent to completion of the synchronization barrier. The action-execution phase includes traversing the plurality of rules according to the predetermined rule-execution order and performing, for each rule, one of: sequentially executing the at least one action associated with a rule for which the stored condition-evaluation result indicates the at least one condition is satisfied, or skipping execution of the at least one action associated with a rule for which the stored condition-evaluation result indicates the at least one condition is not satisfied.
[0010] According to another embodiment of the present disclosure, a system for executing a plurality of rules is disclosed. Each rule includes at least one condition and at least one action associated with the at least one condition. The system includes a processor and a memory storing instructions that, when executed by the processor, cause the processor to partition the plurality of rules into a plurality of batches. The instructions, when executed by the processor, also cause the processor to concurrently evaluate, prior to initiation of an action-execution phase, the at least one condition associated with each of the plurality of rules across the plurality of batches using a plurality of parallel execution threads. The instructions, when executed by the processor, further cause the processor to store, for each rule, a condition-evaluation result associated with the corresponding rule or a position of the corresponding rule within a predetermined rule-execution order. Furthermore, the instructions, when executed by the processor, cause the processor to synchronize completion of the concurrently performed condition evaluations across the plurality of batches via a synchronization barrier. Additionally, the instructions, when executed by the processor, cause the processor to initiate the action-execution phase subsequent to completion of the synchronization barrier. The action-execution phase includes traversing the plurality of rules according to the predetermined rule-execution order and performing, for each rule, one of: sequentially executing the at least one action associated with a rule for which the stored condition-evaluation result indicates the at least one condition is satisfied, or skipping execution of the at least one action associated with a rule for which the stored condition-evaluation result indicates the at least one condition is not satisfied.
[0011] To further clarify the advantages and features of the present disclosure, a more particular description of the disclosure will be rendered by reference to specific embodiments thereof, which are illustrated in the appended drawings. It is appreciated that these drawings depict typical embodiments of the disclosure and are therefore not to be considered limiting of its scope. The disclosure will be described and explained with additional specificity and detail in the accompanying drawings. BRIEF DESCRIPTION OF FIGURES
[0012] These and other features, aspects, and advantages of the present disclosure will become better understood when the following detailed description is read with reference to the accompanying drawings in which like characters represent like parts throughout the drawings, wherein:
[0013] FIG. 1 illustrates a block diagram of an environment for implementation of a system for executing a plurality of rules in a rule engine, in accordance with an embodiment of the present disclosure;
[0014] FIG. 2 illustrates a block diagram of the system for executing the plurality of rules in the rule engine, in accordance with an embodiment of the present disclosure;
[0015] FIG. 3 illustrates a flowchart for a method for executing the plurality of rules in the rule engine, in accordance with an embodiment of the present disclosure;
[0016] FIG. 4 illustrates a flowchart for a method for executing a parallel condition-evaluation phase, and storing and utilizing condition-evaluation results, in accordance with an embodiment of the present disclosure;
[0017] FIG. 5 illustrates an example comparison between a sequential execution timeline and a two-phase execution timeline; and
[0018] FIG. 6 illustrates a flowchart for a method for executing the plurality of rules in the rule engine, in accordance with an embodiment of the present disclosure.
[0019] Further, skilled artisans will appreciate that elements in the drawings are illustrated for simplicity and may not have necessarily been drawn to scale. Furthermore, in terms of the construction of the device, one or more components may have been represented in the drawings by conventional symbols, and the drawings may show only those specific details that are pertinent to understanding the embodiments of the present disclosure so as not to obscure the drawings with details that will be readily apparent to those of ordinary skill in the art having the benefit of the description herein. DETAILED DESCRIPTION
[0020] For the purpose of promoting an understanding of the principles of the invention, reference will now be made to the embodiment illustrated in the drawings and specific language will be used to describe the same. It will nevertheless be understood that no limitation of the scope of the invention is thereby intended, such alterations and further modifications in the illustrated system, and such further applications of the principles of the invention as illustrated therein being contemplated as would normally occur to one skilled in the art to which the invention relates. Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which the invention belongs. The system and examples provided herein are illustrative only and not intended to be limiting.
[0021] For example, the term "some" as used herein may be understood as "none" or "one" or "more than one" or "all." Therefore, the terms "none," "one," "more than one," "more than one, but not all" or "all" would fall under the definition of "some." It should be appreciated by a person skilled in the art that the terminology and structure employed herein is for describing, teaching, and illuminating some embodiments and their specific features and elements and therefore, should not be construed to limit, restrict, or reduce the spirit and scope of the present disclosure in any way.
[0022] For example, any terms used herein, such as "includes," "comprises," "has," "consists," and similar grammatical variants do not specify an exact limitation or restriction, and certainly do not exclude the possible addition of a plurality of features or elements, unless otherwise stated. Further, such terms must not be taken to exclude the possible removal of the plurality of the listed features and elements, unless otherwise stated, for example, by using the limiting language including, but not limited to, "must comprise" or "needs to include."
[0023] Whether or not a certain feature or element was limited to being used only once, it may still be referred to as "plurality of features" or "plurality of elements" or "at least one feature" or "at least one element." Furthermore, the use of the terms "plurality of" or "at least one" feature or element do not preclude there being none of that feature or element, unless otherwise specified by limiting language including, but not limited to, "there needs to be plurality of…" or "plurality of elements is required."
[0024] Unless otherwise defined, all terms and especially any technical and/or scientific terms, used herein may be taken to have the same meaning as commonly understood by a person ordinarily skilled in the art.
[0025] Reference is made herein to some "embodiments." It should be understood that an embodiment is an example of a possible implementation of any features and/or elements of the present disclosure. Some embodiments have been described for the purpose of explaining plurality of the potential ways in which the specific features and/or elements of the proposed disclosure fulfil the requirements of uniqueness, utility, and non-obviousness.
[0026] Use of the phrases and/or terms including, but not limited to, "a first embodiment," "a further embodiment," "an alternate embodiment," "one embodiment," "an embodiment," "multiple embodiments," "some embodiments," "other embodiments," "further embodiment", "furthermore embodiment", "additional embodiment" or other variants thereof do not necessarily refer to the same embodiments. Unless otherwise specified, plurality of particular features and/or elements described in connection with plurality of embodiments may be found in one embodiment, or may be found in more than one embodiment, or may be found in all embodiments, or may be found in no embodiments. Although plurality of features and/or elements may be described herein in the context of only a single embodiment, or in the context of more than one embodiment, or in the context of all embodiments, the features and/or elements may instead be provided separately or in any appropriate combination or not at all. Conversely, any features and/or elements described in the context of separate embodiments may alternatively be realized as existing together in the context of a single embodiment.
[0027] Any particular and all details set forth herein are used in the context of some embodiments and therefore should not necessarily be taken as limiting factors to the proposed disclosure.
[0028] The present disclosure relates to a system and method for two-phase parallel condition evaluation and sequential action execution in a rule engine. In various computing environments, a rule engine receives a plurality of rules, each rule comprising at least one condition and at least one action associated with the at least one condition. The rule engine evaluates the at least one condition of each rule against input data and, where the at least one condition is satisfied, executes the at least one action. The present disclosure describes a two-phase execution model in which rule conditions are evaluated concurrently in configurable batches during a first phase, and rule actions are executed sequentially in a predetermined rule-execution order during a second phase. Such separation of condition evaluation from action execution enables parallel throughput during a condition-evaluation phase while preserving deterministic action ordering during an action-execution phase. Further, such two-phase execution model eliminates the trade-off between parallel speed and deterministic ordering that exists in conventional rule engines, and removes rule-engine latency as a bottleneck in high-concurrency applications. Embodiments of the present disclosure are explained in detail in the forthcoming paragraphs.
[0029] FIG. 1 illustrates a block diagram of an environment 100 for implementation of a system 110 for executing a plurality of rules in a rule engine, in accordance with an embodiment of the present disclosure. The environment 100 may include a client device 102, a client device 104, a communication network 106, an application server 108, the system 110, a rule repository 112, and a catalog data store 114.
[0030] Each of the client device 102 and the client device 104 may be a computing device such as a desktop computer, a laptop computer, a tablet, a smartphone, or a server. The client device 102 and the client device 104 may each be configured to issue requests for product-catalog, promotion, pricing, recommendation, or eligibility-evaluation services over the communication network 106 to the application server 108. For example, the client device 102 may transmit a request to determine applicable promotional offers for a shopping cart containing one or more products and associated subscriber or customer attributes. FIG. 1 shows only two client devices; however, it should be noted that any number of client devices may be used based on specific requirements.
[0031] The communication network 106 may include one or more of the Internet, a local area network (LAN), a wide area network (WAN), a cellular network, or any combination of wired and wireless networks. The application server 108 may be a computing platform configured to receive the requests from the client devices 102, 104, manage request processing, and coordinate interactions with backend services. The application server 108 may forward the received requests to the system 110 for rule evaluation. FIG. 1 illustrates the system 110 implemented as a standalone computing platform; however, it should be noted that the system 110 may alternatively be implemented at the application server 108 or as a distributed system including a plurality of interconnected computing devices configured to collectively perform one or more rule-execution operations described herein.
[0032] The system 110 may be configured to perform the one or more rule execution operations on the plurality of rules. The system 110 may include or implement the rule engine configured to process the plurality of rules. The system 110 may receive, as input, the plurality of rules from the rule repository 112 and catalog data from the catalog data store 114. The rule repository 112 may store the plurality of rules, where each rule may include at least one condition and at least one action associated with the at least one condition. For example, a rule may specify a condition that a subscriber has activated a postpaid plan and has maintained an account balance above a predefined threshold. The action associated with the rule may include granting an additional data allowance or activating a promotional offer when the condition is satisfied. The plurality of rules may be stored in a structured format such as JavaScript Object Notation (JSON), Extensible Markup Language (XML), or a domain-specific language. The catalog data store 114 may store the catalog data, such as product information, pricing data, or promotional offers, against which the plurality of rules may be evaluated. The catalog data store 114 may be a relational database, a document store, or an in-memory data grid.
[0033] In operation, the client devices 102, 104 may transmit requests to the application server 108 via the communication network 106. The application server 108 may forward the requests to the system 110. The system 110 may retrieve the plurality of rules from the rule repository 112 and the catalog data from the catalog data store 114. The system 110 may evaluate the conditions of the retrieved plurality of rules against the catalog data using the condition-evaluation phase (also referred to as a “parallel condition-evaluation phase”) and may execute actions associated with rules whose conditions are satisfied using the action-execution phase (also referred to as a “sequential action-execution phase”). The system 110 may generate, as output, rule outcomes indicating the actions that were executed and results of the executed actions. The rule outcomes may be returned to the application server 108, which may return responses to the client devices 102, 104 over the communication network 106. Thus, the present disclosure provides parallel throughput during condition evaluation while preserving deterministic action ordering during action execution, thereby reducing total execution time compared to fully sequential rule engines.
[0034] The environment 100 may support high-throughput rule evaluation in a variety of application areas. In some embodiments, the system 110 may be deployed in telecom and e-commerce product-catalog, promotion, and pricing engines. In some embodiments, the system 110 may be deployed in real-time cart-compatibility and recommendation systems. In some embodiments, the system 110 may be used in loyalty, campaign, and offer-management platforms where the order in which promotions are applied affects the outcome. In some embodiments, the system 110 may be used in rule-driven eligibility, fraud-screening, and policy checks that operate at low latency and high request volumes. More generally, the system 110 may be used in any high-throughput business-rule evaluation that combines parallel speed with deterministic, auditable action ordering. Some additional details of the system 110 are explained with respect to FIG. 2 in the forthcoming paragraphs.
[0035] FIG. 2 illustrates a block diagram 200 of the system 110 for executing the plurality of rules in the rule engine, in accordance with an embodiment of the present disclosure. The system 110 may include a processor 202, a memory 204, and a communication interface 206.
[0036] The processor 202 may be communicatively coupled to the memory 204 and may be configured to perform various operations related to two-phase execution operations described herein. In an embodiment, the processor 202 may include specialized processing units such as integrated system (bus) controllers, memory management control units, floating point units, graphics processing units, digital signal processing units, etc. In one embodiment, the processor 202 may include a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), or both. The processor 202 may be one or more general processors, Digital Signal Processors (DSPs), application-specific integrated circuits, Field-Programmable Gate Arrays (FPGAs), servers, networks, digital circuits, analog circuits, combinations thereof, or other now known or later developed devices for analyzing and processing data. The processor 202 may be implemented as a single processor or as multiple processors operating in parallel or in a distributed configuration. In an embodiment, the processor 202 may include one or more processors, such as CPUs or other programmable processing devices. The processor 202 may execute a software program, such as code generated manually (i.e., programmed) to perform the desired operation. The processor 202 may execute software, firmware, or a combination of software and firmware stored in the memory 204 or other storage media.
[0037] In some embodiments, the memory 204 may be communicatively coupled to the processor 202. The memory 204 may be configured to store data, instructions executable by the processor 202. In one embodiment, the memory 204 may communicate via a bus within the system 110. The memory 204 may include, but is not limited to, a non-transitory computer-readable storage media, such as various types of volatile and non-volatile storage media including, but not limited to, random access memory, read-only memory, programmable read-only memory, electrically programmable read-only memory, electrically erasable read-only memory, flash memory, magnetic tape or disk, optical media and the like. In one example, the memory 204 may include a cache or random-access memory for the processor 202. In alternative examples, the memory 204 is separate from the processor 202, such as a cache memory of a processor, the system memory, or other memory such as cloud-based virtual computing environments. The memory 204 may be an external storage device or database for storing data. The memory 204 may be operable to store instructions executable by the processor 202. The functions, acts or tasks illustrated in the figures or described may be performed by the programmed processor 202 for executing the instructions stored in the memory 204. The functions, acts or tasks are independent of the particular type of instructions set, storage media, processor or processing strategy and may be performed by software, hardware, integrated circuits, firmware, micro-code and the like, operating alone or in combination. Likewise, processing strategies may include multiprocessing, multitasking, parallel processing, and the like. The memory 204 may further include a database to store the data. Further, the memory 204 may include an operating system for performing one or more tasks of the system 110.
[0038] The memory 204 may include one or more modules 208 and a data storage unit 210. The one or more modules 208, amongst other things, may include routines, programs, objects, components, data structures, etc., which perform predefined tasks or implement data types. The module(s) 208 may also be implemented as, signal processor(s), state machine(s), logic circuitries, and/or any other device or component that manipulates information and/or signals based on operational instructions.
[0039] Further, the module(s) 208 may be implemented in hardware, instructions executed by a processing unit, or by a combination thereof. The processing unit may comprise a computer, the processor 202, a state machine, a logic array, or any other suitable devices capable of processing instructions. The processing unit can be a general-purpose processor which executes instructions and/or routines to cause the general-purpose processor to perform the required tasks, or the processing unit can be dedicated to performing the required functions. In another embodiment of the present disclosure, the module(s) 208 may be machine-readable instructions (software) which, when executed by a processor/processing unit, perform any of the described functionalities. The one or more modules 208 may include a configuration module 212, a batch partitioning module 214, a condition evaluation module 216, a synchronization module 218, and an action execution module 220.
[0040] The configuration module 212 may be configured to manage one or more configurable parameters for rule execution. The configuration module 212 may be configured to supply a configuration parameter specifying a batch size for rule partitioning. In an embodiment, the configuration parameter may be referred to as an execution batch size parameter (e.g., execution.batch_size) and may have a default value of 50, allowing per-deployment performance tuning without code changes. The batch size may determine the number of rules grouped together into each batch for concurrent condition evaluation.
[0041] The batch partitioning module 214 may be configured to partition the plurality of rules into a plurality of batches. The batch partitioning module 214 may receive the plurality of rules from the rule repository 112 and divide the plurality of rules into a plurality of batches of the configured batch size. In an embodiment, a size of each batch of the plurality of batches may be configurable through the configuration parameter or determined dynamically based on a cost estimate associated with one or more rules in the batch. In an embodiment, the cost estimate may be derived from one or more of historical condition-evaluation times, condition-complexity metrics, or data-access latency measurements associated with individual rules. Rules having relatively high estimated evaluation costs may be grouped into smaller batches to improve workload balance among one or more worker entities.
[0042] In some embodiments, a number of the plurality of rules may be less than a threshold value. In response to the number of the plurality of rules being less than the threshold value, each batch may include a single rule, such that the at least one condition associated with each rule is evaluated by a respective execution thread. In an example, where the plurality of rules includes ten rules and the threshold value is 20, the batch partitioning module 214 may create 10 single-rule batches and assign each rule to a respective execution thread for concurrent condition evaluation. In various embodiments, batch partitioning may be performed using fixed-size batches, dynamically sized batches, work-stealing scheduling, or single-rule batches for relatively small rulesets.
[0043] The condition evaluation module 216 may be configured to concurrently evaluate the at least one condition associated with each of the plurality of rules across the plurality of batches using a plurality of parallel execution threads. The condition evaluation module 216 evaluates the conditions prior to initiation of the action-execution phase, such that all the conditions are evaluated before any actions are executed. The parallel evaluation of the conditions across the plurality of batches reduces the total time spent on condition evaluation compared to sequential evaluation of each rule one at a time.
[0044] In an embodiment, the plurality of parallel execution threads may include the one or more worker entities. The one or more worker entities may include processing units configured to evaluate conditions associated with assigned rules concurrently with one another. Each worker entity may process one or more condition-evaluation tasks independently of other worker entities. In an embodiment, the one or more worker entities may include goroutines, which are lightweight concurrent execution units configured to perform condition evaluation tasks. As used herein, the terms execution thread, worker entity, and worker broadly refer to any independently schedulable execution construct capable of processing one or more rule-evaluation tasks, including, without limitation, operating-system threads, lightweight threads, goroutines, tasks, fibers, coroutines, processes, actors, or equivalents thereof. In an embodiment, the plurality of parallel execution threads may be provided by a fixed-size worker pool. The fixed-size worker pool may include a predetermined number of worker entities configured to process condition-evaluation tasks while controlling resource consumption. Further, work items corresponding to the plurality of rules may be assigned to the one or more worker entities using an atomic cursor that bounds the number of concurrently created threads. The atomic cursor may include a shared scheduling mechanism configured to assign the work items to the one or more worker entities in a thread-safe manner while limiting the number of concurrently created execution threads.
[0045] The condition evaluation module 216 may be configured to store, for each rule, a condition-evaluation result associated with the corresponding rule or a position of the corresponding rule within a predetermined rule-execution order. The condition-evaluation result may indicate that the at least one condition is satisfied, not satisfied, or failed during evaluation. In an embodiment, the predetermined rule-execution order includes at least one of a dependency-graph order, an order in which the plurality of rules is received in the rule engine, or a priority-based or salience-based order. The dependency-graph order may include a topological ordering derived from dependencies between rules, such that a rule producing data for another rule is executed before the other rule. The order in which the plurality of rules is received in the rule engine may correspond to an order in which the plurality of rules is stored, loaded, or defined. The priority-based or salience-based order may include an ordering determined according to a priority or salience value associated with each rule, such that rules having higher priority or salience values are traversed before rules having lower priority or salience values. In an embodiment, to store the condition-evaluation result, the condition evaluation module 216 may be configured to write the condition-evaluation result to a thread-safe data structure indexed by at least one of a rule identifier or the position of the rule within the predetermined rule-execution order. In an embodiment, the rule identifier may include a numeric value, alphanumeric string, key, index, or other identifier uniquely associated with a rule within the plurality of rules.
[0046] In an embodiment, condition evaluation of a rule may result in a satisfied condition, an unsatisfied condition, or a failure state. A rule associated with a failure state may be treated as having an unsatisfied condition, such that execution of the action associated with the rule is inhibited during the action-execution phase. In various embodiments, the failure state may be handled using fail-closed, fail-open, retry, or circuit-breaking mechanisms. In an embodiment, where evaluation of a condition associated with a rule fails, a failure state corresponding to the rule may be stored. During the action-execution phase, the action associated with the rule may be skipped based on the stored failure state.
[0047] The synchronization module 218 may be configured to synchronize completion of the concurrently performed condition evaluations across the plurality of batches via a synchronization barrier. The synchronization barrier may include a mechanism configured to ensure that all parallel condition-evaluation operations are completed before the action-execution phase is initiated. For example, where conditions associated with a first batch, a second batch, and a third batch are evaluated concurrently by respective execution threads, the synchronization barrier may delay initiation of the action-execution phase until execution threads associated with all three batches have completed their condition evaluations and stored the corresponding condition-evaluation results. In an embodiment, the synchronization barrier may include a wait group configured to block processing until a set of concurrently executing worker entities completes assigned condition-evaluation tasks.
[0048] The action execution module 220 may be configured to initiate the action-execution phase subsequent to completion of the synchronization barrier. During the action-execution phase, the action execution module 220 may be configured to traverse the plurality of rules according to the predetermined rule-execution order. The sequential traversal in the predetermined rule-execution order ensures that actions are executed in a deterministic order regardless of the order in which the parallel condition evaluations are completed.
[0049] In an embodiment, for each rule, the action execution module 220 may also be configured to sequentially execute the at least one action associated with the rule for which the stored condition-evaluation result indicates the at least one condition is satisfied. In an alternative embodiment, for each rule, the action execution module 220 may be configured to skip execution of the at least one action associated with the rule for which the stored condition-evaluation result indicates the at least one condition is not satisfied.
[0050] In an embodiment, in the action-execution phase, the action execution module 220 may be configured to partition one or more rules having satisfied conditions into two or more independent groups. Further, the action execution module 220 may be configured to concurrently execute actions associated with the two or more independent groups while preserving the predetermined rule-execution order within each group. For example, a first independent group may include rules associated with promotion determination, and a second independent group may include rules associated with compatibility validation. Where no dependency exists between actions associated with the two groups, actions associated with the two groups may be executed concurrently while maintaining the predetermined rule-execution order within each group.
[0051] In an embodiment, responsive to a failure during evaluation of a condition associated with a rule, the action-execution module 220 may be configured to store an execution state indicating the failure in association with the rule. The action-execution module 220 may also be configured to inhibit execution of an action associated with the rule during the action-execution phase.
[0052] The data storage unit 210 may store condition-evaluation results and other data used during rule execution. The communication interface 206 may facilitate communication between the system 110 and one or more external components such as the client devices 102, 104, the rule repository 112, and the catalog data store 114.
[0053] The system 110 may be deployed in a variety of topologies. In an embodiment, the system 110 may be deployed as a single in-process engine within the application server 108. In an embodiment, the system 110 may be deployed as replicated nodes, each node executing the two phases independently against a local copy of the ruleset. In an embodiment, the system 110 may be deployed in a distributed variant in which the batch partitioning module 214 fans batches out to remote worker nodes and the synchronization module 218 gathers results at a coordinator barrier before the action execution module 220 begins the action-execution phase. The distributed variant enables horizontal scaling of the condition-evaluation phase across multiple machines while maintaining deterministic action ordering at the coordinator.
[0054] FIG. 3 illustrates a flowchart for a method 300 for executing the plurality of rules in the rule engine, in accordance with an embodiment of the present disclosure. The method 300 may separate execution of the plurality of rules into two distinct phases, namely the condition-evaluation phase and the action-execution phase. The method 300 may be implemented by the system 110 or one or more components thereof.
[0055] At step 302, the method 300 may include receiving a ruleset 302, including the plurality of rules to be processed. Each rule in the ruleset includes the at least one condition and the at least one action associated with the at least one condition. The ruleset may correspond to the rules stored in the rule repository 112 and retrieved by the system 110.
[0056] At step 304, the method 300 may include executing the condition-evaluation phase. In the condition-evaluation phase 304, the plurality of rules may be partitioned into the plurality of batches, including a batch 306A, a batch 306B, and a batch 306C. The at least one condition associated with each of the plurality of rules may be concurrently evaluated across the plurality of batches using the plurality of parallel execution threads, prior to initiation of the action-execution phase. Each batch 306A, 306B, 306C may be assigned to a respective execution thread or group of execution threads for concurrent evaluation. The number of batches and the number of rules per batch may be determined by the configuration parameter supplied by the configuration module 212.
[0057] Upon completion of condition evaluation across the plurality of batches, the method 300 may include synchronizing completion of the concurrently performed condition evaluations across the plurality of batches, at step 308. The synchronization barrier ensures that all parallel condition evaluations are completed before proceeding to the action-execution phase. At step 310, the method 300 may include collecting and storing the condition-evaluation results in the thread-safe result structure.
[0058] Further, at step 312, the method 300 may include initiating the action-execution phase subsequent to completion of the synchronization barrier. Within the action-execution phase, at step 314, the method 300 may include traversing the plurality of rules in the predetermined rule-execution order.
[0059] For each rule traversed, the method 300 performs one of two operations based on the stored condition-evaluation result. At step 316, where the stored condition-evaluation result indicates the at least one condition is satisfied, the method 300 may include sequentially executing the at least one action associated with the rule. Alternatively, at step 318, where the stored condition-evaluation result indicates the at least one condition is not satisfied, the method 300 may include skipping execution of the at least one action associated with the rule. The sequential traversal in the predetermined rule-execution order ensures that actions are executed deterministically, regardless of the order in which the parallel condition evaluations completed during the condition-evaluation phase 304.
[0060] FIG. 4 illustrates a flowchart for a method 400 for executing the condition-evaluation phase, and storing and utilizing the condition-evaluation results, in accordance with an embodiment of the present disclosure. The method 400 may be a part of the method 300 and may be implemented by the system 110 or one or more components thereof.
[0061] At step 402, the method 400 may include receiving the ruleset, including the plurality of rules to be processed. The plurality of rules of the ruleset may be pre-compiled rules. The pre-compiled rules are rules whose conditions have been compiled into an executable representation, such as bytecode or native instructions, prior to partitioning and evaluation.
[0062] At step 404, the method 400 may include partitioning the plurality of rules into the plurality of batches for concurrent processing. The method 400 may include dividing the plurality of rules into the plurality of batches of a configurable size based on the configuration parameter.
[0063] At step 406, the method 400 may include distributing the partitioned plurality of batches to the fixed-size worker pool. The fixed-size worker pool may provide the plurality of parallel execution threads for concurrent condition evaluation. The fixed-size worker pool may include the one or more worker entities, including a worker entity 408A, a worker entity 408B, and a worker entity 408C. The plurality of parallel execution threads may include the one or more worker entities. The one or more worker entities 408A, 408B, and 408C may concurrently evaluate the at least one condition associated with each of the plurality of rules in respective batches.
[0064] In an embodiment, an atomic cursor 410 may be associated with fixed-size worker pool. The atomic cursor 410 may bound the number of concurrently created threads by atomically advancing a cursor position so that each work item is assigned to one worker entity without contention. The work items corresponding to the plurality of rules may be assigned to the one or more worker entities 408A, 408B, and 408C using the atomic cursor 410. The atomic cursor 410 ensures that the number of active threads remains bounded by the size of the fixed-size worker pool, thereby controlling resource consumption during the condition-evaluation phase.
[0065] The condition evaluation within each worker entity may be performed using a variety of techniques. In an embodiment, the conditions may be evaluated using pre-compiled virtual machine (VM) bytecode, in which rule conditions are compiled into bytecode instructions that are executed by a virtual machine at runtime. In an embodiment, the conditions may be evaluated using abstract syntax tree (AST) interpretation, in which rule conditions are parsed into a tree structure and evaluated by traversing the tree nodes. In an embodiment, the conditions may be evaluated using just-in-time (JIT) compiled native code, in which rule conditions are compiled into machine-native instructions at runtime for direct execution by processor 202.
[0066] In various embodiments, the plurality of parallel execution threads may be implemented using managed thread pools, futures, promises, actor runtimes, or other concurrency mechanisms capable of concurrently evaluating conditions associated with the plurality of rules.
[0067] At step 412, upon completion of condition evaluation by the one or more worker entities 408A, 408B, and 408C, the method 400 may include applying a wait group barrier to synchronize completion of the concurrently performed condition evaluations across the plurality of batches. The wait group barrier may prevent initiation of the action-execution phase until each of the one or more worker entities 408A, 408B, and 408C have finished respective condition evaluations. At step 414, the method 400 may include storing the condition-evaluation results in the thread-safe result structure.
[0068] In an embodiment, the thread-safe result structure may be a thread-safe data structure that stores, for each rule, a condition-evaluation result associated with the corresponding rule or the position of the corresponding rule within the predetermined rule-execution order. In an embodiment, for storing the condition-evaluation result, the method 400 may include writing the condition-evaluation result to a thread-safe data structure indexed by at least one of the rule identifier or the position of the rule within the predetermined rule-execution order. In an embodiment, the thread-safe result structure may be implemented as a thread-safe map keyed by the rule identifier. In an embodiment, the thread-safe result structure may be implemented as a lock-free pre-allocated boolean array indexed by rule position. In an embodiment, the thread-safe result structure may be implemented using per-batch result shards that are merged at the synchronization barrier. The lock-free pre-allocated boolean array avoids lock contention by pre-allocating a fixed-size array with one entry per rule and allowing each worker entity to write to a distinct index without synchronization. The per-batch result shards approach assigns a separate result buffer to each batch and merges the buffers into a single result structure after the synchronization barrier completes.
[0069] Subsequent to application of the wait group barrier, at step 416, the method 400 may include initiating the action-execution phase via a sequential action loop. The sequential action loop may read the thread-safe result structure and traverse the plurality of rules according to the predetermined rule-execution order. For each rule, the sequential action loop may either sequentially execute the at least one action associated with a rule for which the stored condition-evaluation result indicates the at least one condition is satisfied, or may skip execution of the at least one action associated with a rule for which the stored condition-evaluation result indicates the at least one condition is not satisfied. The method 400 may provide parallel throughput during condition evaluation while preserving deterministic action ordering during the action-execution phase.
[0070] FIG. 5 illustrates an example comparison between a sequential execution timeline 502 and a two-phase execution timeline 506. The sequential execution timeline 502 is associated with conventional serialized rule execution and the two-phase execution timeline 506 is associated with execution according to the two-phase execution model described herein.
[0071] In the conventional approach, represented by serialized execution intervals 504, each rule is processed sequentially such that condition evaluation and corresponding action execution for a first rule are completed before processing of a subsequent rule begins, i.e., each rule blocks the next. As a result, total execution time, which is a sum of all rule execution times, increases with the number of rules.
[0072] In contrast, as shown by the two-phase execution timeline 506, the present disclosure partitions the plurality of rules into batches 508A, 508B, and 508C for concurrent condition evaluation. For example, the batch 508A may include rules R1, R2, and R3, the batch 508B may include rules R4, R5, and R6, and the batch 508C may include rules R7, R8, and R9. The conditions associated with the rules of the batches may be evaluated concurrently by respective worker entities during the condition-evaluation phase.
[0073] Upon completion of the condition-evaluation operations, the condition-evaluation results may be synchronized at a synchronization barrier 510. The synchronization barrier 510 may ensure that condition evaluation associated with all batches is completed before initiation of the action-execution phase. Accordingly, the synchronization barrier 510 separates the condition-evaluation phase from the action-execution phase and enables collection of condition-evaluation results for the plurality of rules.
[0074] Following synchronization at synchronization barrier 510, actions associated with rules having satisfied conditions may be executed during ordered action interval 512. The actions may be executed according to the predetermined rule-execution order. In the illustrated example, actions associated with rules R1, R3, R4, and R7 are executed, while actions associated with the remaining rules are skipped because the corresponding conditions are not satisfied.
[0075] Accordingly, the present disclosure enables concurrent evaluation of rule conditions while preserving deterministic action ordering. By separating condition evaluation from action execution, the present disclosure reduces overall rule-processing latency and improves throughput relative to conventional serialized rule execution.
[0076] FIG. 6 illustrates a flowchart for a method 600 for executing the plurality of rules in the rule engine, in accordance with an embodiment of the present disclosure. Each rule may include the at least one condition and the at least one action associated with the at least one condition. The method 600 may implement the two-phase execution model described herein. The method 600 may be a part of the method 300 and may be implemented by the system 110 or one or more components thereof.
[0077] At step 602, the method 600 may include partitioning the plurality of rules into the plurality of batches. In an embodiment, the size of each batch of the plurality of batches may be configurable through the configuration parameter or determined dynamically based on the cost estimate associated with the one or more rules in the batch. In an embodiment, in response to the number of the plurality of rules being less than the threshold value, each batch may include a single rule, such that the at least one condition associated with each rule is evaluated by a respective execution thread.
[0078] At step 604, the method 600 may include concurrently evaluating, prior to initiation of the action-execution phase, the at least one condition associated with each of the plurality of rules across the plurality of batches using the plurality of parallel execution threads. In an embodiment, the plurality of parallel execution threads may include the one or more worker entities, the one or more worker entities may include the goroutines, and the synchronization barrier may include the wait group. In an embodiment, the plurality of parallel execution threads may be provided by the fixed-size worker pool, and the work items corresponding to the plurality of rules may be assigned to the one or more worker entities using the atomic cursor 410 that bounds the number of concurrently created threads.
[0079] At step 606, the method 600 may include storing, for each rule, the condition-evaluation result associated with the corresponding rule or the position of the corresponding rule within the predetermined rule-execution order. In an embodiment, storing the condition-evaluation result may include writing the condition-evaluation result to the thread-safe data structure indexed by at least one of the rule identifier or the position of the rule within the predetermined rule-execution order.
[0080] At step 608, the method 600 may include synchronizing completion of the concurrently performed condition evaluations across the plurality of batches via the synchronization barrier. The synchronization barrier may prevent initiation of the action-execution phase until all parallel condition evaluations across all batches have completed and all condition-evaluation results are available.
[0081] At step 610, the method 600 may include initiating the action-execution phase subsequent to completion of the synchronization barrier.
[0082] At step 612, the method 600 may include traversing the plurality of rules according to the predetermined rule-execution order. In an embodiment, the predetermined rule-execution order may include at least one of the dependency-graph order, the order in which the plurality of rules is received in the rule engine, or the priority-based or salience-based order.
[0083] At step 614, the method 600 may include determining, for each rule traversed, whether the stored condition-evaluation result indicates the at least one condition is satisfied. If the stored condition-evaluation result indicates the at least one condition is satisfied, the method 600 may proceed to step 616A. At step 616A, the method 600 may include sequentially executing the at least one action associated with the rule for which the stored condition-evaluation result indicates the at least one condition is satisfied. Alternatively, if the stored condition-evaluation result indicates the at least one condition is not satisfied, the method 600 may proceed to step 616B. At step 616B, the method 600 may include skipping execution of the at least one action associated with the rule for which the stored condition-evaluation result indicates the at least one condition is not satisfied.
[0084] In an embodiment, responsive to the failure during evaluation of the condition associated with a rule, the execution state indicating the failure may be stored in association with the rule, and execution of an action associated with the rule may be inhibited during the action-execution phase.
[0085] In an embodiment, the action-execution phase may include partitioning the one or more rules having satisfied conditions into the two or more independent groups and concurrently executing the actions associated with the two or more independent groups while preserving the predetermined rule-execution order within each group. Two rules may be placed in the same independent group when the action of one rule is not affecting the condition or action of the other rule. By preserving the predetermined rule-execution order within each group, concurrent group action execution may provide additional parallelism during the action-execution phase while maintaining deterministic outcomes within each group.
[0086] The present disclosure provides various technical advantages. By separating rule execution into a parallel condition-evaluation phase and a sequential action-execution phase, the present disclosure improves processing throughput while preserving deterministic action ordering. Further, concurrent evaluation of rule conditions reduces overall rule-processing latency and enables efficient utilization of available computing resources. Furthermore, execution of actions in a predetermined rule-execution order ensures consistent and repeatable outcomes, thereby eliminating non-deterministic behavior associated with fully parallel rule execution. The present disclosure may therefore enable high-volume rule processing, improved scalability, reduced response times, and reliable rule-evaluation outcomes in telecommunications, e-commerce, and other rule-driven computing environments.
[0087] Features of any of the examples or embodiments outlined above may be combined to create additional examples or embodiments without losing the intended effect. It should be understood that the description of an embodiment or example provided above is by way of example only, and various modifications could be made by one skilled in the art. Furthermore, one skilled in the art will recognize that numerous further modifications and combinations of various aspects are possible. Accordingly, the described aspects are intended to encompass all such alterations, modifications, and variations that fall within the scope of the appended claims. , Claims:1. A method (600) for executing a plurality of rules in a rule engine, each rule comprising at least one condition and at least one action associated with the at least one condition, the method (600) comprising: partitioning (602) the plurality of rules into a plurality of batches; concurrently evaluating (604), prior to initiation of an action-execution phase, the at least one condition associated with each of the plurality of rules across the plurality of batches using a plurality of parallel execution threads; storing (606), for each rule, a condition-evaluation result associated with the corresponding rule or a position of the corresponding rule within a predetermined rule-execution order; synchronizing (608) completion of the concurrently performed condition evaluations across the plurality of batches via a synchronization barrier; and initiating (610) the action-execution phase subsequent to completion of the synchronization barrier, wherein the action-execution phase comprises: traversing (612) the plurality of rules according to the predetermined rule-execution order; and performing, for each rule, one of: sequentially (616A) executing the at least one action associated with a rule for which the stored condition-evaluation result indicates the at least one condition is satisfied; or skipping (616B) execution of the at least one action associated with a rule for which the stored condition-evaluation result indicates the at least one condition is not satisfied.
2. The method (600) as claimed in claim 1, wherein a size of each batch of the plurality of batches is configurable through a configuration parameter or determined dynamically based on a cost estimate associated with one or more rules in the batch, and wherein, in response to a number of the plurality of rules being less than a threshold value, each batch comprises a single rule, such that the at least one condition associated with each rule is evaluated by a respective execution thread.
3. The method (600) as claimed in claim 1, wherein storing the condition-evaluation result comprises writing the condition-evaluation result to a thread-safe data structure indexed by at least one of a rule identifier or the position of the rule within the predetermined rule-execution order.
4. The method (600) as claimed in claim 1, wherein the predetermined rule-execution order comprises at least one of: a dependency-graph order, an order in which the plurality of rules is received in the rule engine, or a priority-based or salience-based order.
5. The method (600) as claimed in claim 1, wherein the plurality of parallel execution threads comprises one or more worker entities, and wherein the one or more worker entities comprise goroutines and the synchronization barrier comprises a wait group, and wherein the plurality of parallel execution threads is provided by a fixed-size worker pool, and wherein work items corresponding to the plurality of rules are assigned to the one or more worker entities using an atomic cursor that bounds the number of concurrently created threads.
6. The method (600) as claimed in claim 1, wherein, responsive to a failure during evaluation of a condition associated with a rule, an execution state indicating the failure is stored in association with the rule, and execution of an action associated with the rule is inhibited during the action-execution phase.
7. The method (600) as claimed in claim 1, wherein the action-execution phase comprises: partitioning one or more rules having satisfied conditions into two or more independent groups; and concurrently executing actions associated with the two or more independent groups while preserving the predetermined rule-execution order within each group.
8. A system (110) for executing a plurality of rules, each rule comprising at least one condition and at least one action associated with the at least one condition, the system (110) comprising: a processor (202); and a memory (204) storing instructions that, when executed by the processor (202), cause the processor (202) to: partition the plurality of rules into a plurality of batches; concurrently evaluate, prior to initiation of an action-execution phase, the at least one condition associated with each of the plurality of rules across the plurality of batches using a plurality of parallel execution threads; store, for each rule, a condition-evaluation result associated with the corresponding rule or a position of the corresponding rule within a predetermined rule-execution order; synchronize completion of the concurrently performed condition evaluations across the plurality of batches via a synchronization barrier; and initiate the action-execution phase subsequent to completion of the synchronization barrier, wherein the action-execution phase comprises: traversing the plurality of rules according to the predetermined rule-execution order; and performing, for each rule, one of: sequentially executing the at least one action associated with a rule for which the stored condition-evaluation result indicates the at least one condition is satisfied; or skipping execution of the at least one action associated with a rule for which the stored condition-evaluation result indicates the at least one condition is not satisfied.
9. The system (110) as claimed in claim 8, wherein to store the condition-evaluation result, the instructions cause the processor (202) to write the condition-evaluation result to a thread-safe data structure indexed by at least one of a rule identifier or the position of the rule within the predetermined rule-execution order.
10. The system (110) as claimed in claim 8, wherein the predetermined rule-execution order comprises at least one of: a dependency-graph order, an order in which the plurality of rules is received in the rule engine, or a priority-based or salience-based order.