-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
💫 Fix streaming data memory growth (!!) #1424
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
honnibal
changed the title
Fix streaming data memory growth (!!)
💫 Fix streaming data memory growth (!!)
Oct 16, 2017
ines
added
bug
Bugs and behaviour differing from documentation
🌙 nightly
Discussion and contributions related to nightly builds
labels
Oct 16, 2017
This was referenced Oct 16, 2017
Hey, thanks for fixing this. Is this going to be backported into v1 though? |
3 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This patch follows through on the changes to the StringStore introduced in v2, and fixes by far the longest open bug: #285 Streaming Data Memory Growth
The solution implemented allows a weakref to be created on
Doc
objects, so that we can figure out when it's safe to flush out old strings. A rolling buffer is created using two StringStore objects. One StringStore contains the set of original strings and strings from recent documents. The other string store is the one current on the Vocab object. The only difference between the twoStringStore
objects are in strings created by increasingly old documents. Once we figure out that all of those old documents have passed out of scope and been reference counted, we figure it's safe to flush the obsolete strings.This logic is only applied in the
Language.pipe()
method, and requires no API changes. However, it does require breaking the former 2-cycle between theDoc
andToken
objects, that had been created by caching theToken
instances within theDoc
. I think breaking this cycle is a Good Thing, independent of theStringStore
changes. We don't need to cache those objects --- almost nothing is done inToken.__init__
, so there should be no problem with recreating the object. If we like, we could use a weakref onToken
, but it's simpler to just not cache.The resolution was checked with this script, to verify the string store does not grow as data streams through:
Checklist: