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

Memory usage for repository export to XML may be unnecessarily high #55

Open
Sat-Ing opened this issue Jul 29, 2024 · 7 comments
Open

Comments

@Sat-Ing
Copy link

Sat-Ing commented Jul 29, 2024

If I export a repository to XML via org.eclipse.emf.cdo.server.CDOServerExporter.XML#exportRepository, I need a very high system memory, otherwise I run into out-of-memory exceptions. The required memory correlates to the size of the repository.

On the other hand, the import via org.eclipse.emf.cdo.server.CDOServerImporter.XML#importRepository, seems not to be dependent on the repository's size and the memory usage is always quite low.

Now the question is: could we somehow reduce the required memory for repository exports? This would greatly benefit the operational usage.

@estepper
Copy link
Contributor

estepper commented Aug 5, 2024

I implemented both the exporter and the importer with scalability in mind. Though, it's possible that I overlooked something. Do you have a concrete suspicion where memory could leak? Perhaps you can use a profiler to inspect your scenario?

@Sat-Ing
Copy link
Author

Sat-Ing commented Aug 6, 2024

@estepper the memory pretty much linearly increases until the export is complete. Binary/XML exports are affected in a similar way. I did not have a look at the CDO code yet. This is a heap dump for a binary export:
image

@estepper
Copy link
Contributor

estepper commented Aug 6, 2024

Thanks for the additional info! I fear I'll have to create a huge repo and try it out myself. Is 15 million objects approx. the size of your repo?

@Sat-Ing
Copy link
Author

Sat-Ing commented Aug 6, 2024

Thats a good question ;). The h2 database size is ~4GB. I need ~8GB of RAM to export it. I am using a repository with no branching and no audits.

@estepper
Copy link
Contributor

estepper commented Aug 6, 2024

H2 and non-auditing are good infos, too. My guess of >15 million objects came fro the instance countin your heap dump for CDOIDObjectLongImpl ;-)

@estepper
Copy link
Contributor

estepper commented Aug 7, 2024

Just to be sure, you haven't customized the server in any way? I mean, no custom listeners or whatever could hold onto Java objects in addition to CDO's shipped code...

@Sat-Ing
Copy link
Author

Sat-Ing commented Aug 7, 2024

No, that should not be the case. This is basically what we do during the export routine. Nothing else is done before this code:

        File h2db = new File(getRepoPath());
        JdbcDataSource dataSource = new JdbcDataSource();
        dataSource.setURL("jdbc:h2:" + h2db + File.separator + REPOSITORY_NAME);

        IMappingStrategy mappingStrategy = CDODBUtil.createHorizontalMappingStrategy(false);
        mappingStrategy.getProperties().put(Props.QUALIFIED_NAMES, "true");
        IDBAdapter dbAdapter = new H2Adapter();
        IDBConnectionProvider dbConnectionProvider = DBUtil.createConnectionProvider(dataSource);
        IStore store = CDODBUtil.createStore(mappingStrategy, dbAdapter, dbConnectionProvider, new HashMap<>());

        Map<String, String> props = new HashMap<String, String>();
        props.put(IRepository.Props.OVERRIDE_UUID, REPOSITORY_NAME);
        props.put(IRepository.Props.SUPPORTING_AUDITS, "false");
        props.put(IRepository.Props.SUPPORTING_BRANCHES, "false");
        props.put(IRepository.Props.ENSURE_REFERENTIAL_INTEGRITY, "false");
        props.put(IRepository.Props.COMMIT_INFO_STORAGE, "NO");
        IRepository repository = CDOServerUtil.createRepository(REPOSITORY_NAME, store, props);

        XML xmlExporter = new XML(repository);
        try (OutputStream os = new FileOutputStream(outputFile)) {
            xmlExporter.exportRepository(os);
        }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants