Skip to content

build: compile yyjson with -Og in debug builds#11587

Open
edsiper wants to merge 1 commit intomasterfrom
simd-coro
Open

build: compile yyjson with -Og in debug builds#11587
edsiper wants to merge 1 commit intomasterfrom
simd-coro

Conversation

@edsiper
Copy link
Member

@edsiper edsiper commented Mar 19, 2026

yyjson's reader can generate an oversized stack frame in SIMD-enabled Debug/RelWithDebInfo builds, which exceeds Fluent Bit's default coroutine stack budget and can break JSON parsing in coroutine paths such as filter_kubernetes.

This change forces -Og for the yyjson target in Debug and RelWithDebInfo builds for GNU/Clang/ Intel compilers. It preserves debug symbols while shrinking yyjson_read_opts() from 26112 bytes to 1472 bytes in the affected build, avoiding coroutine stack overflows without changing parser behavior.

(cc: @cosmo0920 )


Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.

Summary by CodeRabbit

  • Chores
    • Adjusted build behavior for Debug and RelWithDebInfo builds with GNU/Clang/Intel compilers to use less aggressive optimization for a bundled dependency, improving debug reliability and compilation performance.
    • When the bundled dependency is present, code coverage is disabled to prevent inconsistent coverage results.

@coderabbitai
Copy link

coderabbitai bot commented Mar 19, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0eff7972-f4db-4b11-ada2-72b4d469358e

📥 Commits

Reviewing files that changed from the base of the PR and between 930f191 and babc9b7.

📒 Files selected for processing (1)
  • CMakeLists.txt

📝 Walkthrough

Walkthrough

A CMake conditional was added to the bundled yyjson subdirectory: when the yyjson target exists, coverage is disabled and the compiler is GNU/Clang/AppleClang/Intel, the build applies a target-scoped -Og compile option for Debug and RelWithDebInfo configurations.

Changes

Cohort / File(s) Summary
Build Configuration
CMakeLists.txt
Added conditional to disable coverage and apply target-scoped -Og compile option to the bundled yyjson target for GNU/Clang/AppleClang/Intel compilers in Debug and RelWithDebInfo builds. No other targets or configurations changed.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • niedbalski
  • patrick-stephens
  • celalettin1286
  • cosmo0920

Poem

🐰 A tiny flag hops into place,
Debug lines snug in an optimization embrace,
yyjson trimmed for a gentler tune,
Compilers nod beneath the moon,
Build-time carrots for a sleeker race 🥕

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and clearly summarizes the main change: applying -Og optimization to yyjson in debug builds, which is the core objective of the CMakeLists.txt modification.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch simd-coro
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@edsiper edsiper added this to the Fluent Bit v5.0 milestone Mar 19, 2026
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@CMakeLists.txt`:
- Around line 668-674: The compiler check for applying debug/optimization flags
to target_compile_options(yyjson ...) omits AppleClang, so macOS system builds
won't get the stack-shrinking -Og adjustment; update the CMAKE_C_COMPILER_ID
MATCHES expression used in the if(...) guarding target_compile_options for the
yyjson target to include "AppleClang" (make it match "GNU|Clang|AppleClang") so
the -Og option is applied on AppleClang debug/RelWithDebInfo configurations.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: df6311c0-c7c1-46b5-b689-04e194a9d42f

📥 Commits

Reviewing files that changed from the base of the PR and between d257e00 and 930f191.

📒 Files selected for processing (1)
  • CMakeLists.txt

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 930f191ee2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

# yyjson's O0 reader can exceed the default coroutine stack budget.
# Keep debug symbols, but force enough optimization to shrink the frame.
target_compile_options(yyjson PRIVATE
$<$<AND:$<COMPILE_LANGUAGE:C>,$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>>:-Og>

Choose a reason for hiding this comment

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

P2 Badge Skip the -Og override when coverage is enabled

When Fluent Bit is configured with -DFLB_COVERAGE=On, CMakeLists.txt:467-472 explicitly adds -O0 --coverage and forces CMAKE_BUILD_TYPE=Debug, and that mode is exercised in .github/workflows/unit-tests.yaml:52. This new $<CONFIG:Debug> branch still appends -Og for yyjson, so the parser is no longer built with the project’s intended coverage flags (the last optimization flag wins for GCC/Clang). In that configuration the coverage job will collect different, less faithful line/branch coverage for yyjson than before, even though only interactive debug builds needed the stack-frame workaround.

Useful? React with 👍 / 👎.

Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
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.

1 participant