Skip to content

RDKB-65004: Log reduction changes#57

Open
jayasrikadiyal wants to merge 5 commits into
developfrom
RDKB-65004-openspec-changes
Open

RDKB-65004: Log reduction changes#57
jayasrikadiyal wants to merge 5 commits into
developfrom
RDKB-65004-openspec-changes

Conversation

@jayasrikadiyal

Copy link
Copy Markdown

Summary

This PR implements a log duplicate suppression framework for rdk_logger to reduce log uploads from devices.

Changes

OpenSpec Proposal (openspec/changes/log-suppression/):

  • proposal.md: Why and what changes
  • design.md: Technical design with decisions and trade-offs
  • tasks.md: Implementation task breakdown

Core Implementation:

  • include/rdk_log_suppression.h: Public API for log suppression subsystem
  • src/rdk_log_suppression.c: Core engine using FNV-1a hash and per-category ring buffer (8 slots)
  • src/rdk_debug_priv.c: Integrated suppression check into rdk_dbg_priv_log_msg() after priority filter
  • src/rdk_logger_init.c: Wired init/deinit into logger lifecycle
  • configure.ac: Added --enable-log-suppression build flag
  • src/Makefile.am: Added new source to library build

Nvram Sync Dedup:

  • utils/rdk_log_dedup_sync.c: Pre-upload deduplication utility
  • scripts/logDedup.sh: Shell wrapper for batch log dedup before upload

Key Design Decisions:

  • Suppression at component level (inside gLoggingMutex, zero extra synchronization)
  • Pattern matching on format string hash (catches parametric duplicates)
  • Bounded memory: fixed 8-slot ring buffer per category, lazy allocation
  • Configurable per-module via debug.ini
  • Disabled by default; enabled with LOG.RDK.SUPPRESS = ON

Impact:

  • Reduces storage exhaustion from repetitive log flooding
  • Reduces bandwidth from log uploads
  • O(1) overhead per log call (<50ns on ARM Cortex-A53)
  • Fully backward compatible (no API changes, compile-time gated)

@jayasrikadiyal jayasrikadiyal requested a review from a team as a code owner June 16, 2026 20:42
Copilot AI review requested due to automatic review settings June 16, 2026 20:42
Comment thread utils/rdk_log_dedup_sync.c Fixed

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

This PR introduces a duplicate log suppression capability to reduce on-device log growth and uploaded log volume, combining (1) in-process suppression in rdk_logger and (2) a pre-upload, file-based deduplication step plus supporting OpenSpec artifacts.

Changes:

  • Added a suppression engine (include/rdk_log_suppression.h, src/rdk_log_suppression.c) and integrated it into the logging path and lifecycle (src/rdk_debug_priv.c, src/rdk_logger_init.c), plus build wiring (src/Makefile.am, configure.ac).
  • Added a pre-upload dedup utility (utils/rdk_log_dedup_sync.c) and wrapper script (scripts/logDedup.sh).
  • Added OpenSpec proposal/design/tasks plus repository automation documentation (GitHub skills/prompts).

Reviewed changes

Copilot reviewed 23 out of 23 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
utils/rdk_log_dedup_sync.c New standalone tool to collapse consecutive duplicate log lines with a summary marker.
src/rdk_logger_init.c Hooks suppression init/deinit into logger lifecycle (compile-time gated).
src/rdk_log_suppression.c New suppression engine (hash-based pattern tracking with per-category ring buffer).
src/rdk_debug_priv.c Adds suppression check before emitting log4c messages (compile-time gated).
src/Makefile.am Adds suppression engine source file to the library build.
scripts/logDedup.sh Wrapper script to run pre-upload log dedup across a directory.
openspec/changes/log-suppression/tasks.md Implementation task breakdown for the log suppression change.
openspec/changes/log-suppression/README.md Brief readme for the delta spec change folder.
openspec/changes/log-suppression/proposal.md Problem statement and proposed feature changes.
openspec/changes/log-suppression/design.md Technical design decisions/trade-offs for suppression.
openspec/changes/log-suppression/.openspec.yaml OpenSpec change metadata.
include/rdk_log_suppression.h Public API for configuring/checking suppression and retrieving stats.
configure.ac Adds --enable-log-suppression flag and HAVE_LOG_SUPPRESSION define/conditional.
.github/skills/openspec-sync-specs/SKILL.md Documentation for an OpenSpec sync workflow skill.
.github/skills/openspec-propose/SKILL.md Documentation for an OpenSpec proposal workflow skill.
.github/skills/openspec-explore/SKILL.md Documentation for an OpenSpec exploration workflow skill.
.github/skills/openspec-archive-change/SKILL.md Documentation for an OpenSpec archive workflow skill.
.github/skills/openspec-apply-change/SKILL.md Documentation for an OpenSpec apply/implementation workflow skill.
.github/prompts/opsx-sync.prompt.md Prompt doc for syncing delta specs to main specs.
.github/prompts/opsx-propose.prompt.md Prompt doc for generating an OpenSpec proposal.
.github/prompts/opsx-explore.prompt.md Prompt doc for explore mode behavior.
.github/prompts/opsx-archive.prompt.md Prompt doc for archiving OpenSpec changes.
.github/prompts/opsx-apply.prompt.md Prompt doc for applying/implementing OpenSpec tasks.

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

Comment thread src/rdk_debug_priv.c
Comment on lines +53 to +55
#ifdef HAVE_LOG_SUPPRESSION
#include "rdk_log_suppression.h"
#endif

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Good catch. HAVE_LOG_SUPPRESSION is coming from config.h, so checking it before including config.h can compile the suppression paths out of the translation unit. This affects both src/rdk_debug_priv.c and src/rdk_logger_init.c. I’ll move the config.h include to the top of both files before any HAVE_LOG_SUPPRESSION guards.

