Skip to content

Comments

chore: add diagnostic logging to JSONRPC handlers (Fixes #360)#361

Merged
karthiknadig merged 2 commits intomainfrom
chore/issue-360
Feb 25, 2026
Merged

chore: add diagnostic logging to JSONRPC handlers (Fixes #360)#361
karthiknadig merged 2 commits intomainfrom
chore/issue-360

Conversation

@karthiknadig
Copy link
Member

Add diagnostic logging to JSONRPC handlers that were missing visibility, particularly handle_configure which can hang during glob expansion.

  • handle_configure: info! on entry/exit with elapsed time, trace! for each glob pattern being expanded, warn! if glob expansion exceeds 5 seconds (client timeout is 30s). Also moved glob expansion outside the write lock to avoid blocking configuration readers during slow filesystem traversal.
  • handle_find: trace! on entry/exit with elapsed time and result count
  • handle_conda_telemetry: trace! on entry/exit

This addresses the diagnostic gap where PET produces zero output during a configure request that times out (e.g., when environmentDirectories contains recursive patterns like **/.venv on large directory trees).

Fixes #360
Related: #357

@karthiknadig karthiknadig requested a review from Copilot February 25, 2026 03:29
@github-actions
Copy link

github-actions bot commented Feb 25, 2026

Test Coverage Report (Linux)

Metric Value
Current Coverage 58.1%
Base Branch Coverage 58.3%
Delta -.2% ❌

Coverage decreased. Please add tests for new code.

@github-actions
Copy link

github-actions bot commented Feb 25, 2026

Performance Report (Linux) ✅

Metric PR (P50) PR (P95) Baseline (P50) Delta Change
Server Startup 1ms 1ms 1ms 0ms 0%
Full Refresh 76ms 223ms 78ms -2ms 0%

Results based on 10 iterations. P50 = median, P95 = 95th percentile.


Legend
  • 🚀 Significant speedup (>100ms faster)
  • ✅ Faster than baseline
  • ➖ No significant change
  • 🔺 Slower than baseline (>100ms)
  • ⚠️ Significant slowdown (>500ms)

@github-actions
Copy link

github-actions bot commented Feb 25, 2026

Performance Report (Windows) ✅

Metric PR (P50) PR (P95) Baseline (P50) Delta Change
Server Startup 9ms 12ms 10ms -1ms -10%
Full Refresh 157ms 2151ms 181ms -24ms -13.3%

Results based on 10 iterations. P50 = median, P95 = 95th percentile.


Legend
  • 🚀 Significant speedup (>100ms faster)
  • ✅ Faster than baseline
  • ➖ No significant change
  • 🔺 Slower than baseline (>100ms)
  • ⚠️ Significant slowdown (>500ms)

@github-actions
Copy link

github-actions bot commented Feb 25, 2026

Test Coverage Report (Windows)

Metric Value
Current Coverage 54.44%
Base Branch Coverage 54.58%
Delta -0.14% ❌

Coverage decreased. Please add tests for new code.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds diagnostic logging around JSONRPC request handlers (notably configure) to improve observability when requests are slow (e.g., expensive glob expansion), and reduces lock contention by moving glob expansion outside the configuration write lock.

Changes:

  • Add entry/exit timing logs for handle_configure, plus tracing around glob expansion and a warning when expansion is slow.
  • Add timing/result-count trace logging to handle_find.
  • Add trace logging around conda telemetry collection.
Comments suppressed due to low confidence (1)

crates/pet/src/jsonrpc.rs:458

  • Same timing note as handle_configure: SystemTime::elapsed() isn’t monotonic and can produce an error if the clock moves backwards. Using Instant avoids that and makes the logged durations reliable.
                let now = SystemTime::now();
                trace!("Finding environments in {:?}", find_options.search_path);
                let global_env_search_paths: Vec<PathBuf> =
                    get_search_paths_from_env_variables(context.os_environment.as_ref());

                let collect_reporter = Arc::new(collect::create_reporter());
                let reporter = CacheReporter::new(collect_reporter.clone());
                if find_options.search_path.is_file() {
                    identify_python_executables_using_locators(
                        vec![find_options.search_path.clone()],
                        &context.locators,
                        &reporter,
                        &global_env_search_paths,
                    );
                } else {
                    find_python_environments_in_workspace_folder_recursive(
                        &find_options.search_path,
                        &reporter,
                        &context.locators,
                        &global_env_search_paths,
                        context
                            .configuration
                            .read()
                            .unwrap()
                            .clone()
                            .environment_directories
                            .as_deref()
                            .unwrap_or(&[]),
                    );
                }

                let envs = collect_reporter
                    .environments
                    .lock()
                    .expect("environments mutex poisoned")
                    .clone();
                trace!(
                    "Find completed in {:?}, found {} environments in {:?}",
                    now.elapsed().unwrap_or_default(),
                    envs.len(),
                    find_options.search_path
                );

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

@karthiknadig karthiknadig enabled auto-merge (squash) February 25, 2026 03:57
@karthiknadig karthiknadig merged commit a7fb3b8 into main Feb 25, 2026
34 checks passed
@karthiknadig karthiknadig deleted the chore/issue-360 branch February 25, 2026 06:14
@github-actions
Copy link

github-actions bot commented Feb 25, 2026

Performance Report (macOS)

Metric PR (P50) PR (P95) Baseline (P50) Delta
Server Startup 48ms 488ms 48ms 0ms
Full Refresh 92ms 25186ms 93ms -1ms

Results based on 10 iterations. P50 = median, P95 = 95th percentile.


Legend
  • 🚀 Significant speedup (>100ms faster)
  • ✅ Faster than baseline
  • ➖ No significant change
  • 🔺 Slower than baseline (>100ms)
  • ⚠️ Significant slowdown (>500ms)

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.

Add diagnostic logging to configure and other JSONRPC handlers

2 participants