-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(Unneeded?) Memory bloat in fair::mq::shmem::Message #477
Comments
The struct Message
{
Manager& fManager; // local ptr to the manager
bool fQueued; // is the message queued? (can the buffer removed when dtor is called).
MetaHeader fMeta; // contains all the "transferrable" info
size_t fAlignment;
mutable UnmanagedRegion* fRegionPtr; // used in case of unmanaged region messages
mutable char* fLocalPtr; // local data ptr, for received messages obtained from the handle
}
struct MetaHeader
{
size_t fSize;
size_t fHint; // this is used for unmanaged region messages to store user provided info, which is returned when message can be freed. Afaik this is used at least by FLP/readout.
boost::interprocess::managed_shared_memory::handle_t fHandle; // interprocess handle, convertable to local ptr
mutable boost::interprocess::managed_shared_memory::handle_t fShared; // used for the ref count when msg is shared
uint16_t fRegionId; // unmanaged region id
mutable uint16_t fSegmentId; // segment id
bool fManaged; // managed/unmanaged
}; Both should be minimal size, but I would say having the
Logically it belongs to local data, not shared data. For this and similar suggestions one could think to create the final MetaData header only immediately before transfer, then there would be more freedom to resize
Sounds good!
Would 48 be enough for current and future use cases? Hint is 64 bits as per requirement from FLP/readout.
Which handles do you mean? ptrs and boost interproccess handles are both 64, as they are supposed to be convertible into each other. |
Ok, I understand the difference now. What you propose indeed makes sense to me.
Indeed, if you do that, than it's enough to have fQueued shuffled after fAlignment.
As far as I know, there is no x86 hardware which supports more than 48 bits of virtual address space. Maybe this should be architecture dependent? However Sylvain should probably comment here.
What I mean is that right now you have:
However you could, for example, decide that regions are known to a given Manager (i.e. the latter keeps a list of them) and change |
So how do we proceed here? Do you plan to attack this any time soon? |
I will likely come to this sometime in September. |
Ok, thank you! |
The need to store the alignment value is for use in Message::SetUsedSize, which may need it in an edge-case. Instead of storing it with each message, we could also accept it as a parameter to SetUsedSize. What do you think? |
Sounds reasonable to me. Indeed I could not find any invocation of SetUsedSize in the framework and only one in the old TOFCompressor, which indeed is known in advance so its not needed in any case. Maybe you could determine minimum alignment from the current pointer (and cap it to, say, page boundaries). |
basically:
|
Sounds good, then that could be done when no alignment is provided to SetUsedSize. That way no need to break the interface, alignment argument to SetUsedSize will be optional. Then I would do this and not store alignment in shmem::Message at all. |
Fully support this. |
The current state in the dev branch is:
Manager& fManager;
mutable UnmanagedRegion* fRegionPtr = nullptr;
mutable char* fLocalPtr = nullptr;
size_t fSize = 0;
size_t fHint = 0;
boost::interprocess::managed_shared_memory::handle_t fHandle = -1;
mutable boost::interprocess::managed_shared_memory::handle_t fShared = -1;
uint16_t fRegionId = 0;
mutable uint16_t fSegmentId;
bool fManaged = true;
bool fQueued = false; This (plus the |
While doing some profiling I just noticed that the fair::mq::shmem::Message has a fQueued boolean in the middle of it, introducing some unneeded extra padding. If I naively move it to the MetaHeader class, I immediately go from 96 bytes to 88.
I also suspect one could gain quite some extra memory with a few extra reasonable limitations. For example:
All in all, I think one could get down below 64 bytes by having something like the following:
and it could probably be even less if one used handles for fManager and the the other pointers. Do you think there is any space to evolve the managed region to go into this direction?
The text was updated successfully, but these errors were encountered: