KPath: Use an object_cache for the path buffers in the normal case.

This was (following the packagefs changes) the number-one (by call
count) consumer of malloc() during the boot -- 52866 calls, and 100%
of them either 1024 or 1025 bytes!

Virtually all of these are ephemeral (indeed, the object_cache
stats after a boot with this patch shows there is only a single slab
of 64 buffers allocated, and most of them unused), so this is
probably a significant performance boost.

Change-Id: I659f5707510cbfeafa735d35eea7b92732ead666
This commit is contained in:
Augustin Cavalier
2019-07-11 22:52:10 -04:00
parent 9b72c3a089
commit 42e3c6f978
4 changed files with 100 additions and 60 deletions
+4 -3
View File
@@ -23,14 +23,14 @@ public:
LAZY_ALLOC = 0x04
};
public:
KPath(size_t bufferSize = B_PATH_NAME_LENGTH);
KPath(size_t bufferSize = B_PATH_NAME_LENGTH + 1);
KPath(const char* path, int32 flags = DEFAULT,
size_t bufferSize = B_PATH_NAME_LENGTH);
size_t bufferSize = B_PATH_NAME_LENGTH + 1);
KPath(const KPath& other);
~KPath();
status_t SetTo(const char* path, int32 flags = DEFAULT,
size_t bufferSize = B_PATH_NAME_LENGTH);
size_t bufferSize = B_PATH_NAME_LENGTH + 1);
void Adopt(KPath& other);
status_t InitCheck() const;
@@ -67,6 +67,7 @@ public:
private:
status_t _AllocateBuffer();
void _FreeBuffer();
status_t _Normalize(const char* path,
bool traverseLeafLink);
void _ChopTrailingSlashes();