Skip to content

RDKB-65004: Code changes from OpenSpec proposal#59

Open
jayasrikadiyal wants to merge 1 commit into
developfrom
RDKB-65004-log-dedup-suppression
Open

RDKB-65004: Code changes from OpenSpec proposal#59
jayasrikadiyal wants to merge 1 commit into
developfrom
RDKB-65004-log-dedup-suppression

Conversation

@jayasrikadiyal

Copy link
Copy Markdown

Summary

Adds duplicate log message suppression to rdk_logger to reduce logging volume and log uploads from RDK-B devices.

Changes:

  • src/include/rdk_log_dedup.h: New header for dedup engine (state structures, config, API declarations)
  • src/rdk_log_dedup.c: Dedup engine implementation (FNV-1a hash, per-category state tracking, suppression logic)
  • src/rdk_debug_priv.c: Integrated dedup check in log dispatch path, added dedup config parsing from debug.ini
  • src/Makefile.am: Added rdk_log_dedup.c to library sources
  • utils/rdk_log_dedup_filter.c: Standalone sync filter utility for nvram/cloud log deduplication
  • utils/Makefile.am: Added rdk_log_dedup_filter build target
  • debug.ini.sample: Added documentation for dedup configuration keys
  • unittests/rdkLoggerDedupTest.cpp: Unit tests for dedup engine
  • unittests/CMakeLists.txt: Added new test file to build

Key Design:

  • Suppression operates inside existing gLoggingMutex scope (no new locks)
  • FNV-1a hash comparison for minimal overhead
  • Configurable via debug.ini: LOG.RDK.DEDUP_ENABLED, LOG.RDK.DEDUP_WINDOW_SEC, LOG.RDK.DEDUP_MAX_SUPPRESS
  • Disabled by default for backward compatibility
  • Summary message emitted when suppression ends

Jira: RDKB-65004

@jayasrikadiyal jayasrikadiyal requested a review from a team as a code owner June 24, 2026 21:26
Copilot AI review requested due to automatic review settings June 24, 2026 21:26
return 1;
}
snprintf(tmp_path, tmp_path_len, "%s.dedup", input_path);
tmp_output = fopen(tmp_path, "w");

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds a duplicate log message suppression (“dedup”) feature to rdk_logger (plus a standalone log-file filter) to reduce repeated log volume on RDK-B devices, configured via debug.ini.

Changes:

  • Introduces a new dedup engine (src/rdk_log_dedup.c + src/include/rdk_log_dedup.h) and wires it into the log dispatch path.
  • Adds debug.ini configuration keys for enabling and tuning the dedup window/max suppression.
  • Adds a standalone rdk_log_dedup_filter utility and new unit tests for the dedup engine.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 12 comments.

Show a summary per file
File Description
src/include/rdk_log_dedup.h Declares dedup config/state types and dedup API used by the logger.
src/rdk_log_dedup.c Implements the dedup hashing/state tracking and suppression/summary behavior.
src/rdk_debug_priv.c Integrates dedup into rdk_dbg_priv_log_msg() and parses dedup config keys from debug.ini.
src/Makefile.am Adds the dedup implementation source to the logger library build.
utils/rdk_log_dedup_filter.c Adds a standalone tool to filter consecutive duplicates in log files (optionally in-place).
utils/Makefile.am Adds the new filter tool target to the utils build.
debug.ini.sample Documents the new dedup configuration keys.
unittests/rdkLoggerDedupTest.cpp Adds unit tests covering dedup enable/disable and suppression behavior.
unittests/CMakeLists.txt Adds the new dedup test to the unit test build.
Comments suppressed due to low confidence (1)

unittests/CMakeLists.txt:48

  • rdkLoggerDedupTest.cpp includes rdk_log_dedup.h, which lives under src/include/. The unit test CMake currently only adds installed include directories, so the new test will fail to compile unless src/include is on the include path (the header is not installed via include/Makefile.am).

Add the repository’s src/include directory to the test include paths.

  rdkLoggerDedupTest.cpp
  main.cpp
)

include_directories(${CMAKE_INSTALL_PREFIX}/include)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/rdk_debug_priv.c
Comment on lines 308 to +312
}
}
}

/* Parse dedup configuration keys */
Comment thread src/rdk_log_dedup.c
Comment on lines +159 to +161
/* Check if this is a duplicate of the previous message */
if (slot->repeat_count > 0 && slot->last_msg_hash == msg_hash)
{
Comment thread src/rdk_log_dedup.c
if ((now - slot->first_seen) >= (time_t)g_dedup_config.window_sec)
{
/* Window expired - flush summary and allow this message */
fprintf(stderr, "Previous message repeated %u times\n", slot->repeat_count);
Comment thread src/rdk_log_dedup.c
Comment on lines +175 to +178
if (slot->repeat_count >= g_dedup_config.max_suppress)
{
/* Max reached - flush and allow */
fprintf(stderr, "Previous message repeated %u times\n", slot->repeat_count);
Comment thread src/rdk_log_dedup.c
Comment on lines +192 to +197
/* Different message or first message */
if (slot->repeat_count > 0)
{
/* Emit summary for previous suppression run */
fprintf(stderr, "Previous message repeated %u times\n", slot->repeat_count);
}
Comment thread src/rdk_log_dedup.c
Comment on lines +165 to +167
/* Window expired - flush summary and allow this message */
fprintf(stderr, "Previous message repeated %u times\n", slot->repeat_count);
slot->repeat_count = 0;
Comment on lines +34 to +38
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
fclose(input);
return 1;
}
output = tmp_output;
Comment thread src/rdk_log_dedup.c
{
/* Window expired - flush summary and allow this message */
fprintf(stderr, "Previous message repeated %u times\n", slot->repeat_count);
slot->repeat_count = 0;
Comment thread src/rdk_log_dedup.c
{
/* Max reached - flush and allow */
fprintf(stderr, "Previous message repeated %u times\n", slot->repeat_count);
slot->repeat_count = 0;
/* Process lines */
while (fgets(line, sizeof(line), input) != NULL)
{
const char *content = strip_timestamp(line);
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.

3 participants