Token导航 LogoToken导航

Agent Skill · 运维和基础设施

logging-performance-optimization(日志记录性能优化)

logging-performance-optimization 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

logging-performance-optimization 是运维和基础设施类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为需要联网;许可证信息还不明确,第三方扫描已通过,按安装量在运维和基础设施类的 2,449 个 Skill 里排第 1,383。

总安装 612周安装 25GitHub Stars 1下载 196核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
unknown

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:logging-performance-optimization(日志记录性能优化)
来源仓库:https://github.com/wojons/skills
仓库路径:skills/logging-performance-optimization
安装命令:
npx skills add https://github.com/wojons/skills --skill logging-performance-optimization
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/wojons/skills --skill logging-performance-optimization

这个 Skill 是做什么的

运维和基础设施类 Skill 处理部署、监控、日志和云资源,多数需要较高的执行权限。

用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息。适合围绕仓库状态、代码变更或协作事项进行整理。可通过来源仓库和 README 进一步验证具体用法。安装前建议确认权限范围、维护状态及是否触发联网或文件读写。

适用于 Codex、Claude、Cursor 和 Gemini CLI 等宿主环境。

来源仓库内路径:skills/logging-performance-optimization

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/wojons/skills --skill logging-performance-opti…;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它需要需要联网,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

logging-performance-optimization 怎么安装?

在终端执行 npx skills add https://github.com/wojons/skills --skill logging-performance-optimization。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

logging-performance-optimization 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

logging-performance-optimization 需要什么权限?

权限级别是需要联网。该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

logging-performance-optimization 是免费的吗?

公开资料没有标注明确许可证,收费和商用限制都无法确认。正式使用前请到来源仓库核对授权说明。

logging-performance-optimization 用的人多吗?

公开数据是累计安装 612 次,近一周安装 25 次,下载 196 次,GitHub 1 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

logging-performance-optimization 安全吗?

第三方扫描结果为通过,但这只覆盖已知的静态检查项,不能替代自己读一遍源码和安装命令。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 第三方扫描已通过,常见的高风险行为没有命中。

先想清楚的地方

  • 许可证没有明确标注,能不能商用、能不能再分发都不确定。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理运维和基础设施类任务、又不想每次都手写提示词的人。

不太适合

  • 需要明确授权才能用到公司项目里的场景。
  • 需要厂商级技术支持和 SLA 的生产系统。

运维和基础设施类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
brainstorming

头脑风暴 · Codex、Claude

3,148,776173,131操作浏览器MIT通过
copywriting

文案写作 · Codex、Claude

1,996,72425,583需要联网MIT通过
openclaw-secure-linux-cloud

OpenClaw secure linux cloud 命令行 · Codex、Claude

1,853,08840接触敏感数据未明确未通过
xget

xget 命令行 · Codex、Claude

1,799,28040执行命令未明确未通过
requesting-code-review

代码审查请求 · Codex、Claude

1,590,144173,103权限未标注MIT通过
logging-performance-optimization

日志记录性能优化 · 本页

6121需要联网未明确通过

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

Logging Performance Optimization

Optimize logging performance by reducing overhead, implementing async logging, buffering strategies, sampling techniques, and analyzing performance impact for high-throughput and latency-sensitive systems.

When to use me

Use this skill when:

  • Logging overhead is impacting application performance
  • Building high-throughput systems where logging cost matters
  • Optimizing latency-sensitive applications
  • Implementing logging for resource-constrained environments
  • Diagnosing performance issues related to logging
  • Designing logging strategies for large-scale deployments
  • Balancing observability needs with performance requirements
  • Implementing cost-effective logging for cloud environments
  • Tuning logging configurations for optimal performance

What I do

1. Logging Overhead Analysis

  • Measure logging CPU overhead for different log levels and formats
  • Analyze memory usage for log buffers and structures
  • Calculate I/O impact of synchronous vs asynchronous logging
  • Profile logging call sites to identify performance bottlenecks
  • Benchmark different logging libraries and configurations
  • Quantify network overhead for remote log forwarding
  • Measure storage performance impact for log writing

