-
Type: Improvement
-
Resolution: Unresolved
-
Priority: Unknown
-
None
-
Affects Version/s: None
-
Component/s: BSON
-
None
Go BSON encoders/decoders currently use a "registry" to look up codecs for specific Go types, which uses a sync.Map to find the correct codec. However, that creates possible locking contention between goroutines, requires reflection calls, and uses a relatively slow map lookup compared to a simple type switch. The sync.Map lookup is only necessary when a customer overrides the default registry, which few customers do. Instead, it would be better to use a type switch for common Go types, only falling back to a sync.Map for custom registries or user-defined types.
See ReflectionFreeDCodec type that was originally developed to significantly improve BSON encode/decode performance, specifically for the bson.D type.
Definition of done:
- Use a type switch to look up BSON codecs for common Go types when the user has not provided a custom registry.
- depends on
-
GODRIVER-2973 Implement Go Driver 2.0: BSON Library
- Development Complete