Skip to content

Conversation

@juanmrad
Copy link
Collaborator

Summary

This is a DRAFT PR to show memory profiling changes for HMA. it is not intended to be merged.

Test Plan

add the env settings:

# Enable memory monitoring
ENABLE_MEMORY_MONITORING = True

# How often to log memory info (in seconds)
MEMORY_LOG_INTERVAL_SECONDS = 300

Sample Log Output

[2025-10-10 12:30:00] INFO in memory_utils: [Request Start] Memory: Process RSS=1024.5MB VMS=2048.3MB (12.5% of system) | System: Used=4096.2MB Available=2048.8MB Total=8192.0MB (50.0% used)

[2025-10-10 12:30:05] INFO in build_index: 
        === Memory Snapshot: Starting index build for pdq ===
        Process Memory: 1024.50 MB
        System Memory: 4096.20 MB
        FAISS Memory: 1024.50 MB
        Top Objects:
            None
        Top Memory Allocations:
            None
        ============================

[2025-10-10 12:35:00] INFO in matching: [IndexSwap[pdq] - Before] Memory: Process RSS=2048.7MB VMS=4096.5MB (25.0% of system) | System: Used=5120.3MB Available=1536.7MB Total=8192.0MB (62.5% used)

[2025-10-10 12:35:05] INFO in matching: [IndexSwap[pdq] - During (both in memory)] Memory: Process RSS=3072.9MB VMS=6144.8MB (37.5% of system) | System: Used=6144.5MB Available=512.5MB Total=8192.0MB (75.0% used)

[2025-10-10 12:35:10] INFO in memory_utils: [IndexSwap[pdq] (before trim)] Memory: Process RSS=3072.9MB VMS=6144.8MB (37.5% of system) | System: Used=6144.5MB Available=512.5MB Total=8192.0MB (75.0% used)

[2025-10-10 12:35:15] INFO in memory_utils: [IndexSwap[pdq]] Called malloc_trim(0) to release freed memory

[2025-10-10 12:35:20] INFO in memory_utils: [IndexSwap[pdq] (after trim)] Memory: Process RSS=1536.4MB VMS=4096.2MB (18.8% of system) | System: Used=4608.6MB Available=2048.4MB Total=8192.0MB (56.3% used)

@meta-cla meta-cla bot added the CLA Signed label Oct 10, 2025
@github-actions github-actions bot added the hma Items related to the hasher-matcher-actioner system label Oct 10, 2025
@juanmrad juanmrad force-pushed the omm/juanmrad/sample-memory-profiling branch from 5d32820 to 64ff32d Compare October 22, 2025 00:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed hma Items related to the hasher-matcher-actioner system

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant