Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from netdata:master #323

Merged
merged 4 commits into from
Jan 27, 2025
Merged

Conversation

pull[bot]
Copy link

@pull pull bot commented Jan 27, 2025

See Commits and Changes for more details.


Created by pull[bot] (v2.0.0-alpha.1)

Can you help keep this open source service alive? 💖 Please sponsor : )

Summary by Sourcery

Optimize SQLite statement handling by reusing prepared statements across multiple functions to enhance performance and efficiency.

Enhancements:

  • Optimize SQLite statement preparation and reuse in alert version updates to improve performance.
  • Refactor the aclk_push_alert_event function to accept pre-prepared SQLite statements for efficiency.
  • Improve the handling of SQLite statements in sql_health_get_last_executed_event by using thread-local storage for compiled statements.

@pull pull bot added the ⤵️ pull label Jan 27, 2025
@pull pull bot merged commit ae18037 into webfutureiorepo:master Jan 27, 2025
Copy link

sourcery-ai bot commented Jan 27, 2025

Reviewer's Guide by Sourcery

This pull request refactors SQL statement handling in alert and health event functions to improve performance by reusing prepared statements. It also fixes a condition in API data handling, updates network device configuration patterns, and adds an index to the alert_queue table for better query performance.

Sequence diagram for optimized alert event handling

sequenceDiagram
    participant Host
    participant AlertHandler
    participant SQLite

    Note over AlertHandler: Reuse prepared statements

    Host->>AlertHandler: Push alert events
    AlertHandler->>SQLite: Prepare statements (once)
    activate SQLite
    SQLite-->>AlertHandler: Return prepared statements
    deactivate SQLite

    loop For each alert
        AlertHandler->>SQLite: Execute prepared statement
        activate SQLite
        SQLite-->>AlertHandler: Return results
        deactivate SQLite
        AlertHandler->>SQLite: Reset statement (instead of finalizing)
    end

    Note over AlertHandler: Finally cleanup
    AlertHandler->>SQLite: Finalize statements
Loading

Class diagram for alert and queue structure

classDiagram
    class AlertQueue {
        +host_id: BLOB
        +health_log_id: INT
        +unique_id: INT
        +alarm_id: INT
        +status: INT
        +date_scheduled: INT
    }

    class AlertVersion {
        +health_log_id: INT
        +unique_id: INT
        +status: INT
        +version: INT
        +date_submitted: INT
    }

    note for AlertQueue "New index added on (host_id, date_scheduled)"
    AlertQueue -- AlertVersion : references
Loading

File-Level Changes

Change Details Files
Refactor and optimize SQL statement preparation and execution in alert handling functions.
  • Modified sql_update_alert_version to accept a pre-prepared sqlite3_stmt pointer and reuse it.
  • Added logic to prepare SQL statements only once and reuse them in aclk_push_alert_event and aclk_push_alert_events_for_all_hosts.
  • Replaced SQLITE_FINALIZE with SQLITE_RESET for reusable statements.
src/database/sqlite/sqlite_aclk_alert.c
Optimize SQL statement handling in health event functions.
  • Introduced a static thread-local sqlite3_stmt for compiled statements in sql_health_get_last_executed_event.
  • Added conditional logic to prepare and reuse compiled statements for health threads.
src/database/sqlite/sqlite_health.c
Fix group by condition in API data handling.
  • Updated condition to check for RRDR_GROUP_BY_NONE in api_v2_data function.
src/web/api/v2/api_v2_data.c
Update network device configuration patterns.
  • Added 'ifb4*' to the list of default disabled interfaces in do_proc_net_dev.
src/collectors/proc.plugin/proc_net_dev.c
Add index to alert_queue table for performance improvement.
  • Created an index on alert_queue for columns host_id and date_scheduled.
src/database/sqlite/sqlite_metadata.c

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

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

Successfully merging this pull request may close these issues.

3 participants