2. Async Logging & Buffering

  • Implement asynchronous loggers to decouple application from I/O
  • Design buffer strategies (ring buffers, linked lists, memory-mapped files)
  • Configure buffer sizing based on throughput and memory constraints
  • Implement backpressure handling for buffer overflow scenarios
  • Optimize flush strategies (time-based, size-based, event-based)
  • Handle graceful shutdown with buffer draining
  • Monitor buffer health and performance metrics

3. Log Sampling Strategies

  • Implement probabilistic sampling for high-volume logs
  • Design rate-based sampling to control log volume
  • Create context-aware sampling based on trace characteristics
  • Implement dynamic sampling that adjusts based on system load
  • Configure sampling differently per log level (100% errors, 1% debug)
  • Handle sampled trace completeness for distributed tracing
  • Implement consistent sampling for the same trace across services

4. Performance Optimization Techniques

  • Lazy evaluation of log message arguments
  • Conditional logging checks before expensive operations
  • String building optimization for log message construction
  • Object serialization minimization in log statements
  • Thread-local optimizations for concurrent logging
  • Memory allocation reduction in logging hot paths
  • CPU cache-friendly logging data structures

5. Cost-Benefit Analysis

  • Calculate observability value vs performance cost
  • Optimize log detail level based on environment and needs
  • Implement tiered logging with different performance characteristics
  • Balance human readability with machine efficiency
  • Configure environment-specific optimizations
  • Implement feature flags for logging performance features
  • Monitor and adjust based on actual performance impact

Performance Impact Measurement

Benchmarking Methodology

import time
import statistics

def benchmark_logging(logger, iterations=10000):
    """Benchmark logging performance"""
    times = []

    # Warm up
    for _ in range(1000):
        logger.info("Warm up message")

    # Benchmark
    for i in range(iterations):
        start = time.perf_counter_ns()
        logger.info(f"Benchmark message {i}")
        end = time.perf_counter_ns()
        times.append(end - start)

    # Calculate statistics
    avg_ns = statistics.mean(times)
    p95_ns = statistics.quantiles(times, n=20)[18]  # 95th percentile
    p99_ns = statistics.quantiles(times, n=100)[98]  # 99th percentile

    return {
        "iterations": iterations,
        "average_ns": avg_ns,
        "p95_ns": p95_ns,
        "p99_ns": p99_ns,
        "throughput_per_second": 1_000_000_000 / avg_ns
    }

Overhead Calculation

Logging Performance Analysis
───────────────────────────
Configuration: JSON structured logging, file appender

Baseline (no logging):
- Average request latency: 45ms
- Throughput: 2,222 requests/second
- CPU utilization: 35%

With INFO-level logging:
- Average request latency: 52ms (+15.5%)
- Throughput: 1,923 requests/second (-13.5%)
- CPU utilization: 42% (+7 percentage points)

With DEBUG-level logging:
- Average request latency: 89ms (+97.8%)
- Throughput: 1,124 requests/second (-49.4%)
- CPU utilization: 58% (+23 percentage points)

Cost Analysis:
- INFO logging: Acceptable overhead for production
- DEBUG logging: Unacceptable for production at scale
- Recommendation: Sample DEBUG logs at 1% rate

Async Logging Patterns

Ring Buffer Implementation

public class AsyncLogger {
    private final RingBuffer<LogEvent> buffer;
    private final Thread writerThread;
    private volatile boolean running = true;

    public AsyncLogger(int bufferSize) {
        this.buffer = new RingBuffer<>(bufferSize);
        this.writerThread = new Thread(this::writeLoop);
        this.writerThread.start();
    }

