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

feat(wirey): adds cpu profiling #34

Merged
merged 2 commits into from
Aug 21, 2024
Merged

Conversation

RohanSreerama5
Copy link

@RohanSreerama5 RohanSreerama5 commented Aug 20, 2024

This is part of an effort to do some CPU profiling of the Wirey binary. This will bring visibility into Wirey's "hot" functions and how we can go about optimizing the code better. (hot refers to the most frequently invoked functions.)

First deploy this binary into production. Then, we can see the following:

CPU profile: curl http://localhost:6060/debug/pprof/profile?seconds=30 (Collects 30 seconds of CPU profiling data)
Heap profile: curl http://localhost:6060/debug/pprof/heap
Goroutine profile: curl http://localhost:6060/debug/pprof/goroutine

It can also create a Flame graph to indicate the most frequently used functions across the call stack.

What is paramount here is that the CPU profiling is done on a production load, so that the optimizations derived from this effort impact usage behavior of actual users of Wirey.

BTW:
With Profile Guided Optimization (PGO), Golang will also perform optimizations on such "hot" functions and give you back data about the performance increase it might've yielded. Optimizations refer to compiler passes such as inlining, constant folding, etc etc

We can run profiling as optional setting like so:
./myapp -enable-profiling=true -profile-addr="localhost:6061"

@marcotuna
Copy link
Contributor

Hi @RohanSreerama5,

Thanks for adding the profiling feature! I have a couple of suggestions:

  • Make Profiling Optional: Since profiling can introduce some overhead to the application, and the current implementation opens a port by default, it would be better if we could enable it through a configuration setting or command-line flag. This way, we only turn it on when we really need it.

  • Listen Address: It would be helpful if the host and port for profiling could be set in a config file or as a command-line option. This gives us more flexibility and avoids possible conflicts with other services.

What do you think?

@RohanSreerama5
Copy link
Author

Hi @RohanSreerama5,

Thanks for adding the profiling feature! I have a couple of suggestions:

  • Make Profiling Optional: Since profiling can introduce some overhead to the application, and the current implementation opens a port by default, it would be better if we could enable it through a configuration setting or command-line flag. This way, we only turn it on when we really need it.
  • Listen Address: It would be helpful if the host and port for profiling could be set in a config file or as a command-line option. This gives us more flexibility and avoids possible conflicts with other services.

What do you think?

Totally agree, that's a great idea. I've pushed up a commit to address this. Should be able to invoke it like so:
./myapp -enable-profiling=true -profile-addr="localhost:6061".

@RohanSreerama5 RohanSreerama5 changed the base branch from master to devel August 21, 2024 18:12
@RohanSreerama5 RohanSreerama5 merged commit e31e402 into devel Aug 21, 2024
1 check passed
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

Successfully merging this pull request may close these issues.

3 participants