Serialisation of EMF-Model to XML file takes several hours

396 views Asked by At

I have the following problem that when I have a very big EMF Model (>1G on heap) to serialise to a XML file it takes several hours. I've no idea if I'm doing something wrong that causes that long delay or if this is common to take that long. We have a lot of lists in the model but otherwise there are just a lot of objects which are graph nodes with a very long UUID and a few parameters which are mostly integers and further string values like names and so on.

That's an excerpt of my saving routine of my EMF model:

// Register the XMI resource factory
Resource.Factory.Registry reg = Resource.Factory.Registry.INSTANCE;
reg.getExtensionToFactoryMap().put(uri.fileExtension(), new XMIResourceFactoryImpl());

// Obtain a new resource set
ResourceSet resSet = new ResourceSetImpl();

// create a resource
Resource resource = resSet.createResource(uri);

// get resource content
EList<EObject> resourceContent = resource.getContents();

resourceContent.add(objectsToAdd);

// save to file
resource.save(ResourceAdder.createOptions());

That's how my options look like:

public static Map<?, ?> createOptions() {
    HashMap<String, Object> options = new HashMap<String, Object>();
    options.put(XMLResource.OPTION_ENCODING, "UTF-8"); //$NON-NLS-1$
    options.put(XMLResource.OPTION_CONFIGURATION_CACHE, Boolean.TRUE);
    options.put(Resource.OPTION_SAVE_ONLY_IF_CHANGED, Resource.OPTION_SAVE_ONLY_IF_CHANGED_MEMORY_BUFFER);
    return options;
}

So my question is if it is common to take that long to serialise a large EMF-Model? What do you suggest I could do to reduce the amount of time it takes to serialise the model. I already considered using Teneo and serialise the entire EMF-Model to a local Derby database but I haven't tested it yet if it would improve the runtime. Thanks for any pointers or suggestions you can provide.

I added a heap analysis made by VisualVM from a very small graph which still took several minutes to serialise. The final size of all XML-Files is 250MB. HeapAnalysisOfSmallGraph

0

There are 0 answers