LRUs सीखना - जब अधिक क्षमता आपके सिस्टम को बेहतर बनाती है (हिन्दी (Hindi))

LRUs सीखना - जब अधिक क्षमता आपके सिस्टम को बेहतर बनाती है

Tuesday, 09 December 2025

//

21 minute read

अधिकांश तंत्र अधिभारित होने पर विकृत होते हैं

कुछ असामान्य लगते हैं बेहतर.

यह लेख दिखाता है कि कैसे एक LRU-आधारित व्यवहार स्मृति जब यह क्षमता - पर आ जाता है तो स्वयं - अनुकूलन हो जाता है और कैसे इस पैटर्न मेरे सीखने की प्रणाली को शक्ति बोट खोज इंजन. यह भी सबसे छोटा संभव संस्करण है डिएसई वास्तुकला संसाधन दबाव के माध्यम से नियंत्रित विकास

यदि आप ' मेरे लेख पर पढ़ा है सीक्यूआरएस और घटना खोजआप कुछ पैटर्न यहाँ पहचान सकते हैं. लेकिन यह सीक्यूआरएस हड्डी से stripped है.

मूल विचार - बजट पर व्यवहारिक स्मृति

हम में डुबोने से पहले मैं एक शब्द परिभाषित करूँगा Ill use throughout हस्ताक्षरएक हस्ताक्षर कोई स्थिर कुंजी है जो व्यवहार पैटर्न का प्रतिनिधित्व करता है।

क्या अगर आप एक सिस्टम बना सकते हैं कि

  • उत्तर 1ms के नीचे
  • डाटाबेस लेखन पर कभी भी अवरोध नहीं करता
  • दबाव के अधीन अनुकूलन करता है
  • भूल जाता है क्या नहीं करता
  • क्या याद रखता है

कि ठीक है क्या ' IMemoryCache स्लाइडिंग समाप्ति के साथ आपको देता है - यदि आप समझते हैं कि क्या आप बना रहे हैं

LRU कैश वास्तव में क्या करता है

LRU (अधिक से कम हाल ही में उपयोग किया गया)\ कैश उन प्रविष्टियों को बाहर निकालती है जो अभी तक नहीं पहुँची गई हैं'\अधिक समय से नहीं पहुँचे गए हैं\ .\ जब कैश भर जाती है\M SK4\ सबसे ठंडा प्रविष्टि गर्म के लिए जगह बनाने के लिए बाहर फेंक दिया जाता है

अधिकांश विकासकर्ता इसे एक सीमा के रूप में देखते हैं क्यास पूरा है

लेकिन व्यवहारिक सिस्टम के लिए यह एक विशेषता है

// From WeightStore.cs - the bounded memory window
_cache = new MemoryCache(new MemoryCacheOptions
{
    SizeLimit = _cacheSize,           // e.g., 1000 entries
    CompactionPercentage = 0.25       // Remove 25% when limit reached
});

कि SizeLimit सिर्फ एक स्मृति अवरोध नहीं है चयन दबावयह निर्धारित करता है कि सिस्टम कितना याद रखता है और उसे क्या महत्वपूर्ण है पर ध्यान देने के लिए बाध्य करता है

स्लाइडिंग समाप्ति - वह घड़ी जो भूलती है

स्लिडिंग समाप्ति के साथ संयोजन से आप स्वचालित भूल प्राप्त कर सकते हैं

// From WeightStore.cs:254-259
private MemoryCacheEntryOptions GetCacheEntryOptions()
{
    return new MemoryCacheEntryOptions()
        .SetSlidingExpiration(_slidingExpiration)  // 30 minutes
        .SetSize(1);  // Each entry counts as 1 toward size limit
}

यदि कोई हस्ताक्षर नहीं है, तो यह बाहर निकाला गया है.

यह करता है स्वाभाविक भूल:

  • आईपी पुनः माना जाता है
  • बोट्स हस्ताक्षर घुमाएँ
  • ट्रैफिक पैटर्न स्विच
  • कल ' के आक्रमण आज ' नहीं हैं