    public void log(LogLevel level, String message, Map<String, Object> context) {
        LogEvent event = new LogEvent(level, message, context, System.currentTimeMillis());

        // Non-blocking offer, drop if buffer full (backpressure)
        if (!buffer.offer(event)) {
            droppedEvents.increment();
            if (shouldLogDropWarning()) {
                syncLogWarning("Log buffer full, dropped event");
            }
        }
    }

    private void writeLoop() {
        while (running || !buffer.isEmpty()) {
            LogEvent event = buffer.poll(100, TimeUnit.MILLISECONDS);
            if (event != null) {
                writeToDestination(event);
            }
        }
    }
}

Lazy Evaluation Pattern

class LazyLogger:
    def __init__(self, logger):
        self.logger = logger

    def debug(self, message_factory, **context):
        """Only evaluate message if debug logging is enabled"""
        if self.logger.isEnabledFor(logging.DEBUG):
            # Evaluate the expensive message factory
            message = message_factory()
            self.logger.debug(message, extra=context)

# Usage
logger.debug(lambda: f"Expensive debug: {expensive_operation()}", user_id=user.id)

Sampling Strategies

Probabilistic Sampling

type Sampler struct {
    rate    float64 // 0.0 to 1.0
    rng     *rand.Rand
    mu      sync.Mutex
}

func (s *Sampler) ShouldSample(traceID string) bool {
    s.mu.Lock()
    defer s.mu.Unlock()

    // Use trace ID for consistent sampling decision
    hash := fnv.New64a()
    hash.Write([]byte(traceID))
    seed := hash.Sum64()
    s.rng.Seed(int64(seed))

    return s.rng.Float64() < s.rate
}

// Usage in logging
if sampler.ShouldSample(traceID) || level >= WARN {
    logger.Log(level, message, fields...)
}

Rate-Based Sampling

class RateLimitingSampler {
    private buckets = new Map<string, { count: number, resetTime: number }>();
    private readonly windowMs = 60000; // 1 minute

    shouldSample(key: string, limitPerMinute: number): boolean {
        const now = Date.now();
        let bucket = this.buckets.get(key);

        if (!bucket || now > bucket.resetTime) {
            bucket = { count: 0, resetTime: now + this.windowMs };
            this.buckets.set(key, bucket);
        }

        if (bucket.count < limitPerMinute) {
            bucket.count++;
            return true;
        }

        return false;
    }
}

// Sample debug logs at 100 per minute per user
if (level === 'DEBUG') {
    if (!sampler.shouldSample(`debug:${userId}`, 100)) {
        return; // Don't log
    }
}

Performance Optimization Examples

Conditional Logging Check

// BAD: Expensive toString() always called
logger.debug("User object: " + user.toString());

// GOOD: Check level before expensive operation
if (logger.isDebugEnabled()) {
    logger.debug("User object: " + user.toString());
}

// BETTER: Use parameterized logging with lazy evaluation
logger.debug("User object: {}", () -> user.toString());

String Building Optimization

# BAD: Multiple string concatenations
logger.info(f"User {user.id} with email {user.email} performed action {action} on {timestamp}")

# GOOD: Structured logging with separate fields
logger.info("User action performed",
    user_id=user.id,
    user_email=user.email,
    action=action,
    timestamp=timestamp.isoformat()
)

# BETTER: Use logging adapter that accepts kwargs
structured_logger.info(
    "User action performed",
    **user.to_log_dict(),
    action=action,
    timestamp=timestamp
)

Examples

# Benchmark logging performance
npm run logging-performance:benchmark -- --iterations 100000 --levels "DEBUG,INFO,ERROR"

# Analyze logging overhead in production
npm run logging-performance:analyze-overhead -- --duration 300 --output overhead.json

# Configure async logging
npm run logging-performance:configure-async -- --buffer-size 10000 --flush-interval 1000

# Implement log sampling
npm run logging-performance:configure-sampling -- --debug-rate 0.01 --info-rate 1.0 --error-rate 1.0

# Optimize existing logging
npm run logging-performance:optimize -- --path src/ --transform "conditional-checks,string-optimization"

