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

SQLiteTrie: use pygtrie for in memory traversal #21

Closed
wants to merge 2 commits into from

Conversation

pmrowla
Copy link
Contributor

@pmrowla pmrowla commented Nov 21, 2023

Should fix iterative/dvc#9914

After looking at this some more we can just simplify it to use an in-memory trie specifically for traversal, and leave everything else as-is (so all other view operations still reflect the live db)

DVC main with this PR

+ dvc push
24972 files pushed

real    0m7.030s
user    0m2.331s
sys     0m3.188s

+ dvc pull
A       cats_dogs/
1 file added and 24972 files fetched

real    0m15.335s
user    0m4.940s
sys     0m6.977s

DVC main without PR:

+ dvc push
24972 files pushed

real    0m6.914s
user    0m2.330s
sys     0m3.151s

+ dvc pull
A       cats_dogs/
1 file added and 24972 files fetched

real    1m46.046s
user    1m24.086s
sys     0m18.272s

DVC 3.10

+ dvc push
24972 files pushed

real    0m6.164s
user    0m1.616s
sys     0m2.998s

+ dvc pull
A       cats_dogs/
1 file added and 24972 files fetched

real    0m15.515s
user    0m5.079s
sys     0m7.013s

@pmrowla pmrowla self-assigned this Nov 21, 2023
@codecov-commenter
Copy link

codecov-commenter commented Nov 21, 2023

Codecov Report

Attention: 6 lines in your changes are missing coverage. Please review.

Comparison is base (f98617a) 79.50% compared to head (0dd6496) 79.80%.

Files Patch % Lines
src/sqltrie/sqlite/sqlite.py 20.00% 4 Missing ⚠️
src/sqltrie/serialized.py 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #21      +/-   ##
==========================================
+ Coverage   79.50%   79.80%   +0.29%     
==========================================
  Files          11       11              
  Lines         605      604       -1     
  Branches      106      105       -1     
==========================================
+ Hits          481      482       +1     
+ Misses        112      110       -2     
  Partials       12       12              

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

Comment on lines +91 to +94
def _node_factory_wrapper(path_conv, path, children, *value):
return node_factory(
path_conv, path, children, self._load(path, value[0] if value else None)
)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

node factory value is defined as an optional positional arg in pygtrie (since there is a difference between a node having no value set and a node value being set to None)

@pmrowla pmrowla requested a review from efiop November 21, 2023 12:16
@pmrowla
Copy link
Contributor Author

pmrowla commented Nov 21, 2023

dvc-data and dvc tests pass with this PR

Comment on lines +318 to +320
trie = PyGTrie()
for key, value in self.items():
trie[key] = value
Copy link
Contributor

@efiop efiop Nov 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this requires reading the whole trie into memory, right? That should become a problem at some size and kinda defeats the purpose a little bit it seems like. Also reading so much will likely become a problem on slower filesystems. Again, kinda defeats the general purpose of sqltrie.

After researching, what do you think about sql-based view as discussed in the previous PR? Just trying to understand if that would be the long term solution.

This was referenced Nov 21, 2023
@pmrowla
Copy link
Contributor Author

pmrowla commented Nov 23, 2023

closing in favor of #24

@pmrowla pmrowla closed this Nov 23, 2023
@pmrowla pmrowla deleted the pygtrie-traverse branch November 23, 2023 09:40
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.

benchmark regressions
3 participants