स्थिर ब्लॉक सूची अस्थिर हो जाती है. स्लाइडिंग समाप्ति स्मृति को ताजा रखती है

IMemoryCache Pattern - Tiny CQRS Without Saying

यहाँ-' यह कार्य करता है कि पैटर्न है SqliteWeightStore वर्ग

/// <summary>
///     SQLite implementation of the weight store with sliding expiration memory cache.
///     Uses a CQRS-style pattern with write-behind:
///     - Reads: Hit memory cache first (fast path), fall back to SQLite on miss
///     - Writes: Update cache immediately, queue SQLite writes for background flush
///     Sliding expiration provides automatic LRU-like eviction behavior.
/// </summary>

public class SqliteWeightStore : IWeightStore, IAsyncDisposable
{
    // Memory cache with sliding expiration - auto-evicts least recently used entries
    private readonly MemoryCache _cache;

    // Write-behind queue for batched SQLite persistence
    private readonly ConcurrentDictionary<string, PendingWrite> _pendingWrites = new();
    private readonly Timer _flushTimer;
    private readonly TimeSpan _flushInterval = TimeSpan.FromMilliseconds(500);

यह है अनौपचारिक सीक्यूआरएस - लेकिन कंटायर कैश अमान्यीकरण के बिना कैश लेखन मॉडल हैSQLite केवल स्थायी खाता है

flowchart LR
    subgraph Cache["In-Memory Behaviour Store"]
        A[Hot Signatures] --- B[Sliding Expiry]
    end
    subgraph DB["SQLite Ledger"]
        C[(Durable Write-Behind)]
    end

    A --Periodic Flush--> C
    B --Eviction--> D[Forgotten]

    style Cache fill:none,stroke:#10b981,stroke-width:2px
    style DB fill:none,stroke:#6366f1,stroke-width:2px

प्रमुख अंतर्दृष्टि पढ़ता और लिखता स्मृति में जाता हैडाटाबेस अंततः संगत है

पठन पथ - कैश पहले

जब एक डिटेक्टर को सीखी हुई भार की आवश्यकता होती है, तो यह कैश पर आ जाता है

// From WeightStore.cs:421-472
public async Task<double> GetWeightAsync(
    string signatureType,
    string signature,
    CancellationToken ct = default)
{
    var key = CacheKey(signatureType, signature);

    // Check cache first (fast path - no DB access)
    if (_cache.TryGetValue(key, out LearnedWeight? cached) && cached != null)
    {
        _metrics?.RecordCacheHit(signatureType);
        return cached.Weight * cached.Confidence;
    }

    _metrics?.RecordCacheMiss(signatureType);

    // Cache miss - load from DB
    await EnsureInitializedAsync(ct);

    await using var conn = new SqliteConnection(_connectionString);
    await conn.OpenAsync(ct);

    var sql = $@"
        SELECT weight, confidence, observation_count, first_seen, last_seen
        FROM {TableName}
        WHERE signature_type = @type AND signature = @sig
    ";

    // ... execute query ...

    if (await reader.ReadAsync(ct))
    {
        // Cache the result for future reads
        var learnedWeight = new LearnedWeight { /* ... */ };
        _cache.Set(key, learnedWeight, GetCacheEntryOptions());

        return weight * confidence;
    }

    return 0.0;  // No learned weight exists
}

गर्म पथ डाटाबेस पर कभी नहीं हाटकैश पढ़ने के लिए सत्य का स्रोत है

लेखन पथ - Cache Immediately, Persist Later

जब सिस्टम कुछ नया सीखता है, तो यह कैश को तुरंत अद्यतन करता है और डेटाबेस की कतारें लिखती हैं

// From WeightStore.cs:551-582
public Task UpdateWeightAsync(
    string signatureType,
    string signature,
    double weight,
    double confidence,
    int observationCount,
    CancellationToken ct = default)
{
    var key = CacheKey(signatureType, signature);

    // Update cache immediately (source of truth for reads)
    var learnedWeight = new LearnedWeight
    {
        SignatureType = signatureType,
        Signature = signature,
        Weight = weight,
        Confidence = confidence,
        ObservationCount = observationCount,
        FirstSeen = DateTimeOffset.UtcNow,
        LastSeen = DateTimeOffset.UtcNow
    };
    _cache.Set(key, learnedWeight, GetCacheEntryOptions());

    // Queue for async SQLite persistence (write-behind)
    QueueWrite(signatureType, signature, weight, confidence, observationCount);

    return Task.CompletedTask;
}

सूचना UpdateWeightAsync लौटता है Task.CompletedTask यह अनिवार्य रूप से समक्रमित है

