Skip to content

[skip-ci] Add comprehensive ProxySQL_Poll usage documentation throughout codebase#5286

Merged
renecannao merged 1 commit intov3.0from
v3.0-poll_doc
Jan 9, 2026
Merged

[skip-ci] Add comprehensive ProxySQL_Poll usage documentation throughout codebase#5286
renecannao merged 1 commit intov3.0from
v3.0-poll_doc

Conversation

@renecannao
Copy link
Contributor

Summary

Add comprehensive ProxySQL_Poll usage documentation throughout the ProxySQL codebase to better explain how the core I/O multiplexing system is used and integrated.

What was documented

Core Class Documentation

  • lib/ProxySQL_Poll.cpp: Enhanced with architecture overview, template specialization, memory management, and event processing pipeline explanations

Usage Pattern Documentation

  • lib/MySQL_Thread.cpp: Listener registration/removal, client session setup, main poll loop
  • lib/PgSQL_Thread.cpp: Equivalent PostgreSQL documentation mirroring MySQL patterns
  • lib/mysql_data_stream.cpp: Cleanup patterns and activity tracking
  • lib/PgSQL_Data_Stream.cpp: PostgreSQL equivalent patterns

Key Usage Patterns Covered

  1. Registration Pattern: mypolls.add(events, fd, data_stream, timestamp)
  2. Removal Pattern: find_index() + remove_index_fast()
  3. Activity Tracking: last_recv/sent timestamp updates
  4. Main Poll Loop: poll(mypolls.fds, mypolls.len, timeout)

Documentation Approach

  • Contextual: Documentation placed directly where code is used
  • Maintainable: No specific line numbers to avoid becoming outdated
  • Comprehensive: Explains when, why, and how each pattern is used
  • Architecture-focused: Shows integration with ProxySQL's event-driven design

Benefits

  • Developers can easily understand ProxySQL_Poll usage without searching through multiple files
  • Better maintainability with documentation that evolves with the code
  • Clear explanations of how the polling system integrates with connection management
  • Performance characteristics and optimization notes included

Test plan

This is a documentation-only change with no functional code modifications. No new tests are required, but the existing test suite should continue to pass.

[skip-ci]

Enhance ProxySQL_Poll class documentation with detailed usage patterns:

- lib/ProxySQL_Poll.cpp: Enhanced file-level documentation with architecture
  overview, template specialization, memory management, and event processing
  pipeline explanations

- lib/MySQL_Thread.cpp: Added usage documentation for listener registration,
  removal patterns, client session setup, and main poll loop

- lib/PgSQL_Thread.cpp: Added equivalent PostgreSQL usage documentation
  mirroring MySQL patterns with protocol-specific details

- lib/mysql_data_stream.cpp: Documented cleanup, receive activity tracking,
  and send activity tracking patterns

- lib/PgSQL_Data_Stream.cpp: Documented equivalent PostgreSQL data stream
  patterns for cleanup and activity tracking

All documentation is placed directly where code is used, avoiding specific
line numbers for better maintainability. Includes comprehensive explanations
 of when, why, and how ProxySQL_Poll methods are used throughout ProxySQL's
event-driven architecture.

[skip-ci]
@gemini-code-assist
Copy link

Summary of Changes

Hello @renecannao, 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 focuses on significantly improving the documentation for the ProxySQL_Poll system, which is central to ProxySQL's event-driven I/O. The goal is to provide developers with a clearer understanding of how this core component is used and integrated throughout the codebase, thereby enhancing maintainability and reducing the learning curve for new contributors. The changes are purely documentation-based, ensuring no functional impact on the existing system.

Highlights

  • Core Class Documentation: The lib/ProxySQL_Poll.cpp file has been significantly enhanced with detailed documentation covering its architecture, template specialization, memory management strategies, and the event processing pipeline. This provides a foundational understanding of ProxySQL's core I/O multiplexing engine.
  • Usage Pattern Documentation: Comprehensive documentation has been added to various files to illustrate specific usage patterns of ProxySQL_Poll. This includes lib/MySQL_Thread.cpp and lib/PgSQL_Thread.cpp for listener registration/removal, client session setup, and the main poll loop, as well as lib/mysql_data_stream.cpp and lib/PgSQL_Data_Stream.cpp for cleanup patterns and activity tracking.
  • Key Usage Patterns Covered: Specific patterns like mypolls.add(events, fd, data_stream, timestamp) for registration, find_index() followed by remove_index_fast() for removal, last_recv/sent timestamp updates for activity tracking, and the main poll(mypolls.fds, mypolls.len, timeout) loop are now clearly documented.

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

@sonarqubecloud
Copy link

sonarqubecloud bot commented Jan 9, 2026