Output format

Performance Optimization Configuration:

performance:
  async_logging:
    enabled: true
    buffer_size: 10000
    flush_interval_ms: 1000
    overflow_policy: "drop"

  sampling:
    enabled: true
    strategies:
      - type: "probabilistic"
        level: "DEBUG"
        rate: 0.01  # 1% of debug logs
      - type: "probabilistic"
        level: "TRACE"
        rate: 0.001  # 0.1% of trace logs
      - type: "rate_limiting"
        level: "INFO"
        per_minute: 1000  # Max 1000 INFO logs per minute per service
      - type: "none"
        level: "ERROR"  # All errors logged

  optimization:
    lazy_evaluation: true
    conditional_checks: true
    structured_format: true
    buffer_pooling: true
    thread_local_buffers: true

  monitoring:
    metrics:
      - logging_latency_p50
      - logging_latency_p99
      - buffer_utilization
      - dropped_logs
      - sampling_rate
    alerts:
      - logging_latency > 10ms
      - buffer_utilization > 90%
      - dropped_logs > 100/minute

  cost_control:
    max_logs_per_second: 1000
    storage_budget_per_day_gb: 10
    network_bandwidth_mbps: 100

Performance Analysis Report:

Logging Performance Analysis
────────────────────────────
Application: payment-service
Environment: production
Analysis Period: 2026-02-26 18:00-19:00

Performance Metrics:
- Average logging latency: 1.2ms
- 95th percentile latency: 4.5ms
- 99th percentile latency: 12.3ms
- Throughput: 850 logs/second
- CPU overhead: 8.5%
- Memory usage: 45MB (buffers)

Bottleneck Analysis:
1. JSON serialization: 45% of logging latency
2. File I/O blocking: 30% of logging latency
3. String formatting: 15% of logging latency
4. Context extraction: 10% of logging latency

Optimization Opportunities:
✅ Already implemented: Async logging with 10K buffer
⚠️  Opportunity: JSON serialization optimization (potential 45% reduction)
⚠️  Opportunity: Lazy evaluation for debug logs (potential 30% reduction)
⚠️  Opportunity: Conditional level checks (potential 15% reduction)
❌ Critical: File I/O blocking main thread in 2% of cases

Cost Analysis:
- Current logging cost: $450/month (storage + processing)
- Optimized cost estimate: $225/month (50% reduction)
- Performance improvement estimate: 65% latency reduction

Recommendations:
1. HIGH PRIORITY: Fix file I/O blocking main thread
2. MEDIUM PRIORITY: Implement JSON serialization optimization
3. MEDIUM PRIORITY: Add lazy evaluation for debug logs
4. LOW PRIORITY: Implement conditional level checks
5. LOW PRIORITY: Review sampling rates for further optimization

Expected Impact:
- Latency reduction: 65% (from 1.2ms to 0.42ms average)
- CPU overhead reduction: 50% (from 8.5% to 4.25%)
- Cost reduction: 50% (from $450 to $225/month)
- Throughput improvement: 40% (from 850 to 1190 logs/second)

Notes

  • Measure before optimizing - use profiling to identify actual bottlenecks
  • Balance performance with debuggability - don't optimize away necessary logs
  • Consider different optimization strategies for different environments
  • Monitor optimization impact to ensure no regressions
  • Test under load - logging performance characteristics change under pressure
  • Consider GC impact - logging can generate garbage collection pressure
  • Document performance optimizations for maintenance and understanding
  • Regularly review and update optimizations as code and requirements change
  • Consider trade-offs between latency, throughput, and memory usage
  • Implement gradual rollout of performance optimizations with monitoring

平台分布

Codex

35.18%
按下载量换算69

Claude

31.3%
按下载量换算61

Cursor

20.05%
按下载量换算39

Gemini CLI

9.72%
按下载量换算19

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。目前只有一个公开来源,建议同时核对源仓库。

继续浏览同类 Skills