  • उप-- Millisecond लेखन विलंब
  • I/O पर कोई अवरोध नहीं
  • लेखन को सम्मिलित किया जाता है (last write winsM SK1

पृष्ठभूमि फ्लशर -

प्रत्येक लंबित लेखन को एक बैच में SQLite में फ्लैश किया जाता है

// From WeightStore.cs:274-357
public async Task FlushPendingWritesAsync(CancellationToken ct = default)
{
    if (_pendingWrites.IsEmpty) return;

    // Only one flush at a time
    if (!await _flushLock.WaitAsync(0, ct)) return;

    try
    {
        await EnsureInitializedAsync(ct);

        // Snapshot and clear pending writes atomically
        var writes = new List<PendingWrite>();
        foreach (var key in _pendingWrites.Keys.ToList())
        {
            if (_pendingWrites.TryRemove(key, out var write))
            {
                writes.Add(write);
            }
        }

        if (writes.Count == 0) return;

        await using var conn = new SqliteConnection(_connectionString);
        await conn.OpenAsync(ct);
        await using var transaction = await conn.BeginTransactionAsync(ct);

        try
        {
            var sql = $@"
                INSERT INTO {TableName}
                    (signature_type, signature, weight, confidence,
                     observation_count, first_seen, last_seen)
                VALUES (@type, @sig, @weight, @conf, @count, @now, @now)
                ON CONFLICT(signature_type, signature) DO UPDATE SET
                    weight = @weight,
                    confidence = @conf,
                    observation_count = @count,
                    last_seen = @now
            ";

            foreach (var write in writes)
            {
                await using var cmd = new SqliteCommand(sql, conn, transaction);
                // ... add parameters and execute ...
            }

            await transaction.CommitAsync(ct);
            _logger.LogDebug("Flushed {Count} pending writes in {Duration:F1}ms",
                writes.Count, sw.ElapsedMilliseconds);
        }
        catch
        {
            await transaction.RollbackAsync(ct);
            throw;
        }
    }
    finally
    {
        _flushLock.Release();
    }
}

यह है घटना-सोर्सिंगआप मिलते हैं

  • बैच लिखा जाता है (efficicient IM SK1O)
  • संव्यवहारात्मक सुसंगतता
  • समन्वयित अद्यतन (यदि एक ही हस्ताक्षर अद्यतन किया जाता है तो 10 बार में SSK2ms, केवल अंतिम मूल्य लिखा जाता है
  • इस एक्सेस पैटर्न के साथ SQLite पूरी तरह से खुश है

EMA अद्यतन - एक्सपोनेन्शल मोविंग औसतों के साथ सीखना

जब एक नया अवलोकन आ जाता है, सिस्टम भारों को अद्यतन करने के लिए एक्सपोनेन्शल गतिशील औसत का उपयोग करता है

// From WeightStore.cs:584-635
public Task RecordObservationAsync(
    string signatureType,
    string signature,
    bool wasBot,
    double detectionConfidence,
    CancellationToken ct = default)
{
    var key = CacheKey(signatureType, signature);

    // Calculate new weight using EMA in memory
    var alpha = 0.1;  // Learning rate
    var weightDelta = wasBot ? detectionConfidence : -detectionConfidence;

    double newWeight;
    double newConfidence;
    int newObservationCount;

    if (_cache.TryGetValue(key, out LearnedWeight? existing) && existing != null)
    {
        // Apply EMA: new_weight = old_weight * (1-α) + delta * α
        newWeight = existing.Weight * (1 - alpha) + weightDelta * alpha;
        newConfidence = Math.Min(1.0, existing.Confidence + detectionConfidence * 0.01);
        newObservationCount = existing.ObservationCount + 1;
    }
    else
    {
        // First observation
        newWeight = weightDelta;
        newConfidence = detectionConfidence;
        newObservationCount = 1;
    }

    // Update cache immediately
    var learnedWeight = new LearnedWeight
    {
        SignatureType = signatureType,
        Signature = signature,
        Weight = newWeight,
        Confidence = newConfidence,
        ObservationCount = newObservationCount,
        FirstSeen = existing?.FirstSeen ?? DateTimeOffset.UtcNow,
        LastSeen = DateTimeOffset.UtcNow
    };
    _cache.Set(key, learnedWeight, GetCacheEntryOptions());

    // Queue for persistence
    QueueWrite(signatureType, signature, newWeight, newConfidence, newObservationCount);

    return Task.CompletedTask;
}

एमएएम सूत्र सीखने को सुगम बनाता है new_weight = old_weight × (1 - α) + new_value × α

के साथ α =

  • नए साक्ष्य का योगदान 10%
  • ऐतिहासिक प्रमाणों का योगदान 90%
  • यह एकल पर्यवेक्षण से जंगली झुकावों को रोकता है

अधिप्रवाह प्रणाली को क्यों बनाता है बेहतर

यह मुख्य अंतर्दृष्टि है कि अधिकतर लोग हराते हैं

जब कैश भर जाता है

  • कम---frequency हस्ताक्षर बाहर गिरते हैं
  • केवल गर्म (frequently accessed) हस्ताक्षर स्मृति में रहते हैं
  • डाटाबेस एक फ्लश चक्र - और कि 's ठीक से पीछे है
  • तंत्र फोकस दबाव में

इसके बारे में सोचें, यदि 50,000 विशिष्ट हस्ताक्षर आपके बोट डिटेक्टर को आघात देते हैं, लेकिन आप के पास केवल स्मृति है

सबसे गर्म 10,000 - जो आमतौर पर वास्तविक ट्रैफिक का प्रतिनिधित्व करते हैं

उत्पादन में मैं लगभग 40,000 एक-एक प्रतिदिन के हस्ताक्षरों को नहीं देखता। ( एक बार प्रयास करने वाले स्क्रैपर्स। एक बार अनियमित जांचें। <img src="http: europa. eu. int/eur-lex/LexUriServ/Lexicons/2003/ LexUri Serv. do? uri=CELEX: 32001L0059: EN: HTML] विधिवत उपयोगकर्ता जो कभी वापस नहीं आएँगे।

flowchart TB
    subgraph Input["50,000 Unique Signatures"]
        Hot[Hot Signatures\n~10,000]
        Cold[Cold Signatures\n~40,000]
    end

    subgraph Cache["Bounded Cache (10,000)"]
        Kept[Kept in Memory]
    end

    subgraph Evicted["Evicted"]
        Lost[Forgotten\nNoise Traffic]
    end

    Hot --> Kept
    Cold --> Lost

    style Hot fill:none,stroke:#10b981,stroke-width:2px
    style Cold fill:none,stroke:#94a3b8,stroke-width:2px
    style Kept fill:none,stroke:#10b981,stroke-width:2px
    style Lost fill:none,stroke:#ef4444,stroke-width:2px

अधिप्रवाह मज़बूत व्यवहारिक स्मृति

जब ओवरफ्लो नहीं करता है

यह magic नहीं है

  • कैश बहुत छोटा हैयदि आपके कैश में केवल 100 प्रविष्टियों को ही रखा जाता है लेकिन आप के पास 1,000 वास्तविक रूप से महत्वपूर्ण हस्ताक्षर हैं।

  • एकरूप यातायातयदि आप एक छोटे आंतरिक प्रणाली पर चल रहे हैं जहां लगभग सब कुछ है

  • आरंभ समस्याएक नए ढंग से स्थापित प्रणाली में कोई सीखा हुआ वजन नहीं है

पैटर्न सबसे अच्छा काम करता है जब आप पावर के साथ उच्च cardinality-law वितरण बहुत सारे अद्वितीय हस्ताक्षर, लेकिन एक छोटा उपसंचय जो ट्रैफिक पर प्रभाव डालता है

Sync में कैश और डाटाबेस रखें

कैश पढ़ने के लिए सत्य का स्रोत है, लेकिन डेटाबेस स्थायी खाता है।

डिसे सिंक्रोनाइजेशन

जब डेटाबेस वज़न टूटता है, कैश को अनुसरण करने की आवश्यकता होती है DecayOldWeightsAsync विधि दोनों को संभालती है

// From WeightStore.cs:725-766
public async Task DecayOldWeightsAsync(TimeSpan maxAge, double decayFactor, CancellationToken ct = default)
{
    await EnsureInitializedAsync(ct);

    await using var conn = new SqliteConnection(_connectionString);
    await conn.OpenAsync(ct);

    var cutoff = DateTimeOffset.UtcNow.Subtract(maxAge).ToString("O");

    // Decay old weights in the database
    var sql = $@"
        UPDATE {TableName}
        SET weight = weight * @decay,
            confidence = confidence * @decay
        WHERE last_seen < @cutoff
    ";

    await using var cmd = new SqliteCommand(sql, conn);
    cmd.Parameters.AddWithValue("@decay", decayFactor);
    cmd.Parameters.AddWithValue("@cutoff", cutoff);

    var updated = await cmd.ExecuteNonQueryAsync(ct);

    // Delete weights that have decayed below threshold
    var deleteSql = $@"
        DELETE FROM {TableName}
        WHERE confidence < 0.01 OR (ABS(weight) < 0.01 AND observation_count < 5)
    ";

    await using var deleteCmd = new SqliteCommand(deleteSql, conn);
    var deleted = await deleteCmd.ExecuteNonQueryAsync(ct);

    if (updated > 0 || deleted > 0)
    {
        _logger.LogInformation(
            "Weight decay: {Updated} decayed, {Deleted} deleted",
            updated, deleted);

        // Compact cache to remove stale entries
        _cache.Compact(0.25);
    }
}

क्षय डाटाबेस रिकार्डों, के बाद हम कॉल _cache.Compact(0.25) - यह शक्ति MemoryCache अपने प्रविष्टियों से बाहर निकालने के लिए 25%

टैग-आधारित बहिष्करण

कभी-कभी आपको कैश प्रविष्टियों की पूरी श्रेणी को अवैध करने की आवश्यकता होती है उदाहरण के लिए - जब एक डिटेक्टर का पुनर्प्रशिक्षण किया जाता है या जब बाहरी डेटा परिवर्तन होते हैं

// From WeightStore.cs:768-777
/// <summary>
///     Evicts all cached entries for a specific signature type (tag-based eviction).
/// </summary>

public void EvictByTag(string signatureType)
{
    // MemoryCache doesn't natively support tag-based eviction, but we can compact
    // For now, just compact - sliding expiration will handle stale entries
    _cache.Compact(0.1);
    _logger.LogDebug("Compacted cache for signature type: {SignatureType}", signatureType);
}

.NET MemoryCache में मूल टैग नहीं है

समक्रमण रणनीति

प्रमुख अंतर्दृष्टि यह है कि पूर्ण समन्वयन आवश्यक नहीं हैसिस्टम ड्रिफ्ट सहन करता है क्योंकि

  1. क्यास डीबी से पुनः लोड करने में त्रुटि हुई - यदि कोई प्रविष्टि निकाला जाता है तो , अगला पठन ताजा डाटा लेता है
  2. स्लाइडिंग समाप्ति अस्थिरता को संभालती है - प्रविष्टियों को minutes auto के भीतर पहुँच नहीं मिला
  3. संकुचन शक्तियां नवीकरण - आवधिक संकुचन पुराने प्रविष्टि बाहर धकेलता है
  4. Write-behind coalesces updates - कई त्वरित अद्यतन एक डीबी लिखने में हो जाते हैं

यह अंततः सुसंगतता सही किया जाता है. कैश बिना जटिल अमान्यीकरण तर्क की आवश्यकता के डाटाबेस से काफी बंद रहता है

flowchart TB
    subgraph Sync["Cache-Database Synchronisation"]
        D[Database Decay] --> C[Cache Compact]
        E[Tag Eviction] --> C
        S[Sliding Expiration] --> M[Cache Miss]
        M --> R[Reload from DB]
    end

    style Sync fill:none,stroke:#6366f1,stroke-width:2px

कोई कैश अमान्यीकरण hell नहीं है. कोई जटिल pub नहीं है

गाइडिंग गियर

नोट अगर आप सिर्फ LRU चाहते हैं + लिखने के लिए - पैटर्न के पीछे-, आप यहाँ रुक सकते है .\ इस आलेख का शेष यह दिखाता है कि मैं पूरी पैट्नर प्रतिष्ठा के लिए उसी विचारों को लागू कैसे करता हूँ।

हाइस्टेरेसिस और डिसे

पैटर्न प्रतिष्ठा के लिए ( समय पर एक हस्ताक्षर या मानव है या नहीं ट्रैक करने के लिए वही सिद्धांत लागू होते हैं लेकिन अतिरिक्त जटिलता के साथ

// From PatternReputation.cs:42-108
public record PatternReputation
{
    public required string PatternId { get; init; }
    public required string PatternType { get; init; }
    public required string Pattern { get; init; }

    /// <summary>Current bot probability [0,1]. 0 = human, 1 = bot, 0.5 = neutral</summary>

    public double BotScore { get; init; } = 0.5;

    /// <summary>Effective sample count - decays over time, increases with observations</summary>

    public double Support { get; init; } = 0;

    /// <summary>Current reputation state - determines fast-path behavior</summary>

    public ReputationState State { get; init; } = ReputationState.Neutral;

    // Computed properties
    public double Confidence => Math.Min(1.0, Support / 100.0);

    public bool CanTriggerFastAbort =>
        State is ReputationState.ConfirmedBad or ReputationState.ManuallyBlocked;

    public bool CanTriggerFastAllow =>
        State is ReputationState.ConfirmedGood or ReputationState.ManuallyAllowed;
}

हाइस्टेरेसिस के साथ राज्य संक्रमण

पैटर्न न्युट्रल से कनफिगर्ड बैड के लिए सीधे फ्लिप नहीं करता है

// From PatternReputation.cs:367-421 - simplified
public PatternReputation EvaluateStateChange(PatternReputation reputation)
{
    if (reputation.IsManual)
        return reputation;

    var newState = reputation.State;
    var score = reputation.BotScore;
    var support = reputation.Support;

    switch (reputation.State)
    {
        case ReputationState.Neutral:
            // Can promote to Suspect or ConfirmedGood
            if (score >= 0.6 && support >= 10)
                newState = ReputationState.Suspect;
            else if (score <= 0.1 && support >= 100)
                newState = ReputationState.ConfirmedGood;
            break;

        case ReputationState.Suspect:
            // Can promote to ConfirmedBad or demote to Neutral
            if (score >= 0.9 && support >= 50)
                newState = ReputationState.ConfirmedBad;
            else if (score <= 0.4 || support < 10)
                newState = ReputationState.Neutral;
            break;

        case ReputationState.ConfirmedBad:
            // Can demote to Suspect (requires MORE evidence to forgive)
            if (score <= 0.7 && support >= 100)
                newState = ReputationState.Suspect;
            break;
    }

    // ... log state change and return ...
}

असममितता को नोट करें ConfirmedBad → Suspect समर्थन 100 की आवश्यकता होती है Neutral → Suspect सिर्फ की जरूरत है 10. यह जानबूझकर है | - | यह |' | संदेह से अधिक क्षमा करना कठिन है

समय समाप्ति - एक्सपोनेन्शल भूल

जब नमूने शांत हो जाते हैं तो वे तटस्थ की ओर पतन होते हैं

// From PatternReputation.cs:334-361
public PatternReputation ApplyTimeDecay(PatternReputation reputation)
{
    if (reputation.IsManual)
        return reputation;

    var hoursSinceLastSeen = (DateTimeOffset.UtcNow - reputation.LastSeen).TotalHours;

    if (hoursSinceLastSeen < 1)
        return reputation;  // Too recent to decay

    // Score decay toward prior (0.5 = neutral)
    // new_score = old_score + (prior - old_score) × (1 - e^(-Δt/τ))
    var scoreDecayFactor = 1 - Math.Exp(-hoursSinceLastSeen / _options.ScoreDecayTauHours);
    var newScore = reputation.BotScore + (0.5 - reputation.BotScore) * scoreDecayFactor;

    // Support decay
    // new_support = old_support × e^(-Δt/τ)
    var supportDecayFactor = Math.Exp(-hoursSinceLastSeen / _options.SupportDecayTauHours);
    var newSupport = reputation.Support * supportDecayFactor;

    return reputation with
    {
        BotScore = Math.Clamp(newScore, 0, 1),
        Support = newSupport
    };
}

डिफ़ॉल्ट समय स्थिरांक

  • अंक ह्रास τएक सप्ताह की निष्क्रियता के बाद प्राप्तियां तटस्थ की ओर बढ़ती हैं
  • समर्थन विघटन τ2 सप्ताह के बाद विश्वास गिरता है

इसका मतलब यह है कि एक महीने के लिए मौन रहने वाली एक सटीक”-“छोटी आईपी की पुष्टि के बाद अंततः न्यूट्रल में वापस आ जाएगी।

पृष्ठभूमि मरम्मत सेवा

ReputationMaintenanceService तीन आवधिक कार्य चलाता है

// From ReputationMaintenanceService.cs:48-129
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
    _logger.LogInformation("Reputation maintenance service starting");

    // Load persisted reputations on startup
    await _cache.LoadAsync(stoppingToken);

    var decayInterval = TimeSpan.FromMinutes(60);    // Hourly decay sweep
    var gcInterval = TimeSpan.FromHours(24);          // Daily garbage collection
    var persistInterval = TimeSpan.FromMinutes(5);   // Persist every 5 minutes

    var lastDecay = DateTimeOffset.UtcNow;
    var lastGc = DateTimeOffset.UtcNow;
    var lastPersist = DateTimeOffset.UtcNow;

    while (!stoppingToken.IsCancellationRequested)
    {
        await Task.Delay(TimeSpan.FromMinutes(1), stoppingToken);
        var now = DateTimeOffset.UtcNow;

        // Decay sweep: push stale scores toward neutral
        if (now - lastDecay >= decayInterval)
        {
            await _cache.DecaySweepAsync(stoppingToken);
            lastDecay = now;
        }

        // Garbage collection: remove old neutral patterns
        if (now - lastGc >= gcInterval)
        {
            await _cache.GarbageCollectAsync(stoppingToken);
            lastGc = now;

            var stats = _cache.GetStats();
            _logger.LogInformation(
                "Reputation stats: {Total} patterns, {Bad} bad, {Suspect} suspect",
                stats.TotalPatterns, stats.ConfirmedBadCount, stats.SuspectCount);
        }

        // Persistence: save to SQLite
        if (now - lastPersist >= persistInterval)
        {
            await _cache.PersistAsync(stoppingToken);
            lastPersist = now;
        }
    }

    // Final persist on shutdown
    await _cache.PersistAsync(CancellationToken.None);
}

कचरे का संग्रहणकर्ता उन पैटर्न को हटाता है जो हैं

  • 90+ दिन पुराना
  • समर्थन
  • तटस्थ अवस्था में

इससे स्मृति शब्दकोश में मूल्यवान सीखे गए पैटर्नों को सुरक्षित रखते हुए बिना सीमाओं के बढ़ने से बचा जाता है

एसक्यूलाइट एक मजाक नहीं है

बहुत से विकासकर्ता प्रतिक्रियात्मक रूप से PostgreSQL या Redis के लिए पहुँचते हैं

  1. Write-behind bottlenecks eliminates - SQLite 's singleM SK2writer limitation doesn't matter when writes are batched
  2. स्थानीय भंडारण - कोई नेटवर्क विलंब नहीं
  3. शून्य विन्यास - सिर्फ फ़ाइल पथ
  4. किनारा विनियोजन के लिए पूर्ण - Raspberry Pi पर चलता है
  5. पोर्टेबल - डाटाबेस सिर्फ एक फ़ाइल है जिसे आप चारों ओर कॉपी कर सकते हैं

स्कीमा न्यूनतम है

CREATE TABLE IF NOT EXISTS learned_weights (
    signature_type TEXT NOT NULL,
    signature TEXT NOT NULL,
    weight REAL NOT NULL,
    confidence REAL NOT NULL,
    observation_count INTEGER NOT NULL DEFAULT 1,
    first_seen TEXT NOT NULL,
    last_seen TEXT NOT NULL,
    PRIMARY KEY (signature_type, signature)
);

CREATE INDEX IF NOT EXISTS idx_signature_type ON learned_weights(signature_type);
CREATE INDEX IF NOT EXISTS idx_confidence ON learned_weights(confidence);
CREATE INDEX IF NOT EXISTS idx_last_seen ON learned_weights(last_seen);

यदि आप को बड़े पैमाने पर स्केल की आवश्यकता है, PostgreSQL में स्व्वाप करें. यदि आपको HA या अनुकरण की जरूरत है, Redis या एक वितरित कैश से स्वॉप करें।

एवोल्यूशन के रूप में DiSE Tie-In - असफलता

अगर डीआईएसई यह कैश पैटर्न माइटोकोंडरिया है

यह पैटर्न DiSE सिद्धांतों को न्यूनतम स्तर पर लागू करता है

  • संसाधन अवरोध चुने हुए दबाव
  • एलआरयू निष्कासन प्राकृतिक चयन
  • समय विघटन → भूलने से अनुकूलन संभव होता है
  • एमएएम अद्यतन → अवलोकन के माध्यम से परिवर्तन
  • श्लेष्माशोथ → परिवर्तन प्रतिरोध के माध्यम से स्थिरता

एक पूरा कैश विफलता नहीं है विकासात्मक दबाव. तंत्र स्वयं को -\optimizes\M SK2\hot signatures stay,\cold signatures evict\MSC4\and the behavioral memory converges toward what actually matters\ .\

कोई मैल प्रशिक्षण नहीं

निष्कर्ष - सरल संरचनाएं, इमर्जेंट व्यवहार

पूरे पैटर्न को : के रूप में घटाता है

  1. क्यास पढ़ने के लिए सत्य का स्रोत है - sub-millisecond अभिगम
  2. तत्काल अद्यतन कैश लिखता है - कोई अवरोधन नहीं है
  3. स्लाइडिंग समाप्ति स्वचालित LRU प्रदान करता है में विनिर्मित -
  4. सीमाबद्ध आकार चयन दबाव बनाता है - ओवरफ्लो फोकस को तेज करता है
  5. पृष्ठभूमि फ्लश से SQLite समक्रमित रहता है - eventual consistency is fine
  6. समय का पतन भूलने को सक्षम बनाता है - अप्रचलित साक्ष्य गायब हो गया है

आपका छोटा व्यवहार भंडार एक जीवित प्रणाली की अपेक्षा अधिक काम करता है

न्यूनतम वास्तुकला → उभरती सहीता अधिप्रवाह → बेहतर फोकस दबाव → स्थिरता

यदि आप इसे क्रिया में देखना चाहते हैं mostlylucid.botdetection - और डिएसई वास्तुकला श्रृंखला गहरे दर्शन के लिए

लिंक्स

Finding related posts...
logo

© 2026 Scott Galloway — Unlicense — All content and source code on this site is free to use, copy, modify, and sell.