@renecannao renecannao merged commit 9c3f6b0 into v3.0 Jan 9, 2026
1 of 2 checks passed
Copy link

@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 adds comprehensive documentation for ProxySQL_Poll usage across the codebase. The new documentation is well-structured and provides valuable insights into the I/O multiplexing system. My review focuses on improving the accuracy and maintainability of the added comments. I've identified a few typos and suggested replacing hardcoded line number references with function names to align with the documentation approach outlined in the pull request description.

* 2. Remove the socket using remove_index_fast() with the found index
*
* Usage pattern:
* int i = mypollolls.find_index(sock); // Find index by file descriptor

Choose a reason for hiding this comment

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

medium

There's a typo in the usage pattern example. mypollolls should be mypolls.

	 * int i = mypolls.find_index(sock);           // Find index by file descriptor

* or the timeout expires.
*
* Usage pattern: rc = poll(mypolls.fds, mypolls.len, ttw)
* - mypollolls.fds: Array of pollfd structures containing file descriptors and events

Choose a reason for hiding this comment

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

medium

There's a typo in the usage pattern example. mypollolls should be mypolls.

	 * - mypolls.fds: Array of pollfd structures containing file descriptors and events

* or the timeout expires.
*
* Usage pattern: rc = poll(mypolls.fds, mypolls.len, ttw)
* - mypollolls.fds: Array of pollfd structures containing file descriptors and events

Choose a reason for hiding this comment

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

medium

There's a typo in the usage pattern example. mypollolls should be mypolls.

	 * - mypolls.fds: Array of pollfd structures containing file descriptors and events

Comment on lines +177 to +183
* @section Usage Patterns
* Called during:
* - New client connections (MySQL_Thread.cpp:4518)
* - New server connections (MySQL_Thread.cpp:3600)
* - Listener socket registration (MySQL_Thread.cpp:3015)
* - PostgreSQL session establishment (PgSQL_Session.cpp:1094)
*

Choose a reason for hiding this comment

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

medium

The documentation here includes specific line numbers as references, which contradicts the PR description's goal of avoiding them for maintainability. Also, the reference to PgSQL_Session.cpp seems incorrect as the file is not part of this PR.

Consider replacing the line numbers with function names for better context and future-proofing. For example, MySQL_Thread.cpp:4518 is inside MySQL_Thread::listener_handle_new_connection.

 * @section Usage Patterns
 * Called during:
 * - New client connections (e.g., in `MySQL_Thread::listener_handle_new_connection`)
 * - New server connections (e.g., in `MySQL_Thread::worker_thread_gets_sessions_from_idle_thread`)
 * - Listener socket registration (e.g., in `MySQL_Thread::poll_listener_add`)
 * - PostgreSQL session establishment (e.g., in `PgSQL_Thread::listener_handle_new_connection`)

Comment on lines +234 to +238
* @section Usage Patterns
* Called during:
* - Data stream destruction (MySQL_Data_Stream.cpp:337, PgSQL_Data_Stream.cpp:1114)
* - Thread cleanup operations (MySQL_Thread.cpp:3451)
* - Connection termination and cleanup

Choose a reason for hiding this comment

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

medium

The documentation here includes specific line numbers as references, which contradicts the PR description's goal of avoiding them for maintainability. Some references might also be incorrect (e.g., PgSQL_Data_Stream.cpp:1114 seems to point to a non-existent line).

Consider replacing the line numbers with function names for better context and future-proofing.

 * @section Usage Patterns
 * Called during:
 * - Data stream destruction (e.g., `MySQL_Data_Stream::~MySQL_Data_Stream`, `PgSQL_Data_Stream::~PgSQL_Data_Stream`)
 * - Thread cleanup operations (e.g., `MySQL_Thread::cleanup_sessions_from_thread`)
 * - Connection termination and cleanup

Comment on lines +272 to +276
* @section Usage Patterns
* Called during:
* - Listener socket operations (MySQL_Thread.cpp:3019)
* - Connection management and lookup (PgSQL_Thread.cpp:2789)
* - Debugging and diagnostic operations

Choose a reason for hiding this comment

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

medium

The documentation here includes specific line numbers as references, which contradicts the PR description's goal of avoiding them for maintainability.

Consider replacing the line numbers with function names for better context and future-proofing.

 * @section Usage Patterns
 * Called during:
 * - Listener socket operations (e.g., `MySQL_Thread::poll_listener_del`)
 * - Connection management and lookup (e.g., `PgSQL_Thread::poll_listener_del`)
 * - Debugging and diagnostic operations

@renecannao renecannao deleted the v3.0-poll_doc branch March 7, 2026 20:41
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.

1 participant