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

NETOBSERV-754: add pprof, improve memory footprint #449

Merged
merged 5 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add development notes
  • Loading branch information
jotak committed Oct 5, 2023
commit 7b54d818bc2043d91f098af0074e171d3b06ec51
13 changes: 11 additions & 2 deletions .mk/development.mk
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,18 @@ set-release-kind-downstream:
kubectl rollout status -n $(NAMESPACE) --timeout=60s deployment netobserv-controller-manager
kubectl wait -n $(NAMESPACE) --timeout=60s --for condition=Available=True deployment netobserv-controller-manager

.PHONY: enable-pprof
enable-pprof:
.PHONY: pprof
pprof:
@echo -e "\n==> Enabling pprof... Check https://github.com/netobserv/network-observability-operator/blob/main/DEVELOPMENT.md#profiling for help."
kubectl -n $(NAMESPACE) set env deployment netobserv-controller-manager -c "manager" PROFILING_BIND_ADDRESS=:6060
@echo -e "\n==> Redeploying..."
kubectl rollout status -n $(NAMESPACE) --timeout=60s deployment netobserv-controller-manager
kubectl wait -n $(NAMESPACE) --timeout=60s --for condition=Available=True deployment netobserv-controller-manager
sleep 2
$(MAKE) pprof-pf

.PHONY: pprof-pf
pprof-pf:
@echo -e "\n==> Port-forwarding..."
oc get pods
kubectl port-forward -n $(NAMESPACE) $(shell kubectl get pod -l app=netobserv-operator -o jsonpath="{.items[0].metadata.name}") 6060
15 changes: 15 additions & 0 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -384,3 +384,18 @@ Remove the tag after you tested:
git tag -d "0.0.0-rc0"
git push --delete upstream 0.0.0-rc0
```

## Profiling

You can use `pprof` for profiling. Run `pprof` make target to start listening and port-forward on 6060:

```bash
make pprof
```

In another terminal, run for instance:

```bash
curl "http://localhost:6060/debug/pprof/heap?gc" -o /tmp/heap
go tool pprof -http localhost:3435 /tmp/heap
```