Skip to content

feat(prefork): add support for process monitoring and callbacks in prefork mode#4037

Merged
ReneWerner87 merged 7 commits intomainfrom
prefork_optimization
Apr 11, 2026
Merged

feat(prefork): add support for process monitoring and callbacks in prefork mode#4037
ReneWerner87 merged 7 commits intomainfrom
prefork_optimization

Conversation

@ReneWerner87
Copy link
Copy Markdown
Member

Modified fasthttp version
ReneWerner87/fasthttp@master...ReneWerner87:fasthttp:prefork_optimization
PR to fasthttp is coming

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Jan 28, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 5641f645-e898-4c1a-9641-65487cdc45b5

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch prefork_optimization

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@ReneWerner87 ReneWerner87 added this to v3 Jan 28, 2026
@ReneWerner87 ReneWerner87 added this to the v3 milestone Jan 28, 2026
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @ReneWerner87, 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 significantly refactors Fiber's prefork implementation by integrating the fasthttp/prefork package. This change introduces robust process monitoring capabilities, including automatic child process recovery, and extends prefork support to custom listeners via a new callback mechanism. The goal is to provide a more stable and flexible prefork experience for Fiber applications.

Highlights

  • Integration with fasthttp/prefork: Fiber's internal prefork implementation has been replaced by the more robust fasthttp/prefork package, centralizing prefork logic and leveraging its features.
  • Child Process Monitoring and Recovery: The prefork mode now includes built-in monitoring for child process crashes and automatic recovery, configurable via a new PreforkRecoverThreshold in ListenConfig.
  • Enhanced Custom Listener Support: The app.Listener() method now fully supports prefork mode through a new OnPreforkServe callback, allowing each child process to create its own reuseport listener, removing a previous limitation.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

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.

Copy link
Copy Markdown
Contributor

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

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 refactors the prefork implementation to leverage fasthttp's native capabilities, introducing OnPreforkServe for custom listeners and PreforkRecoverThreshold for process monitoring. While these are valuable additions, a critical supply chain vulnerability has been identified: the go.mod file replaces a core dependency with a personal fork using a suspicious, future-dated pseudo-version. This practice should be remediated by using official, verified dependencies. Furthermore, there is a critical issue with a missing type definition that will prevent compilation, and an opportunity to refactor duplicated code to enhance maintainability.

@ReneWerner87 ReneWerner87 modified the milestones: v3.0.0, v3 Feb 1, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Feb 6, 2026

Codecov Report

❌ Patch coverage is 92.85714% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.27%. Comparing base (6c19f48) to head (3fe1c7d).

Files with missing lines Patch % Lines
prefork.go 92.50% 1 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4037      +/-   ##
==========================================
+ Coverage   91.16%   91.27%   +0.10%     
==========================================
  Files         123      124       +1     
  Lines       11855    11841      -14     
==========================================
  Hits        10808    10808              
+ Misses        659      648      -11     
+ Partials      388      385       -3     
Flag Coverage Δ
unittests 91.27% <92.85%> (+0.10%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.

@ReneWerner87 ReneWerner87 force-pushed the prefork_optimization branch from d383b0c to 67a27e7 Compare April 11, 2026 18:09
ReneWerner87 and others added 3 commits April 11, 2026 20:09
…tion

Replace Fiber's own prefork implementation with fasthttp's prefork package.
This eliminates duplicated process management logic and adds new features:

- IsChild() now delegates to prefork.IsChild()
- Master process uses fasthttp's recovery loop (RecoverThreshold)
- Callbacks (OnChildSpawn, OnMasterReady, OnChildRecover) integrate
  Fiber's hooks system (OnFork, OnListen, startup message)
- CommandProducer enables clean test injection (replaces testPreforkMaster)
- OnMasterDeath replaces Fiber's watchMaster (now in fasthttp)
- New PreforkRecoverThreshold field in ListenConfig
- prefork_logger.go adapts Fiber's logger to fasthttp's Logger interface
- go.mod uses replace directive for local fasthttp development

Code reduction: ~200 lines of process management removed from Fiber.
All existing tests adapted for recovery behavior (ErrOverRecovery).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Ensures deterministic and fast execution regardless of GOMAXPROCS count.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@ReneWerner87 ReneWerner87 force-pushed the prefork_optimization branch from 67a27e7 to cfc5a9d Compare April 11, 2026 18:10
ReneWerner87 and others added 3 commits April 11, 2026 20:17
Use github.com/ReneWerner87/fasthttp@2802b1a (prefork_optimization branch)
instead of local ../fasthttp path, so CI and other developers can resolve
the dependency.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Includes fix for ListenAndServeTLS parameter order preservation.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- prefork_logger.go: use grouped import declaration
- prefork.go: rename unused 'files' parameter to '_'
- prefork.go: wrap external errors from cmd.Start() and ListenAndServe()

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Member

@gaby gaby left a comment

Choose a reason for hiding this comment

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

Few questions, over all this makes fiber prefork more simple and moves a lot of the boilerplate to fasthttp which is great.

- Move windowsOS constant to constants.go (global consts file)
- Make prefork logger configurable via ListenConfig.PreforkLogger
- Define PreforkLoggerInterface for custom logger implementations
- Use logger.Printf instead of direct log.Warnf in OnChildRecover
- Remove unused log import from prefork.go

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@ReneWerner87 ReneWerner87 merged commit 3fe1c7d into main Apr 11, 2026
16 of 17 checks passed
@ReneWerner87 ReneWerner87 deleted the prefork_optimization branch April 11, 2026 19:29
@github-project-automation github-project-automation bot moved this to Done in v3 Apr 11, 2026
@ReneWerner87 ReneWerner87 restored the prefork_optimization branch April 11, 2026 19:31
@ReneWerner87
Copy link
Copy Markdown
Member Author

replaced by #4210

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants