perf: serve long-range studies from a decoded closed-day cache
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4143bf599e
commit
4ca9c7bf0c
16 files changed
+846
-83
No files matched your search
@@ -169,6 +169,10 @@ What enters: malicious events (scanner, exploit, bruteforce, ssh-fail, ssh-probe
|
||||
|
||||
Failure behavior: a full disk, the size cap or the day cap drop events (counted, logged at most once in a while, never fatal); a corrupted line is skipped when reading; a partial line left by an earlier failure is terminated before the next write.
|
||||
|
||||
### How studies read the registry
|
||||
|
||||
Period, funnel, metrics, campaigns and the other studies read the registry through `evlog.ScanRecs` and `ScanRefs`. A closed day (any day before the current UTC day) never changes, so it is decoded once into a compact form (strings interned per day, 112 bytes per event) and kept in memory under a cap of 96 MB (`evlog.Options.CacheMem`, negative disables it), least recently used first. A day is read again when the size or modification time of its files changes (a late line, a compression pass). The current day is always read live from the file, so the result matches a full scan exactly; sessions and campaigns that cross midnight are built over the events of the whole window, never per day. A study holds only 16-byte references to the decoded events and rebuilds those of one address when it builds that address' sessions (in parallel). Period, funnel and metrics of the same window share one scan and one set of sessions for the 30 s result lifetime. The byte budget (256 MB) counts only what is read from disk; the event count (1,500,000) and the 10 s deadline remain, and `truncated` is true only when one of them is hit (the dashboard then shows a note). First request after a restart decodes the days (3 in parallel); later ones are served from memory.
|
||||
|
||||
## Intelligence
|
||||
|
||||
The investigation layer is computed from the IP table and the registry, with no external API:
|
||||
|
||||
@@ -169,6 +169,10 @@ O que entra: eventos maliciosos (scanner, exploit, bruteforce, ssh-fail, ssh-pro
|
||||
|
||||
Comportamento em falha: disco cheio, o teto de tamanho ou o teto diário descartam eventos (contados, registrados no log no máximo de vez em quando, nunca fatais); uma linha corrompida é ignorada na leitura; uma linha parcial deixada por uma falha anterior é terminada antes da próxima escrita.
|
||||
|
||||
### Como os estudos leem o registro
|
||||
|
||||
Período, funil, métricas, campanhas e os demais estudos leem o registro por `evlog.ScanRecs` e `ScanRefs`. Um dia fechado (qualquer dia anterior ao dia UTC atual) não muda mais, então é decodificado uma vez em forma compacta (textos internados por dia, 112 bytes por evento) e mantido na memória sob um teto de 96 MB (`evlog.Options.CacheMem`, negativo desliga), o menos usado recentemente sai primeiro. Um dia é lido de novo quando o tamanho ou a data de modificação dos arquivos muda (uma linha tardia, uma compressão). O dia atual é sempre lido ao vivo do arquivo, então o resultado é idêntico ao de uma varredura completa; sessões e campanhas que cruzam a meia-noite são montadas sobre os eventos da janela inteira, nunca por dia. O estudo guarda só referências de 16 bytes aos eventos decodificados e reconstrói os de um endereço ao montar as sessões dele (em paralelo). Período, funil e métricas da mesma janela compartilham uma varredura e um conjunto de sessões durante os 30 s de vida do resultado. O orçamento de bytes (256 MB) conta só o que é lido do disco; o limite de eventos (1.500.000) e o prazo de 10 s continuam, e `truncated` só é verdadeiro quando um deles é atingido (o painel então mostra um aviso). A primeira requisição após reiniciar decodifica os dias (3 em paralelo); as seguintes saem da memória.
|
||||
|
||||
## Inteligência
|
||||
|
||||
A camada de investigação é calculada a partir da tabela de IPs e do registro, sem API externa:
|
||||
|
||||
Reference in new issue
Block a user