packagefs: Use ClassCache for UnpackingDirectory and UnpackingLeafNode.
This shifts another big chunk of packagefs memory usage into dedicated object caches. It saves a small amount of memory since now we use caches sized exactly to the object size plus alignment rather than rounding up to the block allocator size, and also makes clearer in memory usage statistics how much memory packagefs is using.
This commit is contained in:
@@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
#include "UnpackingDirectory.h"
|
#include "UnpackingDirectory.h"
|
||||||
|
|
||||||
|
#include "ClassCache.h"
|
||||||
#include "DebugSupport.h"
|
#include "DebugSupport.h"
|
||||||
#include "EmptyAttributeDirectoryCookie.h"
|
#include "EmptyAttributeDirectoryCookie.h"
|
||||||
#include "UnpackingAttributeCookie.h"
|
#include "UnpackingAttributeCookie.h"
|
||||||
@@ -16,6 +17,9 @@
|
|||||||
// #pragma mark - UnpackingDirectory
|
// #pragma mark - UnpackingDirectory
|
||||||
|
|
||||||
|
|
||||||
|
CLASS_CACHE(UnpackingDirectory);
|
||||||
|
|
||||||
|
|
||||||
UnpackingDirectory::UnpackingDirectory(ino_t id)
|
UnpackingDirectory::UnpackingDirectory(ino_t id)
|
||||||
:
|
:
|
||||||
Directory(id)
|
Directory(id)
|
||||||
@@ -225,6 +229,20 @@ UnpackingDirectory::IndexCookieForAttribute(const StringKey& name) const
|
|||||||
// #pragma mark - RootDirectory
|
// #pragma mark - RootDirectory
|
||||||
|
|
||||||
|
|
||||||
|
void*
|
||||||
|
RootDirectory::operator new(size_t size)
|
||||||
|
{
|
||||||
|
return malloc(size);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
RootDirectory::operator delete(void* object)
|
||||||
|
{
|
||||||
|
free(object);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
RootDirectory::RootDirectory(ino_t id, const timespec& modifiedTime)
|
RootDirectory::RootDirectory(ino_t id, const timespec& modifiedTime)
|
||||||
:
|
:
|
||||||
UnpackingDirectory(id),
|
UnpackingDirectory(id),
|
||||||
|
|||||||
@@ -13,6 +13,9 @@
|
|||||||
|
|
||||||
class UnpackingDirectory : public Directory, public UnpackingNode {
|
class UnpackingDirectory : public Directory, public UnpackingNode {
|
||||||
public:
|
public:
|
||||||
|
static void* operator new(size_t size);
|
||||||
|
static void operator delete(void* block);
|
||||||
|
|
||||||
UnpackingDirectory(ino_t id);
|
UnpackingDirectory(ino_t id);
|
||||||
virtual ~UnpackingDirectory();
|
virtual ~UnpackingDirectory();
|
||||||
|
|
||||||
@@ -55,6 +58,9 @@ private:
|
|||||||
|
|
||||||
class RootDirectory : public UnpackingDirectory {
|
class RootDirectory : public UnpackingDirectory {
|
||||||
public:
|
public:
|
||||||
|
static void* operator new(size_t size);
|
||||||
|
static void operator delete(void* block);
|
||||||
|
|
||||||
RootDirectory(ino_t id,
|
RootDirectory(ino_t id,
|
||||||
const timespec& modifiedTime);
|
const timespec& modifiedTime);
|
||||||
|
|
||||||
|
|||||||
@@ -11,11 +11,15 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <new>
|
#include <new>
|
||||||
|
|
||||||
|
#include "ClassCache.h"
|
||||||
#include "UnpackingAttributeCookie.h"
|
#include "UnpackingAttributeCookie.h"
|
||||||
#include "UnpackingAttributeDirectoryCookie.h"
|
#include "UnpackingAttributeDirectoryCookie.h"
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
|
|
||||||
|
|
||||||
|
CLASS_CACHE(UnpackingLeafNode);
|
||||||
|
|
||||||
|
|
||||||
UnpackingLeafNode::UnpackingLeafNode(ino_t id)
|
UnpackingLeafNode::UnpackingLeafNode(ino_t id)
|
||||||
:
|
:
|
||||||
Node(id),
|
Node(id),
|
||||||
@@ -212,7 +216,7 @@ UnpackingLeafNode::CloneTransferPackageNodes(ino_t id, UnpackingNode*& _newNode)
|
|||||||
{
|
{
|
||||||
ASSERT(fFinalPackageNode == NULL);
|
ASSERT(fFinalPackageNode == NULL);
|
||||||
|
|
||||||
UnpackingLeafNode* clone = new(std::nothrow) UnpackingLeafNode(id);
|
UnpackingLeafNode* clone = new UnpackingLeafNode(id);
|
||||||
if (clone == NULL)
|
if (clone == NULL)
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
|
|
||||||
|
|||||||
@@ -11,8 +11,11 @@
|
|||||||
#include "UnpackingNode.h"
|
#include "UnpackingNode.h"
|
||||||
|
|
||||||
|
|
||||||
class UnpackingLeafNode : public Node, public UnpackingNode {
|
class UnpackingLeafNode final : public Node, public UnpackingNode {
|
||||||
public:
|
public:
|
||||||
|
static void* operator new(size_t size);
|
||||||
|
static void operator delete(void* block);
|
||||||
|
|
||||||
UnpackingLeafNode(ino_t id);
|
UnpackingLeafNode(ino_t id);
|
||||||
virtual ~UnpackingLeafNode();
|
virtual ~UnpackingLeafNode();
|
||||||
|
|
||||||
|
|||||||
@@ -399,7 +399,7 @@ Volume::Mount(const char* parameterString)
|
|||||||
|
|
||||||
// create the root node
|
// create the root node
|
||||||
fRootDirectory
|
fRootDirectory
|
||||||
= new(std::nothrow) ::RootDirectory(kRootDirectoryID, st.st_mtim);
|
= new ::RootDirectory(kRootDirectoryID, st.st_mtim);
|
||||||
if (fRootDirectory == NULL)
|
if (fRootDirectory == NULL)
|
||||||
RETURN_ERROR(B_NO_MEMORY);
|
RETURN_ERROR(B_NO_MEMORY);
|
||||||
fRootDirectory->Init(NULL, volumeNameString);
|
fRootDirectory->Init(NULL, volumeNameString);
|
||||||
@@ -1394,9 +1394,9 @@ Volume::_CreateUnpackingNode(mode_t mode, Directory* parent, const String& name,
|
|||||||
{
|
{
|
||||||
UnpackingNode* unpackingNode;
|
UnpackingNode* unpackingNode;
|
||||||
if (S_ISREG(mode) || S_ISLNK(mode))
|
if (S_ISREG(mode) || S_ISLNK(mode))
|
||||||
unpackingNode = new(std::nothrow) UnpackingLeafNode(fNextNodeID++);
|
unpackingNode = new UnpackingLeafNode(fNextNodeID++);
|
||||||
else if (S_ISDIR(mode))
|
else if (S_ISDIR(mode))
|
||||||
unpackingNode = new(std::nothrow) UnpackingDirectory(fNextNodeID++);
|
unpackingNode = new UnpackingDirectory(fNextNodeID++);
|
||||||
else
|
else
|
||||||
RETURN_ERROR(B_UNSUPPORTED);
|
RETURN_ERROR(B_UNSUPPORTED);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user