Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add caching to Secure lookup #35

Merged
merged 3 commits into from
Jul 5, 2024
Merged

Add caching to Secure lookup #35

merged 3 commits into from
Jul 5, 2024

Conversation

OlafHaalstra
Copy link
Contributor

After having profiled the MFT code it became apparent that the secure.lookup inside get_owner_and_group is the culprit. See image below.

I have compared the following situations:

  • Original
  • Removing the get_owner_and_group call
  • Adding lru_cache to self.lookup
    Which yields the following results:
Situation Parsing 100.000 records Parsing 9.206.590 records
Original 1m33s 57m51s
Removed 25s N/A
Cached 24s 13m27s

Here we can see an improvement of 430% by adding caching.

Steps to create the image:

python -m cProfile -o profile.pstats -m dissect.target.tools.query -t ~/Documents/research/dissect/Collection/ -f mft --limit 100000 | rdump -w test.json
gprof2dot -f pstats profile.pstats | dot -Tpng -o image.out

image

dissect/ntfs/secure.py Outdated Show resolved Hide resolved
@OlafHaalstra
Copy link
Contributor Author

For completeness here is the profile after making the change. Looks like get_owner_and_group still hoards up 41% of the compute time so it's probably very much possible to further improve this.

image4

@Schamper
Copy link
Member

Schamper commented Jul 5, 2024

By the way, I thought about this and I think if Acquire/Velo would collect the $SII, this issue wouldn't have been as big. Because without it, we have to fallback to a "bruteforce" approach for finding the correct entry.

Created a ticket for Acquire: fox-it/acquire#180

Copy link

codecov bot commented Jul 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.45%. Comparing base (2765041) to head (321a8ff).

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #35      +/-   ##
==========================================
+ Coverage   87.43%   87.45%   +0.02%     
==========================================
  Files          11       11              
  Lines        1234     1236       +2     
==========================================
+ Hits         1079     1081       +2     
  Misses        155      155              
Flag Coverage Δ
unittests 87.45% <100.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

dissect/ntfs/secure.py Outdated Show resolved Hide resolved
dissect/ntfs/secure.py Outdated Show resolved Hide resolved
@Schamper Schamper merged commit 14781ef into fox-it:main Jul 5, 2024
17 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants