reduce processSessions log spam and fix kcov bottleneck. raise TIMING
threshold from 1ms to 10ms, demote ADAPTIVE in_flight log to debug, switch 3 tests from full init to initForTesting eliminating thread pool overhead under kcov
This commit is contained in:
@@ -1106,7 +1106,6 @@ pub const FileSharingManager = struct {
|
||||
/// Dynamically adjusts max_concurrent_downloads based on network health
|
||||
adaptive_controller: ?AdaptiveConcurrencyController,
|
||||
/// TIMING: Counter for periodic timing logs
|
||||
timing_log_counter: u32 = 0,
|
||||
|
||||
// ========================================================================
|
||||
// HIGH-5 FIX: LOCK ORDERING DOCUMENTATION
|
||||
@@ -2565,7 +2564,7 @@ pub const FileSharingManager = struct {
|
||||
// Debug logging for adaptive controller state
|
||||
if (total_stuck > 0 or total_in_flight > 50) {
|
||||
const stats = ctrl.getStats();
|
||||
std.log.info("ADAPTIVE: in_flight={}, stuck={}, timeouts_recorded={}, success={d:.1}%, timeout={d:.1}%, concurrency={}", .{
|
||||
std.log.debug("ADAPTIVE: in_flight={}, stuck={}, timeouts_recorded={}, success={d:.1}%, timeout={d:.1}%, concurrency={}", .{
|
||||
total_in_flight,
|
||||
total_stuck,
|
||||
weighted_timeouts,
|
||||
@@ -2606,12 +2605,10 @@ pub const FileSharingManager = struct {
|
||||
// Clean up completed/failed sessions
|
||||
self.cleanupCompletedSessions();
|
||||
|
||||
// TIMING: Log timing breakdown (only when significant time spent)
|
||||
// TIMING: Log timing breakdown only when significant (>10ms)
|
||||
const total_time = std.time.nanoTimestamp() - timer_start;
|
||||
const total_ms = @as(f64, @floatFromInt(total_time)) / 1_000_000.0;
|
||||
// Log every 100th call or when > 1ms to reduce spam while getting data
|
||||
self.timing_log_counter +%= 1;
|
||||
if (total_ms > 1.0 or self.timing_log_counter % 100 == 0) {
|
||||
if (total_ms > 10.0) {
|
||||
const p1_ms = @as(f64, @floatFromInt(phase1_time)) / 1_000_000.0;
|
||||
const p2_ms = @as(f64, @floatFromInt(phase2_time)) / 1_000_000.0;
|
||||
const p3_ms = @as(f64, @floatFromInt(phase3_time)) / 1_000_000.0;
|
||||
@@ -5250,7 +5247,7 @@ test "file sharing session creation" {
|
||||
test "file sharing manager basic operations" {
|
||||
const allocator = testing.allocator;
|
||||
const config = FileSharingConfig.default();
|
||||
var manager = try FileSharingManager.init(config, allocator);
|
||||
var manager = try FileSharingManager.initForTesting(config, allocator);
|
||||
defer manager.deinit();
|
||||
|
||||
// Test initial stats
|
||||
@@ -5268,7 +5265,7 @@ test "file sharing manager basic operations" {
|
||||
test "file sharing manager processing" {
|
||||
const allocator = testing.allocator;
|
||||
const config = FileSharingConfig.default();
|
||||
var manager = try FileSharingManager.init(config, allocator);
|
||||
var manager = try FileSharingManager.initForTesting(config, allocator);
|
||||
defer manager.deinit();
|
||||
|
||||
// Process empty manager (should not crash)
|
||||
@@ -5527,7 +5524,7 @@ test "handlePieceData rejects bad hash and blacklists peer" {
|
||||
test "blacklisted peer cannot send pieces" {
|
||||
const allocator = testing.allocator;
|
||||
const config = FileSharingConfig.default();
|
||||
var manager = try FileSharingManager.init(config, allocator);
|
||||
var manager = try FileSharingManager.initForTesting(config, allocator);
|
||||
defer manager.deinit();
|
||||
|
||||
const peer_id: [32]u8 = [_]u8{77} ** 32;
|
||||
|
||||
Reference in New Issue
Block a user