Skip to content

feat: add a ttfb.py dev-script for testing HA deployments - #794

Merged
kalbasit merged 1 commit into
mainfrom
02-07-feat_add_a_ttfb.py_dev-script_for_testing_ha_deployments
Feb 7, 2026
Merged

kalbasit merged 1 commit into
mainfrom
02-07-feat_add_a_ttfb.py_dev-script_for_testing_ha_deployments

Conversation

@kalbasit

@kalbasit kalbasit commented Feb 7, 2026

Copy link
Copy Markdown
Owner

The ttfb.py (time to first byte) measures how long it takes ncps to
respond back with the first byte, very useful to manually detect
regressions causing #660

The ttfb.py (time to first byte) measures how long it takes ncps to
respond back with the first byte, very useful to manually detect
regressions causing #660
@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. enhancement New feature or request labels Feb 7, 2026
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @kalbasit, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a new Python-based development script, ttfb.py, aimed at enhancing the diagnostic capabilities for High Availability deployments. The script measures the Time To First Byte (TTFB) for Nix Archive (NAR) requests across various ports, providing a crucial tool for identifying and analyzing performance bottlenecks or regressions, particularly those related to slow response times.

Highlights

  • New ttfb.py script: Introduces a Python development script to measure Time To First Byte (TTFB) for NAR (Nix Archive) requests.
  • HA deployment testing: The script is designed to test High Availability (HA) deployments by querying multiple ports in parallel.
  • Regression detection: Aims to help manually detect performance regressions, specifically referencing issue ncps does not handle NAR streaming in a multi-instance HA setup #660.
  • Dependency update: Adds the httpx Python library to the nix/devshells/flake-module.nix to support the new script.
Changelog
  • dev-scripts/ttfb.py
    • Added a new Python script that uses asyncio and httpx to fetch .narinfo and then the corresponding NAR path from multiple localhost ports.
    • Measures and reports Time To First Byte (TTFB) and total response time for each port.
    • Includes argument parsing for the Nix store hash and handles various error conditions like timeouts or missing NAR URL.
  • nix/devshells/flake-module.nix
    • Modified to include httpx in the buildInputs for the default development shell's Python environment. This ensures that the ttfb.py script has its necessary dependencies available within the Nix development environment.
Activity
  • The pull request introduces a new development script to address a specific diagnostic need. No further review comments or activities have been recorded yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩

kalbasit commented Feb 7, 2026

Copy link
Copy Markdown
Owner Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@dosubot

dosubot Bot commented Feb 7, 2026

Copy link
Copy Markdown

Related Documentation

Checked 7 published document(s) in 1 knowledge base(s). No updates required.

How did I do? Any feedback?  Join Discord

Comment thread dev-scripts/ttfb.py Dismissed
Comment thread dev-scripts/ttfb.py Dismissed

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new development script, ttfb.py, to measure the 'time to first byte' for HA deployments. This is a valuable tool for performance testing. The script is well-written, leveraging asyncio and httpx for parallel requests. My feedback focuses on improving the script's robustness by suggesting more specific exception handling and making the response parsing more resilient. The update to the Nix development shell to include httpx is correct and necessary.

Comment thread dev-scripts/ttfb.py
Comment on lines +37 to +38
except Exception as e:
return {"port": port, "error": str(e)}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Catching a generic Exception is too broad and can hide unexpected errors or bugs in the code. It's better to catch more specific exceptions. For network-related errors other than timeouts, httpx.RequestError is a good choice. A similar broad exception is caught on line 55.

Suggested change
except Exception as e:
return {"port": port, "error": str(e)}
except httpx.RequestError as e:
return {"port": port, "error": str(e)}

Comment thread dev-scripts/ttfb.py
Comment on lines +61 to +65
nar_path = next(
line.split(": ")[1].strip()
for line in resp.text.splitlines()
if line.startswith("URL:")
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The use of line.split(': ') to parse the narinfo response is a bit fragile. It assumes there will always be a single space after the colon. To make the parsing more robust against formatting variations (e.g., no space, multiple spaces), it's better to split only on the first colon and then strip whitespace from the result.

Suggested change
nar_path = next(
line.split(": ")[1].strip()
for line in resp.text.splitlines()
if line.startswith("URL:")
)
nar_path = next(
line.split(":", 1)[1].strip()
for line in resp.text.splitlines()
if line.startswith("URL:")
)

@codecov

codecov Bot commented Feb 7, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.41%. Comparing base (a499284) to head (9586a66).
⚠️ Report is 77 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #794   +/-   ##
=======================================
  Coverage   85.41%   85.41%           
=======================================
  Files           2        2           
  Lines         480      480           
=======================================
  Hits          410      410           
  Misses         65       65           
  Partials        5        5           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@kalbasit
kalbasit merged commit 033b2ca into main Feb 7, 2026
18 checks passed
@kalbasit
kalbasit deleted the 02-07-feat_add_a_ttfb.py_dev-script_for_testing_ha_deployments branch February 7, 2026 21:23
@kalbasit kalbasit added the backport release-0.8 Backport PR automatically label Feb 15, 2026
@kalbasit

Copy link
Copy Markdown
Owner Author

Backport failed for release-0.8, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin release-0.8
git worktree add -d .worktree/backport-794-to-release-0.8 origin/release-0.8
cd .worktree/backport-794-to-release-0.8
git switch --create backport-794-to-release-0.8
git cherry-pick -x 033b2ca46225116ceebbaf76cb638bf5dd538c0b

kalbasit added a commit that referenced this pull request Feb 15, 2026
]

The ttfb.py (time to first byte) measures how long it takes ncps to
respond back with the first byte, very useful to manually detect
regressions causing #660

(cherry picked from commit 033b2ca)
kalbasit added a commit that referenced this pull request Feb 15, 2026
]

The ttfb.py (time to first byte) measures how long it takes ncps to
respond back with the first byte, very useful to manually detect
regressions causing #660

(cherry picked from commit 033b2ca)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport release-0.8 Backport PR automatically enhancement New feature or request size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants