Open michaelkohn opened 2 months ago
Following up on last week's update: We can try to find a way to run the process once somehow.
Running the process once won't necessarily lower the Apdex Score, but still, it'd be nice to have fewer processes running for the page.
So far, the process needs to run twice. After submitting a task, it needs to evaluate dirty contacts and reports and create a doc of the type task; then it runs again to retrieve the updated list of tasks but now considers the new task doc/ or the new state of the task, on the internal evaluations.
Tech talk:
data_record
and updates the emissions (this.rulesEngineCore.updateEmissionsFor(subjectIds)
).this.rulesEngineCore.fetchTasksFor
), which ends up creating a doc of type task
task
and fetches the tasks again this.rulesEngineCore.fetchTasksFor
3 main things happen in tasks:refresh
code:
The "fetch tasks docs for all contacts" is a process in the rules engine. It's what takes most of the time by far, specifically, these sub-processes:
performance.now()
in each of those functions.Checking the refreshAndSave, taskDataFor, and tasksByRelation, they seem to be doing what's needed:
The tasks:refresh
process starts. The rules engine state doc (_local/rulesStateStore
) is updated 3 times. This is the sequence when it comes to database interactions done by the rules engine:
@michaelkohn @Benmuiruri I added a more technical comment. I hope it helps; I tried to explain it, but it will make more sense once looking at the code for a bit.
In short, I haven't found anything significant to improve the rules engines' performance. The code is tangled, which can make it a bit tricky to change. It can open the door to bugs in tasks and targets.
@michaelkohn What do you recommend?
I wouldn't want to start any work without getting the baseline, but I'm also curious if any other devs have any ideas/things to explore?
Refresh a couple of things:
I checked the code that is in the scope of the Apdex metric (task:refresh)