Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Disabling Notifications on ResourceSet.clear
Disabling Notifications on ResourceSet.clear [message #1780542] Tue, 23 January 2018 19:30 Go to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
i want to disable notifications on resouceset clearing for performance reasons
so i do the following

rs.eSetDeliver(false);

but this seems not to be sufficient cause the resources and resoureset are inverses

do i additionally have to do this:

for (Resource r : rs.getResources()) {
r.eSetDeliver(false);
}

do i oversee something or is that the only way


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Disabling Notifications on ResourceSet.clear [message #1780588 is a reply to message #1780542] Wed, 24 January 2018 08:39 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
This is the only way. But the context is a little strange. Perhaps better to remove the adapters?

Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Disabling Notifications on ResourceSet.clear [message #1780592 is a reply to message #1780588] Wed, 24 January 2018 08:58 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
the problem is we have 380000 resources and the building/merging of the notifications is slow. if there is any adapter and/or delivering not turned off

public class Main {

    public static void main(String[] args) {
        Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("xmi", new ResourceFactoryImpl());
        ResourceSet rs = new ResourceSetImpl();
        AdapterImpl a = new AdapterImpl();
        rs.eAdapters().add(a);
        rs.eSetDeliver(false);
        for (int i = 0; i < 380000;i++) {
            if (i%1000==0) {
                System.out.println(i);
            }
            Resource r = rs.createResource(URI.createURI("dummy_"+i+".xmi"));
            r.eAdapters().add(a);
        }
        System.out.println("clearers gonna clear");
        rs.eSetDeliver(false);
        for (Resource r : rs.getResources()) {
//            r.eSetDeliver(false);
        }
        rs.getResources().clear();
        rs.eAdapters().clear();
        System.out.println("done");
    }

}


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Disabling Notifications on ResourceSet.clear [message #1780596 is a reply to message #1780592] Wed, 24 January 2018 11:17 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
Yes, I noticed not that long ago that notification merging in O(n^2). That's because org.eclipse.emf.common.notify.impl.NotificationChainImpl.add(Notification) walks each older notification calling org.eclipse.emf.common.notify.Notification.merge(Notification) on each one with respect to the new one being added. Assuming no clients specialize the merge implementation behavior in some unexpected way, one could build a map on the notifier when the list gets large to reduce this to O(n).

Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Disabling Notifications on ResourceSet.clear [message #1780945 is a reply to message #1780596] Tue, 30 January 2018 09:38 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
I opened https://bugs.eclipse.org/bugs/show_bug.cgi?id=530494 and addressed this problem. I think there should be no need to disable notifications with this fix. On my machine, I can clear a resource set with 640,000 resources (with adapters attached to the resource set and all resources) in < 200ms.

Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Disabling Notifications on ResourceSet.clear [message #1780954 is a reply to message #1780945] Tue, 30 January 2018 11:30 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
yes this looks very promising. thanks.

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:How do I define a nillable element in XSD schema for ecore XML model plugin
Next Topic:Link between 2 ecore?
Goto Forum:
  


Current Time: Fri Apr 19 09:07:28 GMT 2024

Powered by FUDForum. Page generated in 0.02111 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top