Skip to content

Conversation

@santigimeno
Copy link
Member

@santigimeno santigimeno commented Apr 7, 2025

Add state tracking to prevent excessive uv_async_t::send() calls.

Benchmark results for (40k and 50k):

=== Benchmark Summary ===

Benchmark Type: wrk2
Old Version: ./nsolid_baseline
New Version: ./nsolid_span_collector
Iterations: 50
Connections: 10
Duration: 60s
Rate: 40k

=== Latency Percentile Distribution ===

+------------+------------------+------------------+------------+---------+--------------+
| Percentile | Old Version (ms) | New Version (ms) | Difference | p-value | Significance |
+------------+------------------+------------------+------------+---------+--------------+
| P50        | 1.09             | 1.10             | +0.40%     | 0.00    | ***          |
| P75        | 1.67             | 1.67             | +0.03%     | 0.73    |              |
| P90        | 2.22             | 2.22             | -0.23%     | 0.01    | **           |
| P95        | 2.54             | 2.53             | -0.52%     | 0.00    | ***          |
| P99        | 3.16             | 3.10             | -1.82%     | 0.00    | ***          |
| P99.9      | 4.98             | 4.36             | -12.45%    | 0.01    | ***          |
| P99.99     | 9.97             | 8.96             | -10.09%    | 0.13    |              |
| P99.999    | 12.91            | 11.77            | -8.88%     | 0.15    |              |
+------------+------------------+------------------+------------+---------+--------------+
=== Benchmark Summary ===

Benchmark Type: wrk2
Old Version: ./nsolid_baseline
New Version: ./nsolid_span_collector
Iterations: 50
Connections: 10
Duration: 60s
Rate: 50k

=== Latency Percentile Distribution ===

+------------+------------------+------------------+------------+---------+--------------+
| Percentile | Old Version (ms) | New Version (ms) | Difference | p-value | Significance |
+------------+------------------+------------------+------------+---------+--------------+
| P50        | 0.98             | 0.95             | -3.76%     | 0.16    |              |
| P75        | 1.78             | 1.54             | -13.31%    | 0.23    |              |
| P90        | 3.36             | 2.49             | -25.71%    | 0.18    |              |
| P95        | 5.37             | 3.51             | -34.60%    | 0.09    | *            |
| P99        | 18.08            | 10.66            | -41.02%    | 0.01    | ***          |
| P99.9      | 50.91            | 30.78            | -39.54%    | 0.01    | ***          |
| P99.99     | 72.19            | 47.71            | -33.91%    | 0.01    | ***          |
| P99.999    | 75.98            | 51.69            | -31.97%    | 0.01    | ***          |
+------------+------------------+------------------+------------+---------+--------------+

TL;DR

The new version demonstrates a clear improvement in latency performance, particularly for edge cases and high-load scenarios represented by the tail latencies. This suggests better handling of resource-intensive operations or improved performance under stress conditions.

Summary by CodeRabbit

  • Bug Fixes
    • Improved the efficiency of span message sending by reducing redundant send operations when the queue size exceeds a certain threshold. This results in more optimal resource usage during span collection.

@santigimeno
Copy link
Member Author

For a nicer visualization:
report40k.html and report50k.html

@santigimeno santigimeno self-assigned this Apr 7, 2025
@santigimeno
Copy link
Member Author

Also for max throughput we have gains: reportwrk.html

=== Benchmark Summary ===

Benchmark Type: wrk (maximum throughput)
Old Version: ./nsolid_baseline
New Version: ./nsolid_span_collector
Iterations: 30
Connections: 10
Duration: 60s
Threads: 2

+------------------+-------------+-------------+------------+-----+
| Metric           | Old Version | New Version | Difference | Sig |
+------------------+-------------+-------------+------------+-----+
| Avg Latency (ms) | 0.65        | 0.64        | N/A        |     |
| P50 Latency (ms) | 0.17        | 0.17        | -1.23%     | **  |
| P90 Latency (ms) | 0.32        | 0.32        | -0.13%     |     |
| P99 Latency (ms) | 0.36        | 0.36        | -1.15%     | *** |
| Avg Req/Sec      | 52,423.01   | 52,955.12   | +1.02%     | **  |
+------------------+-------------+-------------+------------+-----+

@santigimeno
Copy link
Member Author

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented Apr 16, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai
Copy link

coderabbitai bot commented Apr 16, 2025

