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

fix(p2p): cache responses to serve without roundtrip to db #2352

Open
wants to merge 28 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
ba6bdab
chore: changelog
rymnc Oct 14, 2024
5a51e0c
test: arc mutex on cachedview, reset every 10 sec
rymnc Oct 14, 2024
8079739
fix: err
rymnc Oct 14, 2024
19a32f3
fix(p2p): use dashmap, remove mutex, remove instantiation with view
rymnc Oct 14, 2024
805a866
fix: fmt
rymnc Oct 14, 2024
fd0aea0
Merge branch 'master' into fix/p2p-round-robin
rymnc Oct 15, 2024
c5db7a6
chore: add metrics to cache hits/misses
rymnc Oct 15, 2024
b4763be
fix: clippy
rymnc Oct 15, 2024
b6bbf61
Merge branch 'master' into fix/p2p-round-robin
rymnc Oct 15, 2024
5b03fa0
chore: refactor cached_view into own module
rymnc Oct 15, 2024
6422210
chore: retain time based clear, but cache is now on a per block basis…
rymnc Oct 16, 2024
2b2a8fb
fix: metrics logging and clearing
rymnc Oct 16, 2024
0a3724d
Merge branch 'master' into fix/p2p-round-robin
rymnc Oct 28, 2024
f597ac9
fix: fmt and clippy
rymnc Oct 28, 2024
25515ee
Update CHANGELOG.md
rymnc Oct 29, 2024
e481e6a
Update crates/services/p2p/src/cached_view.rs
rymnc Oct 29, 2024
5ad5093
fix: make fetch generic
rymnc Oct 29, 2024
a884429
Merge branch 'master' into fix/p2p-round-robin
rymnc Oct 29, 2024
f16cb2f
fix: use let-else pattern
rymnc Oct 30, 2024
c6f00af
Merge branch 'master' into fix/p2p-round-robin
rymnc Oct 30, 2024
1630e2b
fix: add test
rymnc Oct 30, 2024
22d09cf
Merge branch 'master' into fix/p2p-round-robin
rymnc Oct 30, 2024
09d7bd2
fix: call run multiple times until heartbeat report is available
rymnc Oct 30, 2024
3972a47
fix: clippy
rymnc Oct 30, 2024
69de071
fix: dont allow cache reset interval to swallow runtime of other tasks
rymnc Oct 30, 2024
c634764
Merge branch 'master' into fix/p2p-round-robin
rymnc Oct 30, 2024
7a0a776
chore: visibility of CachedView
rymnc Nov 1, 2024
d897cba
chore: todos
rymnc Nov 14, 2024
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- [2310](https://github.com/FuelLabs/fuel-core/pull/2310): The `metrics` command-line parameter has been replaced with `disable-metrics`. Metrics are now enabled by default, with the option to disable them entirely or on a per-module basis.
- [2341](https://github.com/FuelLabs/fuel-core/pull/2341): The maximum number of processed coins from the `coins_to_spend` query is limited to `max_inputs`.

### Fixed

- [2352](https://github.com/FuelLabs/fuel-core/pull/2352): Cache p2p responses to serve without roundtrip to db.

## [Version 0.39.0]

### Added
Expand Down
15 changes: 15 additions & 0 deletions Cargo.lock

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

26 changes: 26 additions & 0 deletions crates/metrics/src/p2p_metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,22 @@ use std::sync::OnceLock;
pub struct P2PMetrics {
pub unique_peers: Counter,
pub blocks_requested: Gauge,
pub p2p_req_res_cache_hits: Counter,
pub p2p_req_res_cache_misses: Counter,
}

impl P2PMetrics {
fn new() -> Self {
let unique_peers = Counter::default();
let blocks_requested = Gauge::default();
let p2p_req_res_cache_hits = Counter::default();
let p2p_req_res_cache_misses = Counter::default();

let metrics = P2PMetrics {
unique_peers,
blocks_requested,
p2p_req_res_cache_hits,
p2p_req_res_cache_misses,
};

let mut registry = global_registry().registry.lock();
Expand All @@ -33,6 +39,18 @@ impl P2PMetrics {
metrics.blocks_requested.clone()
);

registry.register(
"P2p_Req_Res_Cache_Hits",
"A Counter which keeps track of the number of cache hits for the p2p req/res protocol",
metrics.p2p_req_res_cache_hits.clone()
);

registry.register(
"P2p_Req_Res_Cache_Misses",
"A Counter which keeps track of the number of cache misses for the p2p req/res protocol",
metrics.p2p_req_res_cache_misses.clone()
);

metrics
}
}
Expand All @@ -50,3 +68,11 @@ pub fn increment_unique_peers() {
pub fn set_blocks_requested(count: usize) {
p2p_metrics().blocks_requested.set(count as i64);
}

pub fn increment_p2p_req_res_cache_hits() {
p2p_metrics().p2p_req_res_cache_hits.inc();
}

pub fn increment_p2p_req_res_cache_misses() {
p2p_metrics().p2p_req_res_cache_misses.inc();
}
1 change: 1 addition & 0 deletions crates/services/p2p/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ description = "Fuel client networking"
[dependencies]
anyhow = { workspace = true }
async-trait = { workspace = true }
dashmap = "6.1.0"
netrome marked this conversation as resolved.
Show resolved Hide resolved
fuel-core-chain-config = { workspace = true }
fuel-core-metrics = { workspace = true } # TODO make this a feature
fuel-core-services = { workspace = true, features = ["sync-processor"] }
Expand Down
Loading
Loading