-
-
Notifications
You must be signed in to change notification settings - Fork 7
Profiler rewview fixes #146
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
Conversation
WalkthroughThis PR updates profiler documentation, aligns a macro signature, tweaks macro semicolon behavior, improves robustness in perf and allocation paths, adjusts CPU frequency math to floating point, cleans up rdtsc includes/defines, and moves profiler shutdown from close() into main() after PHYSFS_deinit(). Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Main as main()
participant PHYS as PHYSFS
participant Prof as Profiler
participant File as Output File
Main->>PHYS: PHYSFS_deinit()
note over PHYS: Library shutdown
Main->>Prof: PROFILER_STOP
note over Prof: Finalize profiling, flush data
Prof-->>File: write summary
File-->>Prof: flushed
Main->>File: fclose()
note right of Main: Now done at end of main()
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
1d88ae2 to
a70c317
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
lib/profiler/README.md (1)
14-33: Replace hard tabs with spaces in code example.The code example contains hard tabs which should be replaced with spaces for consistency with Markdown formatting standards.
Apply this diff to replace hard tabs with spaces:
static void random_func(void) { - TIME_FUNC_BEGIN(); + TIME_FUNC_BEGIN(); - /* Your code goes here... */ + /* Your code goes here... */ - TIME_FUNC_END(); + TIME_FUNC_END(); } int main(int argc, char **argv) { - PROFILER_SETUP(); + PROFILER_SETUP(); (void) argc; (void) argv; - random_func(); + random_func(); - TIME_BLOCK_BEGIN(block_name); - /* Your code goes here */ - TIME_BLOCK_END(block_name); + TIME_BLOCK_BEGIN(block_name); + /* Your code goes here */ + TIME_BLOCK_END(block_name); - PROFILER_STOP(stdout); + PROFILER_STOP(stdout); }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (8)
lib/profiler/README.md(1 hunks)lib/profiler/include/macros.h(1 hunks)lib/profiler/include/repetition_tester.h(1 hunks)lib/profiler/src/calc_cpu_freq.c(1 hunks)lib/profiler/src/perf.c(3 hunks)lib/profiler/src/rdtsc.c(1 hunks)lib/profiler/src/rep_return_data.c(1 hunks)src/main.c(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
lib/profiler/src/rep_return_data.c (2)
src/util.c (2)
ec_malloc(132-140)ec_realloc(152-159)test/test_util.c (1)
test_util_ec_malloc(21-28)
🪛 markdownlint-cli2 (0.18.1)
lib/profiler/README.md
14-14: Hard tabs
Column: 1
(MD010, no-hard-tabs)
16-16: Hard tabs
Column: 1
(MD010, no-hard-tabs)
18-18: Hard tabs
Column: 1
(MD010, no-hard-tabs)
23-23: Hard tabs
Column: 1
(MD010, no-hard-tabs)
27-27: Hard tabs
Column: 1
(MD010, no-hard-tabs)
29-29: Hard tabs
Column: 1
(MD010, no-hard-tabs)
30-30: Hard tabs
Column: 1
(MD010, no-hard-tabs)
31-31: Hard tabs
Column: 1
(MD010, no-hard-tabs)
33-33: Hard tabs
Column: 1
(MD010, no-hard-tabs)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
- GitHub Check: Mac (GCC)
- GitHub Check: Ubuntu (mingw)
- GitHub Check: Mac (Clang)
- GitHub Check: Ubuntu (GCC)
- GitHub Check: Ubuntu (Clang)
- GitHub Check: Windows (MSVC)
- GitHub Check: Analyze (c-cpp)
🔇 Additional comments (9)
lib/profiler/src/calc_cpu_freq.c (1)
24-24: LGTM! Floating-point arithmetic improves precision.The change from integer arithmetic to floating-point arithmetic prevents potential overflow and provides more accurate CPU frequency estimation.
lib/profiler/src/rdtsc.c (1)
2-2: LGTM! Explicit inclusion of stdint.h.Explicitly including
stdint.hfor fixed-width integer types improves code clarity and portability.lib/profiler/src/rep_return_data.c (1)
49-51: LGTM! Essential NULL check added.The NULL check after
mallocis necessary for robustness. Returning NULL on allocation failure allows the caller to handle the error appropriately.lib/profiler/src/perf.c (3)
11-11: LGTM! Explicit initialization improves clarity.Explicitly initializing
_FDto 0 makes the initial state clear and follows best practices.
27-30: LGTM! Prevents resource leaks on repeated setup.Closing the existing file descriptor before opening a new one prevents resource leaks when
perf_setupis called multiple times.
63-66: LGTM! Validates read to prevent partial data usage.Checking that the read returned the expected number of bytes prevents using partially read or invalid data.
lib/profiler/include/macros.h (1)
39-39: LGTM! Macro signature now consistent across branches.Aligning the
TIME_BANDWIDTH_BEGINmacro signature in the non-PROFILER branch with the PROFILER branch ensures consistency and prevents compilation errors when switching between profiling and non-profiling builds.lib/profiler/include/repetition_tester.h (1)
12-12: LGTM! Follows standard macro idiom.Removing the trailing semicolon from the macro expansion follows the standard idiom for do-while(0) macros, where the caller supplies the semicolon. This makes macro invocations look like regular statements and avoids issues in certain contexts.
src/main.c (1)
1482-1490: LGTM! Profiler finalization correctly relocated.Moving profiler finalization to the end of
main()afterPHYSFS_deinit()ensures all subsystems are properly shut down before writing profiler output. The fallback tostdoutif file opening fails is appropriate.
Summary by CodeRabbit
Documentation
Bug Fixes
Refactor