Conversation
Previously we passed the type in via a generic parameter. Passing it in as a struct allows us to build the reflect type and cache it outside of the containsNoPointer() function. The store itself will cache the results to this function call to avoid calling it every time we allocate a type.
Previously every allocation would perform a check on whether the allocation type contains pointers. This work is very slow and allocates a remarkable amount of memory. We introduce a cache which simply stores types which have been successfully checked previously. This cache is protected by a read/write lock - which does put another lock on the allocation path.
e275904 to
3e4e1e5
Compare
This struct is responsible for checking whether types contain pointers. It caches acceptable types to avoid repeated, expensive, type checks.
There is only one file which contains all of the type checking code in it. We also add tests which directly test the pointerCheck type as well as the containsNoPointers() function. We preserve the lower level function tests because they are able to verify that the exact type failures we expect are being found, and described in the error text.
3e4e1e5 to
ff40120
Compare
This file contains hidden or 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
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.
No description provided.