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

Improve startup performance #1412

Open
gsingh93 opened this issue Dec 4, 2022 · 5 comments
Open

Improve startup performance #1412

gsingh93 opened this issue Dec 4, 2022 · 5 comments

Comments

@gsingh93
Copy link
Member

gsingh93 commented Dec 4, 2022

Startup performance is not great, particularly when debugging a kernel with QEMU.

Some preliminary profiling with cProfile shows that syntax highlighting is a major issue, with set syntax-highlight off leading to a 43% improvement.

gdb-pt-dump also takes a significant amount of time, but there's work for a Rust rewrite underway, and in the meantime I plan to add an option to completely disable getting memory maps in QEMU to improve performance.

We should investigate these, and other issues, and start tracking startup time as part of every PR.

Edit: Seems like this call to print_help accounts for 8% of startup time:

self.parser.print_help(file)

@disconnect3d
Copy link
Member

Pretty sure the memoization improvements from #1453 may help here, at least a little bit.

@gsingh93 gsingh93 modified the milestones: March 2023, Future Jan 4, 2023
@gsingh93
Copy link
Member Author

Leaving a link to this here as something we can explore for performance benchmarking: https://pytest-benchmark.readthedocs.io/en/latest/

@gsingh93 gsingh93 modified the milestones: 2023.06, Future Mar 19, 2023
@gsingh93 gsingh93 modified the milestones: 2023.09, Future Jun 30, 2023
@disconnect3d
Copy link
Member

disconnect3d commented Dec 28, 2023

Two things to profile this:

  1. PYTHONPROFILEIMPORTTIME=1 gdb --quiet --batch - and checking import times (thx to https://stackoverflow.com/questions/34755728/profile-python-import-times/55603444#55603444)
  2. PWNDBG_PROFILE=1 time gdb --quiet --batch && ./profiling/print_stats.py ./pwndbg-load.pstats > x && head -n50 x

Some quick observations:

  • loading pwndbg on a low resource VPS takes 0.8-1s
  • importing pwnlib is heavy
  • importing requests - from ai.py is heavy

We should at least:

  • defer import of requests to when it is actually needed in ai.py
  • import only the used functionalities from pwnlib, not the whole module -- this may or may not help

@disconnect3d
Copy link
Member

@disconnect3d
Copy link
Member

Fwiw we should investigate "freezing" or "frozen" modules, since this may improve startup time if we would do it for ALL Pwndbg code and its dependencies code.

We could do it for Pwndbg releases?

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

No branches or pull requests

2 participants