speed improvements
save file messages (not working, but thats bc of other parts)
This commit is contained in:
parent
c42c446446
commit
a4092298fb
@ -39,9 +39,9 @@ int main(int argc, const char** argv) {
|
|||||||
RegistryMessageModelImpl rmm(cr); // dummy
|
RegistryMessageModelImpl rmm(cr); // dummy
|
||||||
// they only exist for the serializers (for now)
|
// they only exist for the serializers (for now)
|
||||||
// TODO: version
|
// TODO: version
|
||||||
MessageSerializerNJ msnj_src{cr, {}, {}};
|
MessageSerializerNJ msnj_src{cr, os_src, {}, {}};
|
||||||
MessageFragmentStore mfs_src(cr, rmm, os_src, fsb_src, msnj_src);
|
MessageFragmentStore mfs_src(cr, rmm, os_src, fsb_src, msnj_src);
|
||||||
MessageSerializerNJ msnj_dst{cr, {}, {}};
|
MessageSerializerNJ msnj_dst{cr, os_dst, {}, {}};
|
||||||
MessageFragmentStore mfs_dst(cr, rmm, os_dst, fsb_dst, msnj_dst);
|
MessageFragmentStore mfs_dst(cr, rmm, os_dst, fsb_dst, msnj_dst);
|
||||||
|
|
||||||
// add message fragment store too (adds meta?)
|
// add message fragment store too (adds meta?)
|
||||||
|
@ -88,12 +88,13 @@ void MessageFragmentStore::handleMessage(const Message3Handle& m) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: this is bad, we need a non persistence tag instead
|
// TODO: this is bad, we need a non persistence tag instead
|
||||||
if (!m.any_of<Message::Components::MessageText>()) {
|
if (!m.any_of<Message::Components::MessageText, Message::Components::MessageFileObject>()) {
|
||||||
// skip everything else for now
|
// skip everything else for now
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// TODO: check if file object has id
|
||||||
|
|
||||||
// TODO: use fid, seving full fuid for every message consumes alot of memory (and heap frag)
|
// TODO: use fid, saving full fuid for every message consumes alot of memory (and heap frag)
|
||||||
if (!m.all_of<Message::Components::MFSObj>()) {
|
if (!m.all_of<Message::Components::MFSObj>()) {
|
||||||
std::cout << "MFS: new msg missing Object\n";
|
std::cout << "MFS: new msg missing Object\n";
|
||||||
if (!m.registry()->ctx().contains<Message::Contexts::OpenFragments>()) {
|
if (!m.registry()->ctx().contains<Message::Contexts::OpenFragments>()) {
|
||||||
@ -235,6 +236,7 @@ void MessageFragmentStore::handleMessage(const Message3Handle& m) {
|
|||||||
m.emplace_or_replace<Message::Components::MFSObj>(fragment_id);
|
m.emplace_or_replace<Message::Components::MFSObj>(fragment_id);
|
||||||
|
|
||||||
// in this case we know the fragment needs an update
|
// in this case we know the fragment needs an update
|
||||||
|
// TODO: refactor extract
|
||||||
for (const auto& it : _frag_save_queue) {
|
for (const auto& it : _frag_save_queue) {
|
||||||
if (it.id == fragment_id) {
|
if (it.id == fragment_id) {
|
||||||
// already in queue
|
// already in queue
|
||||||
@ -258,8 +260,14 @@ void MessageFragmentStore::handleMessage(const Message3Handle& m) {
|
|||||||
auto& fid_open = m.registry()->ctx().get<Message::Contexts::OpenFragments>().open_frags;
|
auto& fid_open = m.registry()->ctx().get<Message::Contexts::OpenFragments>().open_frags;
|
||||||
|
|
||||||
if (fid_open.contains(msg_fh)) {
|
if (fid_open.contains(msg_fh)) {
|
||||||
// TODO: dedup events
|
|
||||||
// TODO: cooldown per fragsave
|
// TODO: cooldown per fragsave
|
||||||
|
// TODO: refactor extract
|
||||||
|
for (const auto& it : _frag_save_queue) {
|
||||||
|
if (it.id == msg_fh) {
|
||||||
|
// already in queue
|
||||||
|
return; // done
|
||||||
|
}
|
||||||
|
}
|
||||||
_frag_save_queue.push_back({Message::getTimeMS(), msg_fh, m.registry()});
|
_frag_save_queue.push_back({Message::getTimeMS(), msg_fh, m.registry()});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -275,6 +283,12 @@ void MessageFragmentStore::handleMessage(const Message3Handle& m) {
|
|||||||
// assumes not loaded frag
|
// assumes not loaded frag
|
||||||
// need update from frag
|
// need update from frag
|
||||||
void MessageFragmentStore::loadFragment(Message3Registry& reg, ObjectHandle fh) {
|
void MessageFragmentStore::loadFragment(Message3Registry& reg, ObjectHandle fh) {
|
||||||
|
if (!fh) {
|
||||||
|
std::cerr << "MFS error: loadFragment called with invalid object!!!\n";
|
||||||
|
assert(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
std::cout << "MFS: loadFragment\n";
|
std::cout << "MFS: loadFragment\n";
|
||||||
// version HAS to be set, or we just fail
|
// version HAS to be set, or we just fail
|
||||||
if (!fh.all_of<ObjComp::MessagesVersion>()) {
|
if (!fh.all_of<ObjComp::MessagesVersion>()) {
|
||||||
@ -407,11 +421,12 @@ bool MessageFragmentStore::syncFragToStorage(ObjectHandle fh, Message3Registry&
|
|||||||
|
|
||||||
// filter: require msg for now
|
// filter: require msg for now
|
||||||
// this will be removed in the future
|
// this will be removed in the future
|
||||||
if (!reg.any_of<Message::Components::MessageText/*, Message::Components::Transfer::FileInfo*/>(m)) {
|
//if (!reg.any_of<Message::Components::MessageText>(m)) {
|
||||||
|
if (!reg.any_of<Message::Components::MessageText, Message::Components::MessageFileObject>(m)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_frag_save_queue.front().id != reg.get<Message::Components::MFSObj>(m).o) {
|
if (fh != reg.get<Message::Components::MFSObj>(m).o) {
|
||||||
continue; // not ours
|
continue; // not ours
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -518,7 +533,9 @@ MessageFragmentStore::~MessageFragmentStore(void) {
|
|||||||
auto fh = _frag_save_queue.front().id;
|
auto fh = _frag_save_queue.front().id;
|
||||||
auto* reg = _frag_save_queue.front().reg;
|
auto* reg = _frag_save_queue.front().reg;
|
||||||
assert(reg != nullptr);
|
assert(reg != nullptr);
|
||||||
|
_fs_ignore_event = true;
|
||||||
syncFragToStorage(fh, *reg);
|
syncFragToStorage(fh, *reg);
|
||||||
|
_fs_ignore_event = false;
|
||||||
_frag_save_queue.pop_front(); // pop unconditionally
|
_frag_save_queue.pop_front(); // pop unconditionally
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -586,7 +603,7 @@ float MessageFragmentStore::tick(float) {
|
|||||||
// only checks if it collides with ranges, not adjacent
|
// only checks if it collides with ranges, not adjacent
|
||||||
// bc ~range~ msgreg will be marked dirty and checked next tick
|
// bc ~range~ msgreg will be marked dirty and checked next tick
|
||||||
const bool had_events = !_event_check_queue.empty();
|
const bool had_events = !_event_check_queue.empty();
|
||||||
for (size_t i = 0; i < 10 && !_event_check_queue.empty(); i++) {
|
for (size_t i = 0; i < 50 && !_event_check_queue.empty(); i++) {
|
||||||
//std::cout << "MFS: event check\n";
|
//std::cout << "MFS: event check\n";
|
||||||
auto fh = _event_check_queue.front().fid;
|
auto fh = _event_check_queue.front().fid;
|
||||||
auto c = _event_check_queue.front().c;
|
auto c = _event_check_queue.front().c;
|
||||||
|
Loading…
Reference in New Issue
Block a user