Summary:
Useful in some places for object uniqueness across processes.
Currently used for generating a host-wide identifier of Cache objects
but expected to be used soon in some unique id generation code.
`int64_t` is chosen for return type because POSIX uses signed integer type,
usually `int`, for `pid_t` and Windows uses `DWORD`, which is `uint32_t`.
Future work: avoid copy-pasted declarations in port_*.h, perhaps with
port_common.h always included from port.h
Pull Request resolved: https://github.com/facebook/rocksdb/pull/8693
Test Plan: manual for now
Reviewed By: ajkr, anand1976
Differential Revision:
D30492876
Pulled By: pdillinger
fbshipit-source-id:
39fc2788623cc9f4787866bdb67a4d183dde7eef
#include "cache/cache_entry_stats.h"
#include "db/column_family.h"
#include "db/db_impl/db_impl.h"
+#include "port/port.h"
#include "rocksdb/system_clock.h"
#include "rocksdb/table.h"
#include "table/block_based/cachable_entry.h"
++collection_count;
role_map_ = CopyCacheDeleterRoleMap();
std::ostringstream str;
- str << cache->Name() << "@" << static_cast<void*>(cache);
+ str << cache->Name() << "@" << static_cast<void*>(cache) << "#"
+ << port::GetProcessID();
cache_id = str.str();
cache_capacity = cache->GetCapacity();
}
#endif
}
+int64_t GetProcessID() { return getpid(); }
+
} // namespace port
} // namespace ROCKSDB_NAMESPACE
extern void SetCpuPriority(ThreadId id, CpuPriority priority);
+int64_t GetProcessID();
+
} // namespace port
} // namespace ROCKSDB_NAMESPACE
(void)priority;
}
+int64_t GetProcessID() { return GetCurrentProcessId(); }
+
} // namespace port
} // namespace ROCKSDB_NAMESPACE
extern void SetCpuPriority(ThreadId id, CpuPriority priority);
+int64_t GetProcessID();
+
} // namespace port