Skip to content
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

[pysa] Add a high level API for step logging #845

Open
arthaud opened this issue May 1, 2024 · 0 comments
Open

[pysa] Add a high level API for step logging #845

arthaud opened this issue May 1, 2024 · 0 comments

Comments

@arthaud
Copy link
Contributor

arthaud commented May 1, 2024

We currently use the following pattern to log a Pysa analysis step (e.g, call graph builting, type checking, etc.):

let timer = Timer.start () in
let () = Log.info "Fetching initial callables to analyze..." in
let initial_callables =
  Interprocedural.FetchCallables.from_qualifiers
    ~scheduler
    ~configuration
    ~pyre_api
    ~include_unit_tests:false
    ~qualifiers
in
Statistics.performance
  ~name:"Fetched initial callables to analyze"
  ~phase_name:"Fetching initial callables to analyze"
  ~timer
  ~integers:(Interprocedural.FetchCallables.get_stats initial_callables)
  ();
initial_callables

For instance: https://github.com/facebook/pyre-check/blob/main/source/interprocedural_analyses/taint/taintAnalysis.ml#L723-L743

It would be better to have a proper API that avoids code duplication:

let step_log = StepLogger.start
  ~start:"Fetching initial callables to analyze"
  ~end:"Fetched initial callables to analyze""
in
(* code of the step *)
let initial_callables =
  Interprocedural.FetchCallables.from_qualifiers
    ~scheduler
    ~configuration
    ~pyre_api
    ~include_unit_tests:false
    ~qualifiers
in
StepLogger.end ~integers:(Interprocedural.FetchCallables.get_stats initial_callables);
initial_callables

This is tracked internally by T184908437.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant