Skip to content

glob: reduce the number of allocations for URLs that don't need globbing - #22947

Merged
cmeister2 merged 1 commit into
masterfrom
cm2/globalloc
Sep 15, 2026
Merged

cmeister2 merged 1 commit into
masterfrom
cm2/globalloc

Conversation

@cmeister2

Copy link
Copy Markdown
Contributor

For URLs that don't need glob-expansion, copy the URL pointer as a literal.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The upload ownership issue remains unresolved, along with the bracketed literal URL edge case.

Pull request overview

This pull request reduces allocations for URLs that do not require glob expansion by retaining them as literals.

Changes:

  • Adds literal URL tracking and handling.
  • Updates glob activity and cleanup logic.
  • Adds regression test 2415.
File summaries
File Summary
tests/data/test2415 Adds regression coverage for named glob references with literal URLs.
tests/data/Makefile.am Registers the new test.
src/tool_urlglob.h Adds literal URL state.
src/tool_urlglob.c Implements the literal URL fast path; retains a moderate issue with upload-file ownership and a nit involving bracketed literal URLs.
Review details

Suppressed comments (2)

src/tool_urlglob.c:584

  • This shortcut only looks for the presence of bracket characters, so valid non-glob URLs such as http://[::1]/ (and [] literals) still take the allocation-heavy parser path. glob_parse() explicitly recognizes these as literal components via peek_ipv6()/the empty-bracket case, so please extend the no-glob detection to skip those forms as well if this optimization is intended for all URLs that do not expand.
  if(!strpbrk(url, "{}[]")) {
    /* no glob syntax: borrow the URL instead of parsing a copy of it */
    glob->literal = url;

src/tool_urlglob.c:638

  • Because glob_url() is also used for upload filenames, this branch makes every plain -T file go through glob_next_url(). setup_input_file() previously moved u->infile into state->uploadfile when no glob was active, but literal makes glob_inuse() true, so this curlx_strdup() adds an avoidable allocation and copy for every non-glob upload. Please preserve the ownership fast path for literal upload files or limit this state change to URL patterns.
      *globbed = curlx_strdup(glob->literal);
  • Files reviewed: 4/4 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@testclutch

Copy link
Copy Markdown

Analysis of PR #22947 at acec0dea:

Test 3231 failed, but it has been 69.6% flaky lately, so it's probably NOT a fault of the PR. Note that this test has failed in 2 different CI jobs (the link just goes to one of them). Note that this CI job has had a number of other flaky tests recently (4, to be specific) so it may be that this failure is rather a systemic issue with this job and not with this specific PR.

Generated by Testclutch

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@cmeister2
cmeister2 merged commit 91e0ed5 into master Sep 15, 2026
205 of 206 checks passed
@cmeister2
cmeister2 deleted the cm2/globalloc branch September 15, 2026 08:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

4 participants