-
Type: Improvement
-
Resolution: Fixed
-
Priority: Unknown
-
Affects Version/s: None
-
Component/s: None
Use Case
When ObjectId.cacheHexString is enabled there is a performance impact on ObjectId creation and the extra memory used by the hex string is consumed even if .toHexString is never called on the ObjectId.
By lazily caching the hex string it provides the following benefits:
- No performance impact on ObjectId creation
- Memory use does not increase unless string is requested
- Duplicate .toHexString calls are still efficient as cache is used
Possible Negatives:
- hex string performance impact is moved to first .toHexString() invocation. Overall performance is still consistent, but it is not front loaded on ObjectId creation.
I will submit a PR to address this issue.
- is related to
-
NODE-6480 Lazily cache ObjectId hex string
- Backlog