-
Notifications
You must be signed in to change notification settings - Fork 190
ENT-8096: Implemented policy profiler in cf-agent #5903
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
I still need to add functions execution in the profiler edit: this is done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CodeQL found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.
20debf1 to
7f623aa
Compare
6347574 to
1c3e1ca
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some smaller comments
Changelog: The policy profiling logic is now implemented natively within the cf-agent, replacing the previous reliance on cf-agent logs and the cf-profile.pl script for faster execution. Ticket: ENT-8096 Signed-off-by: Victor Moene <victor.moene@northern.tech>
| { | ||
| assert(ctx != NULL); | ||
| assert(last_event != NULL); | ||
| SeqAppend(ctx->events, last_event); // keep track of EventFrames for cleanup |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@victormlg I think this part (pushing an event into the Seq) is the only thing we want to do while evaluating policy. The rest (building a nice tree, hashmaps, summarizing, sorting, etc. Should all appen by iterating over the events after policy evaluation is done.
| return; | ||
| } | ||
|
|
||
| JsonElement *tree = EventFrameTreeToJson(ctx->root); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we should loop over the "unprocessed" events in the Seq, and convert them to the proper tree.
The policy evaluation creates multiple copies of the same bundle, promise, and function stack frames. The final evaluation tree is built on the assumption that the correct evaluation tree is the one with the longest execution time.
Example policy:
To generate the profiling tree, run:
sudo /var/cfengine/bin/cf-agent -Kpf ~/profiler5.cfDepends on NorthernTechHQ/libntech#258