Skip to content
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

OMNeT 6-pre12 fingerprint-modules filter broken due to slow dynamic cast #894

Open
edlongman opened this issue Sep 16, 2021 · 1 comment
Assignees
Labels
new New issue that has not been yet acknowledged
Milestone

Comments

@edlongman
Copy link
Contributor

edlongman commented Sep 16, 2021

Platform

  • OMNeT++ version: OMNeT 6-pre12
  • OS: Windows 10

Describe the bug
getClassDescriptorFor causes a huge slowdown of fingerprint calculation when filtering using fields. The simple Aloha simulation goes from 0.5s to over 15s

The dynamic cast from the classDescriptors array can be skipped (but with potential for risk here) since the only things that are added to the array are classDescriptors. But this is a negligible saving.

The issue with modules with no associated classDescriptor, so the entire array of classDescriptors must be looped through, doing a dynamic_cast inside doesSupport at every step along the way.

cClassDescriptor *cClassDescriptor::getDescriptorFor(const cObject *object)
{
// find descriptor by class name
cClassDescriptor *desc = cClassDescriptor::getDescriptorFor(object->getClassName());
if (desc)
return desc;
// bad luck: no descriptor for exactly this class. Try to find one for some base class.
//XXX we could even cache the result in a {classname->descriptor} hashtable.
cClassDescriptor *bestDesc = nullptr;
int bestInheritanceChainLength = -1;
cRegistrationList *array = classDescriptors.getInstance();
for (int i = 0; i < array->size(); i++) {
cClassDescriptor *desc = dynamic_cast<cClassDescriptor *>(array->get(i));
if (!desc || !desc->doesSupport(const_cast<cObject*>(object)))
continue; // skip holes
int inheritanceChainLength = desc->getInheritanceChainLength();
if (inheritanceChainLength > bestInheritanceChainLength) {
bestDesc = desc;
bestInheritanceChainLength = inheritanceChainLength;
}
}
return bestDesc;
}

To Reproduce
Run aloha sample (PureAloha1) with the following fingerprint calculation

sim-time-limit = 10000s
fingerprint = 330e-4b36/tplx
fingerprint-modules = "className=~*Host"

Compare that with fingerprint-modules = "Aloha.host*"

@edlongman edlongman added the new New issue that has not been yet acknowledged label Sep 16, 2021
@edlongman
Copy link
Contributor Author

Performance can be restored by adding a .msg file as per 6.10 of the user manual - but this is obviously not practical when using something like INET or another large library

cplusplus{{
#include <omnetpp.h>
#include "Server.h"
#include "Host.h"  
}}


namespace aloha;

class Server extends cSimpleModule
{
    @existingClass;
    @overwritePreviousDefinition;
    @descriptor(readonly);
    @icon(simple);
}

class Host extends cSimpleModule
{
    @existingClass;
    @overwritePreviousDefinition;
    @descriptor(readonly);
    @icon(simple);
}

@rhornig rhornig added this to the 6.1 milestone Feb 2, 2024
@rhornig rhornig self-assigned this Feb 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new New issue that has not been yet acknowledged
Projects
None yet
Development

No branches or pull requests

2 participants