Comment thread src/rdk_logger_init.c
Comment on lines +41 to +43
#ifdef HAVE_LOG_SUPPRESSION
#include "rdk_log_suppression.h"
#endif
Comment thread src/rdk_log_suppression.c Outdated
Comment thread src/rdk_log_suppression.c Outdated
Comment thread src/rdk_log_suppression.c
Comment thread src/rdk_log_suppression.c
Comment on lines +181 to +183
if (!g_suppress.initialized || !g_suppress.globally_enabled) {
return RDK_SUPPRESS_PASS;
}
Comment thread scripts/logDedup.sh Outdated

LOG_DIR="${1:-/rdklogs/logs}"
THRESHOLD="${2:-2}"
DEDUP_BIN="/usr/bin/rdkLogDedupSync"
Comment thread scripts/logDedup.sh Outdated
Comment thread utils/rdk_log_dedup_sync.c Outdated
Comment thread utils/rdk_log_dedup_sync.c
@jayasrikadiyal jayasrikadiyal changed the title RDKB-65004: OpenSpec proposal and code changes RDKB-65004: Log reduction changes Jun 16, 2026
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 16, 2026 22:38

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

Copilot reviewed 8 out of 8 changed files in this pull request and generated 7 comments.

Comment thread src/rdk_log_suppression.c
Comment on lines +199 to +217
if (elapsed > (double)cat->window_sec) {
/* Window expired - emit summary if we suppressed, then reset */
if (entry->repeat_count > cat->threshold) {
uint32_t suppressed = entry->repeat_count - cat->threshold;
*repeat_count = suppressed;
}
cat->total_summaries++;
/* Reset entry for new window */
entry->first_seen = now;
entry->last_seen = now;
entry->repeat_count = 1;
return RDK_SUPPRESS_EMIT_SUMMARY;
}
/* Window expired but below threshold - reset */
entry->first_seen = now;
entry->last_seen = now;
entry->repeat_count = 1;
return RDK_SUPPRESS_PASS;
}
Comment thread configure.ac
Comment thread src/Makefile.am Outdated
Comment thread scripts/logDedup.sh
Comment on lines +27 to +40
LOG_DIR="${1:-/rdklogs/logs}"
THRESHOLD="${2:-2}"
DEDUP_BIN="/usr/bin/rdkLogDedupSync"
DEDUP_COUNT=0

if [ ! -d "$LOG_DIR" ]; then
echo "Error: Log directory not found: $LOG_DIR"
exit 1
fi

if [ ! -x "$DEDUP_BIN" ]; then
echo "Error: Dedup binary not found or not executable: $DEDUP_BIN"
exit 1
fi
Comment thread utils/rdk_log_dedup_sync.c
Comment thread configure.ac
PKG_CHECK_MODULES([LOG4C], [log4c >= 1.2.3])


dnl Log suppression feature
Comment thread src/rdk_logger_init.c
Comment on lines +79 to +81
#ifdef HAVE_LOG_SUPPRESSION
rdk_log_suppression_init();
#endif
Copilot AI review requested due to automatic review settings June 16, 2026 23:39

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

Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.

Comment thread src/rdk_log_suppression.c
Comment on lines +199 to +217
if (elapsed > (double)cat->window_sec) {
/* Window expired - emit summary if we suppressed, then reset */
if (entry->repeat_count > cat->threshold) {
uint32_t suppressed = entry->repeat_count - cat->threshold;
*repeat_count = suppressed;
}
cat->total_summaries++;
/* Reset entry for new window */
entry->first_seen = now;
entry->last_seen = now;
entry->repeat_count = 1;
return RDK_SUPPRESS_EMIT_SUMMARY;
}
/* Window expired but below threshold - reset */
entry->first_seen = now;
entry->last_seen = now;
entry->repeat_count = 1;
return RDK_SUPPRESS_PASS;
}
Comment thread src/rdk_logger_init.c
Comment thread src/Makefile.am Outdated
Comment thread scripts/logDedup.sh Outdated
Comment thread utils/rdk_log_dedup_sync.c
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 16, 2026 23:49

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

Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.

Comment thread src/rdk_log_suppression.c
Comment on lines +199 to +217
if (elapsed > (double)cat->window_sec) {
/* Window expired - emit summary if we suppressed, then reset */
if (entry->repeat_count > cat->threshold) {
uint32_t suppressed = entry->repeat_count - cat->threshold;
*repeat_count = suppressed;
}
cat->total_summaries++;
/* Reset entry for new window */
entry->first_seen = now;
entry->last_seen = now;
entry->repeat_count = 1;
return RDK_SUPPRESS_EMIT_SUMMARY;
}
/* Window expired but below threshold - reset */
entry->first_seen = now;
entry->last_seen = now;
entry->repeat_count = 1;
return RDK_SUPPRESS_PASS;
}
Comment on lines +28 to +31
* Usage: rdk_log_dedup_sync <input_file> <output_file> [threshold]
* Exit codes: 0 = success, 1 = error, 2 = no changes needed

#include <stdio.h>
Comment on lines +60 to +63
/**
* Deinitialize the log suppression subsystem.
* Frees all allocated suppression state.
*/
Comment thread scripts/logDedup.sh
Comment on lines +27 to +30
LOG_DIR="${1:-/rdklogs/logs}"
THRESHOLD="${2:-2}"
DEDUP_BIN="${DEDUP_BIN:-/usr/bin/rdkLogDedupSync}"
DEDUP_COUNT=0
Comment thread src/rdk_logger_init.c
Comment on lines 80 to +84
/* Perform Dynamic Logger Internal Init */
rdk_dyn_log_init();
#ifdef HAVE_LOG_SUPPRESSION
rdk_log_suppression_init();
#endif
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