"""

Walkthrough

The changes introduce a new boolean member variable, sent_, to the SpanCollector class and update the logic in the span collection process. The revised logic ensures that the asynchronous message send operation is triggered only once when the span queue size crosses a specified threshold, and not repeatedly while the queue remains above that threshold. The sent_ flag is reset when the queue size drops back to or below the threshold, allowing future sends if the threshold is exceeded again. No changes were made to public interfaces or method signatures.

Changes

File(s) Change Summary
agents/src/span_collector.cc Modified logic to trigger message sending only once when queue size exceeds threshold, using a new sent_ flag.
agents/src/span_collector.h Added a new private boolean member variable sent_ to the SpanCollector class.

Poem

A clever flag, a single send,
No more repeats—just messages to tend.
When spans pile high, we send with care,
And wait for the queue to drop down there.
With sent_ in tow, our code feels bright—
One hop ahead, the logic’s right!
🐇✨
"""

Tip

⚡️ Faster reviews with caching
  • CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.

Enjoy the performance boost—your workflow just got faster.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a648ed7 and f0389a7.

📒 Files selected for processing (2)
  • agents/src/span_collector.cc (1 hunks)
  • agents/src/span_collector.h (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • agents/src/span_collector.cc
  • agents/src/span_collector.h
⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: test-tarball-linux
  • GitHub Check: lint-js-and-md
  • GitHub Check: test-linux (ubuntu-24.04-arm)
  • GitHub Check: coverage-linux
  • GitHub Check: coverage-linux-without-intl
  • GitHub Check: coverage-windows
  • GitHub Check: test-macOS
  • GitHub Check: test-linux (ubuntu-24.04)
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@santigimeno santigimeno force-pushed the santi/improve_span_collector branch from 04c3c34 to 7c3764a Compare April 16, 2025 10:02
@santigimeno santigimeno force-pushed the santi/improve_span_collector branch from 7c3764a to a647f0f Compare April 28, 2025 09:37
@santigimeno santigimeno force-pushed the santi/improve_span_collector branch from a647f0f to d1d3eed Compare April 29, 2025 14:43
@santigimeno santigimeno force-pushed the santi/improve_span_collector branch from d1d3eed to a648ed7 Compare May 8, 2025 10:47
Add state tracking to prevent excessive `uv_async_t::send()` calls.

Benchmark results for (40k and 50k):

```
=== Benchmark Summary ===

Benchmark Type: wrk2
Old Version: ./nsolid_baseline
New Version: ./nsolid_span_collector
Iterations: 50
Connections: 10
Duration: 60s
Rate: 40k

=== Latency Percentile Distribution ===

+------------+------------------+------------------+------------+---------+--------------+
| Percentile | Old Version (ms) | New Version (ms) | Difference | p-value | Significance |
+------------+------------------+------------------+------------+---------+--------------+
| P50        | 1.09             | 1.10             | +0.40%     | 0.00    | ***          |
| P75        | 1.67             | 1.67             | +0.03%     | 0.73    |              |
| P90        | 2.22             | 2.22             | -0.23%     | 0.01    | **           |
| P95        | 2.54             | 2.53             | -0.52%     | 0.00    | ***          |
| P99        | 3.16             | 3.10             | -1.82%     | 0.00    | ***          |
| P99.9      | 4.98             | 4.36             | -12.45%    | 0.01    | ***          |
| P99.99     | 9.97             | 8.96             | -10.09%    | 0.13    |              |
| P99.999    | 12.91            | 11.77            | -8.88%     | 0.15    |              |
+------------+------------------+------------------+------------+---------+--------------+
```

```
=== Benchmark Summary ===

Benchmark Type: wrk2
Old Version: ./nsolid_baseline
New Version: ./nsolid_span_collector
Iterations: 50
Connections: 10
Duration: 60s
Rate: 50k

=== Latency Percentile Distribution ===

+------------+------------------+------------------+------------+---------+--------------+
| Percentile | Old Version (ms) | New Version (ms) | Difference | p-value | Significance |
+------------+------------------+------------------+------------+---------+--------------+
| P50        | 0.98             | 0.95             | -3.76%     | 0.16    |              |
| P75        | 1.78             | 1.54             | -13.31%    | 0.23    |              |
| P90        | 3.36             | 2.49             | -25.71%    | 0.18    |              |
| P95        | 5.37             | 3.51             | -34.60%    | 0.09    | *            |
| P99        | 18.08            | 10.66            | -41.02%    | 0.01    | ***          |
| P99.9      | 50.91            | 30.78            | -39.54%    | 0.01    | ***          |
| P99.99     | 72.19            | 47.71            | -33.91%    | 0.01    | ***          |
| P99.999    | 75.98            | 51.69            | -31.97%    | 0.01    | ***          |
+------------+------------------+------------------+------------+---------+--------------+

```
TL;DR

The new version demonstrates a clear improvement in latency
performance, particularly for edge cases and high-load scenarios
represented by the tail latencies. This suggests better handling of
resource-intensive operations or improved performance under stress
conditions.
@santigimeno santigimeno force-pushed the santi/improve_span_collector branch from a648ed7 to f0389a7 Compare May 12, 2025 14:14
santigimeno added a commit that referenced this pull request Jun 5, 2025
Add state tracking to prevent excessive `uv_async_t::send()` calls.

Benchmark results for (40k and 50k):

```
=== Benchmark Summary ===

Benchmark Type: wrk2
Old Version: ./nsolid_baseline
New Version: ./nsolid_span_collector
Iterations: 50
Connections: 10
Duration: 60s
Rate: 40k

=== Latency Percentile Distribution ===

+------------+------------------+------------------+------------+---------+--------------+
| Percentile | Old Version (ms) | New Version (ms) | Difference | p-value | Significance |
+------------+------------------+------------------+------------+---------+--------------+
| P50        | 1.09             | 1.10             | +0.40%     | 0.00    | ***          |
| P75        | 1.67             | 1.67             | +0.03%     | 0.73    |              |
| P90        | 2.22             | 2.22             | -0.23%     | 0.01    | **           |
| P95        | 2.54             | 2.53             | -0.52%     | 0.00    | ***          |
| P99        | 3.16             | 3.10             | -1.82%     | 0.00    | ***          |
| P99.9      | 4.98             | 4.36             | -12.45%    | 0.01    | ***          |
| P99.99     | 9.97             | 8.96             | -10.09%    | 0.13    |              |
| P99.999    | 12.91            | 11.77            | -8.88%     | 0.15    |              |
+------------+------------------+------------------+------------+---------+--------------+
```

```
=== Benchmark Summary ===

Benchmark Type: wrk2
Old Version: ./nsolid_baseline
New Version: ./nsolid_span_collector
Iterations: 50
Connections: 10
Duration: 60s
Rate: 50k

=== Latency Percentile Distribution ===

+------------+------------------+------------------+------------+---------+--------------+
| Percentile | Old Version (ms) | New Version (ms) | Difference | p-value | Significance |
+------------+------------------+------------------+------------+---------+--------------+
| P50        | 0.98             | 0.95             | -3.76%     | 0.16    |              |
| P75        | 1.78             | 1.54             | -13.31%    | 0.23    |              |
| P90        | 3.36             | 2.49             | -25.71%    | 0.18    |              |
| P95        | 5.37             | 3.51             | -34.60%    | 0.09    | *            |
| P99        | 18.08            | 10.66            | -41.02%    | 0.01    | ***          |
| P99.9      | 50.91            | 30.78            | -39.54%    | 0.01    | ***          |
| P99.99     | 72.19            | 47.71            | -33.91%    | 0.01    | ***          |
| P99.999    | 75.98            | 51.69            | -31.97%    | 0.01    | ***          |
+------------+------------------+------------------+------------+---------+--------------+

```
TL;DR

The new version demonstrates a clear improvement in latency
performance, particularly for edge cases and high-load scenarios
represented by the tail latencies. This suggests better handling of
resource-intensive operations or improved performance under stress
conditions.

PR-URL: #287
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: dobleuber <wbertc@gmail.com>
@santigimeno
Copy link
Member Author

Landed in a0a2c70

@santigimeno santigimeno closed this Jun 5, 2025
@santigimeno santigimeno deleted the santi/improve_span_collector branch June 5, 2025 13:54
santigimeno added a commit that referenced this pull request Aug 25, 2025
Add state tracking to prevent excessive `uv_async_t::send()` calls.

Benchmark results for (40k and 50k):

```
=== Benchmark Summary ===

Benchmark Type: wrk2
Old Version: ./nsolid_baseline
New Version: ./nsolid_span_collector
Iterations: 50
Connections: 10
Duration: 60s
Rate: 40k

=== Latency Percentile Distribution ===

+------------+------------------+------------------+------------+---------+--------------+
| Percentile | Old Version (ms) | New Version (ms) | Difference | p-value | Significance |
+------------+------------------+------------------+------------+---------+--------------+
| P50        | 1.09             | 1.10             | +0.40%     | 0.00    | ***          |
| P75        | 1.67             | 1.67             | +0.03%     | 0.73    |              |
| P90        | 2.22             | 2.22             | -0.23%     | 0.01    | **           |
| P95        | 2.54             | 2.53             | -0.52%     | 0.00    | ***          |
| P99        | 3.16             | 3.10             | -1.82%     | 0.00    | ***          |
| P99.9      | 4.98             | 4.36             | -12.45%    | 0.01    | ***          |
| P99.99     | 9.97             | 8.96             | -10.09%    | 0.13    |              |
| P99.999    | 12.91            | 11.77            | -8.88%     | 0.15    |              |
+------------+------------------+------------------+------------+---------+--------------+
```

```
=== Benchmark Summary ===

Benchmark Type: wrk2
Old Version: ./nsolid_baseline
New Version: ./nsolid_span_collector
Iterations: 50
Connections: 10
Duration: 60s
Rate: 50k

=== Latency Percentile Distribution ===

+------------+------------------+------------------+------------+---------+--------------+
| Percentile | Old Version (ms) | New Version (ms) | Difference | p-value | Significance |
+------------+------------------+------------------+------------+---------+--------------+
| P50        | 0.98             | 0.95             | -3.76%     | 0.16    |              |
| P75        | 1.78             | 1.54             | -13.31%    | 0.23    |              |
| P90        | 3.36             | 2.49             | -25.71%    | 0.18    |              |
| P95        | 5.37             | 3.51             | -34.60%    | 0.09    | *            |
| P99        | 18.08            | 10.66            | -41.02%    | 0.01    | ***          |
| P99.9      | 50.91            | 30.78            | -39.54%    | 0.01    | ***          |
| P99.99     | 72.19            | 47.71            | -33.91%    | 0.01    | ***          |
| P99.999    | 75.98            | 51.69            | -31.97%    | 0.01    | ***          |
+------------+------------------+------------------+------------+---------+--------------+

```
TL;DR

The new version demonstrates a clear improvement in latency
performance, particularly for edge cases and high-load scenarios
represented by the tail latencies. This suggests better handling of
resource-intensive operations or improved performance under stress
conditions.

PR-URL: #287
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: dobleuber <wbertc@gmail.com>
santigimeno added a commit that referenced this pull request Aug 26, 2025
Add state tracking to prevent excessive `uv_async_t::send()` calls.

Benchmark results for (40k and 50k):

```
=== Benchmark Summary ===

Benchmark Type: wrk2
Old Version: ./nsolid_baseline
New Version: ./nsolid_span_collector
Iterations: 50
Connections: 10
Duration: 60s
Rate: 40k

=== Latency Percentile Distribution ===

+------------+------------------+------------------+------------+---------+--------------+
| Percentile | Old Version (ms) | New Version (ms) | Difference | p-value | Significance |
+------------+------------------+------------------+------------+---------+--------------+
| P50        | 1.09             | 1.10             | +0.40%     | 0.00    | ***          |
| P75        | 1.67             | 1.67             | +0.03%     | 0.73    |              |
| P90        | 2.22             | 2.22             | -0.23%     | 0.01    | **           |
| P95        | 2.54             | 2.53             | -0.52%     | 0.00    | ***          |
| P99        | 3.16             | 3.10             | -1.82%     | 0.00    | ***          |
| P99.9      | 4.98             | 4.36             | -12.45%    | 0.01    | ***          |
| P99.99     | 9.97             | 8.96             | -10.09%    | 0.13    |              |
| P99.999    | 12.91            | 11.77            | -8.88%     | 0.15    |              |
+------------+------------------+------------------+------------+---------+--------------+
```

```
=== Benchmark Summary ===

Benchmark Type: wrk2
Old Version: ./nsolid_baseline
New Version: ./nsolid_span_collector
Iterations: 50
Connections: 10
Duration: 60s
Rate: 50k

=== Latency Percentile Distribution ===

+------------+------------------+------------------+------------+---------+--------------+
| Percentile | Old Version (ms) | New Version (ms) | Difference | p-value | Significance |
+------------+------------------+------------------+------------+---------+--------------+
| P50        | 0.98             | 0.95             | -3.76%     | 0.16    |              |
| P75        | 1.78             | 1.54             | -13.31%    | 0.23    |              |
| P90        | 3.36             | 2.49             | -25.71%    | 0.18    |              |
| P95        | 5.37             | 3.51             | -34.60%    | 0.09    | *            |
| P99        | 18.08            | 10.66            | -41.02%    | 0.01    | ***          |
| P99.9      | 50.91            | 30.78            | -39.54%    | 0.01    | ***          |
| P99.99     | 72.19            | 47.71            | -33.91%    | 0.01    | ***          |
| P99.999    | 75.98            | 51.69            | -31.97%    | 0.01    | ***          |
+------------+------------------+------------------+------------+---------+--------------+

```
TL;DR

The new version demonstrates a clear improvement in latency
performance, particularly for edge cases and high-load scenarios
represented by the tail latencies. This suggests better handling of
resource-intensive operations or improved performance under stress
conditions.

PR-URL: #287
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: dobleuber <wbertc@gmail.com>
PR-URL: #359
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
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.

4 participants