pmem / CacheLib

Pluggable in-process caching engine to build and scale high performance services
https://www.cachelib.org
Apache License 2.0
5 stars 13 forks source link

[Upstream] Create initial mmap PR based on Meta's guidelines (not ready for review yet) #99

Closed guptask closed 1 year ago

guptask commented 2 years ago

Instruction from Meta for first PR:

  1. Create a class containing Id and Type of a segment called ShmTypeOpts. The type is an enum. The ID is a string. Put ShmTypeOpts into ShmSegmentOpts.
  2. ShmBase is initialized solely with ShmSegmentOpts since name_ can now be initialized with the ID in ShmSegmentOpts.ShmTypeOpts.
  3. Posix/SysVShmSegment class (subclasses of ShmBase) will be new-ed/attached without an extra name input.
  4. ShmSegment class (the class that wraps a ShmBase) will be new-ed/attached without name or usePosix because that can be retrieved with ShmSegmentOpts.ShmTypeOpts).
  5. In ShmManager, we keep a map from name to ShmTypeOpts called nameToType (replacing nameToKey, but we will need to keep nameToKey_ for compatibility reason).
  6. When creating a new segment via ShmManager, we expect a name and ShmTypeOpts to be provided. If the type indicates SysV or Posix, we ignore the id field in ShmTypeOpts and fill the id field with uniqueIdForName. We use this ShmTypeOpts to create the segment then save the segment into segments and save the ShmTypeOpts to nameToType.
  7. When attaching/removing a segment via ShmManager, we expect only the name provided. ShmManager looks up the segment and the ShmTypeOpts from nameToType_ and try to attach/remove with the ShmTypeOpts retrieved.
  8. When removing a segment via the static function of ShmManager, we expect ShmTypeOpts to be provided directly.
  9. After the first diff, the usePosix field inside ShmManager will be noop since each segment know what type they are from nameToType.

This change is Reviewable