πΎ Cache
Optimize Jibril's memory usage and detection accuracy by tuning cache sizes for your workload. Proper cache configuration ensures comprehensive monitoring without excessive resource consumption.
π§ Understanding Cachesβ
Jibril uses in-memory caches to correlate system events, track processes, and maintain behavioral context. These caches bridge the gap between kernel-level eBPF events and userland detection logic. While some data is inherently volatile and must always be queried from the kernel, a significant portion is non-volatile. Caching this non-volatile data eliminates multiple round trips to the kernel, improving performance.
π Cache sizing has an direct relationship with cadence configuration: shorter check intervals allow for smaller caches (since data is processed more frequently), while longer intervals require larger caches to retain context between checks.
π― Purposeβ
Store transient data about:
- Running processes and tasks
- Files accessed and their attributes
- Network flows and connections
- Behavioral correlations
βοΈ Trade-offsβ
Larger caches:
- β Fewer missed detections
- β Better correlation accuracy
- β Higher memory usage
Smaller caches:
- β Lower memory footprint
- β Possible missed detections
- β Less context retention
This combination enables Jibril to respond quickly to system changes while maintaining the context needed to detect sophisticated threats that unfold over time. Even under heavy workloads, Jibril's resource usage remains predictable and deterministic.
π Cache Categoriesβ
Jibril uses different cache types for different system resources:
π Task-Related Cachesβ
Store process and execution data.
rec-tasks- Recent task historytasks- Active OS processescmds- Command linesargs- Command arguments
π File-Related Cachesβ
Store file access and correlation data.
files- Accessed filesdirs- Accessed directoriesbases- Base pathstask-file- Task β File mappingfile-task- File β Task mappingtask-ref- Task references
π Network Flow Cachesβ
Store network communication data.
flows- Network flowstask-flow- Task β Flow mappingflow-task- Flow β Task mappingflow-ref- Flow references
βοΈ Configuration Examplesβ
Choose a configuration based on your environment's workload and resource constraints.
π― 1. Default (Balanced)β
Good for most use cases with moderate activity.
caches:
rec-tasks: 32
tasks: 64
cmds: 32
args: 32
files: 32
dirs: 16
bases: 32
task-file: 32
file-task: 32
task-ref: 32
flows: 32
task-flow: 32
flow-task: 32
flow-ref: 32
Characteristics:
- π Balanced memory usage for most workloads
- β Handles moderate concurrent processes
- β Suitable for typical container and server workloads
- β This is the default configuration from standalone.yaml
- β οΈ Heavy workloads might need smaller cadences to avoid miss detections
- β οΈ Small containers may be susceptible to Out of Memory (OOM) errors
π± 2. Small Devicesβ
Minimized memory footprint for resource-constrained environments.
caches:
rec-tasks: 16
tasks: 32
cmds: 16
args: 16
files: 16
dirs: 4
bases: 8
task-file: 256
file-task: 256
task-ref: 256
flows: 64
task-flow: 64
flow-task: 64
flow-ref: 64
Characteristics:
- π Minimal memory usage for small containers
- β Suitable for embedded systems (like IoT and edge devices)
- β οΈ Raising cadences might help avoid miss-detections (higher CPU usage)
- β οΈ Acceptable if other detection recipes compensate for the missed detections
π 3. Comprehensive Detectionβ
Larger correlation caches for better pattern matching.
caches:
rec-tasks: 32
tasks: 64
cmds: 32
args: 32
files: 32
dirs: 16
bases: 32
task-file: 512
file-task: 512
task-ref: 512
flows: 128
task-flow: 128
flow-task: 128
flow-ref: 128
Characteristics:
- π Bigger memory usage for specific environments
- β Allows for bigger cadences (less CPU usage) without miss-detections
- β Better historical event correlation and event context retention
- β Enhanced network flow tracking and context retention
- β Reduced chance of missed detections
- π― Recommended for big and complex workloads
π 4. Heavy I/Oβ
Maximum caches for high-volume environments.
caches:
rec-tasks: 64
tasks: 128
cmds: 64
args: 64
files: 64
dirs: 32
bases: 64
task-file: 1024
file-task: 1024
task-ref: 1024
flows: 256
task-flow: 256
flow-task: 256
flow-ref: 256
Characteristics:
- π― Too many opened files and/or sockets might face different needs
- β Bigger task and files caches for better context retention
- β Bigger network flow caches for better network context retention
π Cache Detailsβ
rec-tasksβ
Recent Tasks Cache - Stores short-term historical data about recently completed processes for temporal analysis.
tasksβ
Active Tasks Cache - Stores information about currently running OS processes observed by Jibril.
cmds / argsβ
Command & Arguments Caches - Store command lines and their arguments for running processes.
files, dirs, basesβ
File System Caches - Track accessed files, directories, and base paths.
task-file, file-taskβ
Correlation Caches - Bidirectional mapping between tasks and files they access.
flows, task-flow, flow-taskβ
Network Flow Caches - Track network connections and their relationships to processes.
π Sizing Guidelinesβ
π― How to Size Cachesβ
Consider these factors:
-
Concurrent Process Count
- Systems with many processes β increase
tasks,rec-tasks
- Systems with many processes β increase
-
File I/O Volume
- High file creation/modification rate β increase
files,task-file,file-task
- High file creation/modification rate β increase
-
Network Activity
- Many concurrent connections β increase
flows,task-flow,flow-task
- Many concurrent connections β increase
-
Available Memory
- Limited RAM β use small device profile
- Ample RAM β use heavy I/O profile
Jibril's memory consumption will be a mix of all caches plus the amount of detection recipes enabled. Start by using the default configuration and adjust based on your needs.
β οΈ When Caches Overflowβ
π¨ Symptomsβ
- Missed file access detections
- Incomplete process context (files, flows, etc.)
- Lost process correlation
- Warning messages in logs
β Solutionsβ
- Increase relevant cache sizes
- Adjust cadence intervals
- Enable only necessary detection recipes
- Monitor system activity patterns
π§ Tuning Processβ
Step-by-step approach:
- Start with defaults
Use the average configuration initially.
Enable only a few detection recipes to start with. - Monitor behavior
Check logs for cache overflow warnings.
Check CPU usage and memory consumption. - Adjust incrementally
Increase specific caches by 50-100%.
Enable more detection recipes as needed. - Test under load
Verify performance during peak activity.
Check for missed detections. - Fine-tune
Balance memory usage with detection accuracy.
β οΈ Avoidβ
- β Setting all caches to maximum
- β Using small device config on production servers
- β Ignoring cache overflow warnings
- β Changing all cache sizes simultaneously
- β Forgetting to test after changes
- β Over-provisioning without monitoring
π Memory Impact Referenceβ
Approximate memory usage per cache profile:
| Profile | Memory Usage | Use Case |
|---|---|---|
| Small Devices | From 50 to 250 MB | IoT, embedded, edge devices |
| Default (Balanced) | From 256 to 1024 MB | Standard servers, VMs, containers |
| Comprehensive Detection | From 512 to 2048 MB | Production security monitoring |
| Heavy I/O | From 1024 to 4096 MB | Databases, file servers, critical infrastructure |
Note: Total Jibril memory usage includes eBPF maps, detection logic, and other overhead. Cache sizes are just one component of the whole equation.