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

Lazy minhash implementation for scalability. #653

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

ibenian
Copy link

@ibenian ibenian commented Feb 25, 2018

This is an incremental fix to solve the scalability problem in MinHasher. Current minhasher allocates hash buffer for every element in the init() method only to use it in the plus() method before throwing it away. This should be fine for small number of hashes and relatively small number of items, but causes GC and heap errors when scaled. I've encountered the problem when testing with 25K hashes on several million items. The problem continued when I tried to run it on a much larger dataset on our hadoop cluster using Scalding.
This pull request includes a new LazyMinHasher which just holds the values until aggregation time without doing any buffer allocation. It does buffer allocation in plus() method and then immediately throws it out. Because short lived objects are more easily garbage collected, the burden on GC is significantly lower. Also, because there is only two hash buffers kept in the memory at a given time rather than first allocating all of them, the memory footprint is much lower.
To reproduce the problem, increase the test sample size to ~1M in MinHasherTest.scala, and the new numBands val to ~25K. This should break the MinHasher32 test while LazyMinHasher still passes.

@CLAassistant
Copy link

CLAassistant commented Feb 25, 2018

CLA assistant check
All committers have signed the CLA.

@codecov-io
Copy link

Codecov Report

Merging #653 into develop will decrease coverage by 0.23%.
The diff coverage is 54.54%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #653      +/-   ##
===========================================
- Coverage    83.14%   82.91%   -0.24%     
===========================================
  Files          109      110       +1     
  Lines         5222     5233      +11     
  Branches       317      322       +5     
===========================================
- Hits          4342     4339       -3     
- Misses         880      894      +14
Impacted Files Coverage Δ
...ain/scala/com/twitter/algebird/LazyMinHasher.scala 54.54% <54.54%> (ø)
...in/scala/com/twitter/algebird/scalacheck/Gen.scala 91.66% <0%> (-8.34%) ⬇️
...src/main/scala/com/twitter/algebird/Interval.scala 77.39% <0%> (-6.96%) ⬇️
...om/twitter/algebird/util/summer/AsyncListSum.scala 95.45% <0%> (-2.28%) ⬇️
.../main/scala/com/twitter/algebird/BloomFilter.scala 95.27% <0%> (ø) ⬆️
...c/main/scala/com/twitter/algebird/MapAlgebra.scala 77.88% <0%> (+0.96%) ⬆️
.../main/scala/com/twitter/algebird/JavaMonoids.scala 64.51% <0%> (+1.61%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 52e53d2...17054df. Read the comment docs.

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.

3 participants