Skip to main content
import

Fixing slow site imports on large export ZIPs (binary lookup performance)

Question

  • A site import (via jContent "Import site", Server Settings, or the provisioning API) appears stuck after logging "Start importing repository.xml" — the process runs for hours with little or no further log output and may never complete
  • Thread dumps taken during the import consistently show the import thread RUNNABLE, inside org.jahia.services.importexport.DocumentViewImportHandler.findContent()
  • CPU usage stays high throughout — the import is not deadlocked or hung, it is doing (redundant) work
  • The same site exported at a similar file size sometimes imports quickly, while another export of comparable size never completes — file size alone does not predict the slowness

Cause

findContent() locates binary content in the import ZIP using java.util.zip.ZipInputStream, which only supports forward, sequential reads (no central-directory random access like java.util.zip.ZipFile). Whenever the next needed binary entry lies earlier in the archive than the current read position, the code must close and fully reopen the ZIP from byte 0, then re-scan/re-decompress every entry again until it reaches the target one.

For most exports, this happens rarely. For large exports with many binaries whose entries are not stored in the same order they are referenced during import, this "rewind" can trigger on a large fraction of lookups, turning the import into an effectively quadratic operation — each rewind re-decompresses a large portion of a multi-gigabyte archive. In one confirmed case (~4.9GB export, ~7,900 ZIP entries), roughly every second binary lookup triggered a full rewind, which is why the import is really slow.

Solution

Enable Jahia's built-in mass-import setting to bypass the ZIP-stream lookup entirely: instead of searching for binaries inside the ZIP stream, the import first expands the archive's binaries to the local disk and resolves each one via a direct file lookup.

Steps:

  1. Stop the Jahia instance.
  2. In jahia.properties (digital-factory-config/jahia/jahia.properties), set:

    expandImportedFilesOnDisk = true
    expandImportedFilesOnDiskPath = /path/with/sufficient/free/disk/space
    • Use a fast local disk. Reserve free space comfortably above the export ZIP's uncompressed size (budget generously — e.g. 2–3x the ZIP size as a safe margin).
    • Files placed under expandImportedFilesOnDiskPath are deleted automatically at the end of the import.
    • This is a startup property (read once from SettingsBean) — a restart is required for it to take effect.
  3. Start Jahia and retry the import.

Optionally, importMaxBatch (default 500) controls how often the JCR session is saved during a mass import and can be tuned if memory pressure is observed — this is independent of the fix above.