Skip to content

Conversation

@jimmyw
Copy link

@jimmyw jimmyw commented Oct 30, 2025

Description

In my quest to improve heap fragmentation, i noticed that the webserver was a big issue, but not for the reasons you think. A single web page read/write causes several esp_events to be sent, each one causing a malloc on its own and a contex switch to handle tasks. And the worst part of it, is that we never listened on any of these events.

This PR adds a KConfig option to disable events on the webserver, this was a hug improvement for us in 5.4.1

Make it possible to disable http(s) server events. This improves
performance of the server, as http server creates events on every signle
read or write to the socket.
@cursor
Copy link

cursor bot commented Oct 30, 2025

You have run out of free Bugbot PR reviews for this billing cycle. This will reset on November 20.

To receive reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

@github-actions
Copy link

Fails
🚫

node failed.

Log

┌─────────┬─────────────────────────────────────┬───────────────────────────────────────────────────────┬──────────────────────────────┐
│ (index) │             CiVariable              │                         Value                         │        CustomSettings        │
├─────────┼─────────────────────────────────────┼───────────────────────────────────────────────────────┼──────────────────────────────┤
│    0    │  'ENABLE_RULE_PR_COMMIT_MESSAGES'   │                         true                          │          'default'           │
│    1    │    'ENABLE_RULE_PR_DESCRIPTION'     │                         true                          │          'default'           │
│    2    │     'ENABLE_RULE_PR_SIZE_LINES'     │                         true                          │          'default'           │
│    3    │ 'ENABLE_RULE_PR_SOURCE_BRANCH_NAME' │                         true                          │          'default'           │
│    4    │   'ENABLE_RULE_PR_TARGET_BRANCH'    │                         true                          │          'default'           │
│    5    │  'ENABLE_RULE_PR_TOO_MANY_COMMITS'  │                         true                          │          'default'           │
│    6    │    'ENABLE_OUTPUT_INSTRUCTIONS'     │                         true                          │          'default'           │
│    7    │             'CLA_LINK'              │     'https://cla-assistant.io/espressif/esp-idf'      │   'custom (default is: )'    │
│    8    │   'COMMIT_MESSAGE_ALLOWED_TYPES'    │ 'change,ci,docs,feat,fix,refactor,remove,revert,test' │          'default'           │
│    9    │      'CONTRIBUTING_GUIDE_FILE'      │                   'CONTRIBUTING.md'                   │   'custom (default is: )'    │
│   10    │   'IGNORED_SECTIONS_DESCRIPTION'    │              'related,release,breaking'               │          'default'           │
│   11    │         'IS_GITLAB_MIRROR'          │                         true                          │ 'custom (default is: false)' │
│   12    │   'MAX_COMMIT_MESSAGE_BODY_LINE'    │                          100                          │          'default'           │
│   13    │    'MAX_COMMIT_MESSAGE_SUMMARY'     │                          72                           │          'default'           │
│   14    │         'MAX_COMMITS_WARN'          │                           5                           │          'default'           │
│   15    │            'MAX_COMMITS'            │                           2                           │          'default'           │
│   16    │           'MAX_PR_LINES'            │                         1000                          │          'default'           │
│   17    │    'MIN_COMMIT_MESSAGE_SUMMARY'     │                          20                           │          'default'           │
│   18    │     'MIN_PR_DESCRIPTION_LENGTH'     │                          50                           │          'default'           │
└─────────┴─────────────────────────────────────┴───────────────────────────────────────────────────────┴──────────────────────────────┘
DangerJS checks (rules) output states:
======================================================================================================
Commit messages style......................................................................... �[32mPassed�[0m
Number of commits in Pull Request............................................................. �[32mPassed�[0m
Pull Request size (number of changed lines)................................................... �[32mPassed�[0m
Pull Request sufficient Description........................................................... �[32mPassed�[0m
Source branch name............................................................................ �[32mPassed�[0m
Target branch is project default branch....................................................... �[32mPassed�[0m
======================================================================================================
Error:  RequestError [HttpError]: API rate limit exceeded for 64.236.161.23. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.)
    at /node_modules/@octokit/request/dist-node/index.js:86:21
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  status: 403,
  response: {
    url: 'https://api.github.com/repos/espressif/esp-idf',
    status: 403,
    headers: {
      'access-control-allow-origin': '*',
      'access-control-expose-headers': 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-RateLimit-Used, X-RateLimit-Resource, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, Deprecation, Sunset',
      connection: 'close',
      'content-length': '279',
      'content-security-policy': "default-src 'none'; style-src 'unsafe-inline'",
      'content-type': 'application/json; charset=utf-8',
      date: 'Thu, 30 Oct 2025 12:01:46 GMT',
      'referrer-policy': 'origin-when-cross-origin, strict-origin-when-cross-origin',
      server: 'Varnish',
      'strict-transport-security': 'max-age=31536000; includeSubdomains; preload',
      'x-content-type-options': 'nosniff',
      'x-frame-options': 'deny',
      'x-github-media-type': 'github.v3; format=json',
      'x-github-request-id': 'AC00:3A970B:75F47D:1F8230C:690353AA',
      'x-ratelimit-limit': '60',
      'x-ratelimit-remaining': '0',
      'x-ratelimit-reset': '1761827775',
      'x-ratelimit-resource': 'core',
      'x-ratelimit-used': '60',
      'x-xss-protection': '1; mode=block'
    },
    data: {
      message: "API rate limit exceeded for 64.236.161.23. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.)",
      documentation_url: 'https://docs.github.com/rest/overview/resources-in-the-rest-api#rate-limiting'
    }
  },
  request: {
    method: 'GET',
    url: 'https://api.github.com/repos/espressif/esp-idf',
    headers: {
      accept: 'application/vnd.github.v3+json',
      'user-agent': 'octokit-rest.js/18.12.0 octokit-core.js/3.6.0 Node.js/18.15.0 (linux; x64)'
    },
    request: { hook: [Function: bound bound register] }
  }
}
danger-results://tmp/danger-results-be0ddf10.json

Generated by 🚫 dangerJS against 23b2402

@github-actions github-actions bot changed the title feat(esp_http_server): Make HTTP(S)_SERVER_EVENT events optional feat(esp_http_server): Make HTTP(S)_SERVER_EVENT events optional (IDFGH-16707) Oct 30, 2025
@espressif-bot espressif-bot added the Status: Opened Issue is new label Oct 30, 2025

#define ESP_HTTPD_DEF_CTRL_PORT (32768) /*!< HTTP Server control socket port*/

#ifdef CONFIG_HTTPD_ENABLE_EVENTS
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
#ifdef CONFIG_HTTPD_ENABLE_EVENTS
#if CONFIG_HTTPD_ENABLE_EVENTS || __DOXYGEN__

int fd; /*!< Session socket file descriptor */
int data_len; /*!< Data length */
} esp_http_server_event_data;
#endif
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
#endif
#endif // CONFIG_HTTPD_ENABLE_EVENTS

extern "C" {
#endif

#ifdef CONFIG_ESP_HTTPS_SERVER_EVENTS
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
#ifdef CONFIG_ESP_HTTPS_SERVER_EVENTS
#if CONFIG_ESP_HTTPS_SERVER_EVENTS || __DOXYGEN__

HTTPS_SERVER_EVENT_DISCONNECTED, /*!< The connection has been disconnected */
HTTPS_SERVER_EVENT_STOP, /*!< This event occurs when HTTPS Server is stopped */
} esp_https_server_event_id_t;
#endif
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
#endif
#endif // CONFIG_ESP_HTTPS_SERVER_EVENTS

}
}
#else
#define http_dispatch_event_to_event_loop(event_id, event_data, event_data_size) do {} while (0)
Copy link
Member

Choose a reason for hiding this comment

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

Could we use similar approach (stub out the implementation) in HTTP server component as well?

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

Labels

Status: Opened Issue is new

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants