Skip to content

Commit

Permalink
Merge pull request #94 from firstbatchxyz/erhant/cpu-usage
Browse files Browse the repository at this point in the history
CPU Usage diagnostics & fix
  • Loading branch information
erhant authored Aug 16, 2024
2 parents 97782e1 + e579e2a commit 52d4772
Show file tree
Hide file tree
Showing 11 changed files with 1,086 additions and 35 deletions.
10 changes: 7 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
/target
.env*
!.env.example
.vscode
.DS_Store
/qdrant_storage

# ignore all env except example
.env*
!.env.example


flamegraph.svg
27 changes: 24 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ edition = "2021"
license = "Apache-2.0"
readme = "README.md"

[profile.profiling]
inherits = "release"
debug = true

[dependencies]
tokio-util = { version = "0.7.10", features = ["rt"] }
tokio = { version = "1", features = ["macros", "rt-multi-thread", "signal"] }
Expand Down Expand Up @@ -58,6 +62,7 @@ libp2p-identity = { version = "0.2.9", features = ["secp256k1", "ed25519"] }
tracing = { version = "0.1.40" }
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
public-ip = "0.2.2"
dotenvy = "0.15.7"


[dev-dependencies]
Expand Down
14 changes: 9 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ ifneq (,$(wildcard ./.env))
endif

###############################################################################
.PHONY: launch # | Run with INFO log-level & release mode
.PHONY: launch # | Run with INFO log-level in release mode
launch:
RUST_LOG=info cargo run --release
RUST_LOG=warn,dkn_compute=info cargo run --release

.PHONY: run # | Run with INFO log-level
run:
RUST_LOG=none,dkn_compute=info cargo run
RUST_LOG=warn,dkn_compute=info cargo run

.PHONY: debug # | Run with DEBUG log-level with INFO log-level workflows
debug:
RUST_LOG=none,dkn_compute=debug,ollama_workflows=info cargo run
RUST_LOG=warn,dkn_compute=debug,ollama_workflows=info cargo run

.PHONY: trace # | Run with crate-level TRACE logging
trace:
Expand All @@ -25,6 +25,10 @@ trace:
build:
cargo build

.PHONY: profile # | Profile with flamegraph at dev level
profile:
cargo flamegraph --root --profile=profiling

.PHONY: version # | Print version
version:
@cargo pkgid | cut -d@ -f2
Expand Down
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,20 @@ make lint # clippy
make format # rustfmt
```

### Profiling

To create a flamegraph of the application, do:

```sh
make profile
```

This will create a profiling build that inherits `release` mode, except with debug information.

> [!NOTE]
>
> Profiling requires superuser access.
## License

This project is licensed under the [Apache License 2.0](https://opensource.org/license/Apache-2.0).
Loading

0 comments on commit 52d4772

Please sign in to comment.