CrushMFT Documentation

Jobs with a million items#

A job hands a list of items from task to task. For a few thousand files nobody has to think about that list. This page is for jobs that find hundreds of thousands of files, or millions: what the server does to keep them from running out of memory, and what you can do.

What the server does by itself#

  • Long lists live on disk. A list with more than 10,000 items is kept in a file, and the tasks read it piece by piece. A run with a million items holds a few thousand of them in memory at a time.
  • All lists of all runs share a budget. A quarter of the engine's memory is for items. When the lists of all runs together need more, the longest move to disk first, also below 10,000.
  • Progress is saved inside a task. A task that is half way through a long list notes where it is, every 30 seconds. After a restart it goes on from there, not from the first item.
  • History keeps a sample. A finished run keeps the counts of every task and the first 1,000 items of each list, not all of them.

None of this has to be switched on.

The settings#

Server settings, for the rare case:

Setting Is Unless you change it
job_item_list_spill a list longer than this goes to disk 10000
job_item_memory_percent the share of the engine's memory for item lists 25
job_item_folder where the lists are kept on disk. Empty: with the jobs. empty
job_progress_save_seconds how often a task notes its place in a list 30
Store job items whether runs keep their items at all: see Jobs settings on

Put job_item_folder on a fast local disk with room: a list of a million items takes a few hundred megabytes while the run lasts. The files are removed when the run ends.

Per job there is one more, in the job's stored settings: item_lists_in_memory keeps this job's lists in memory whatever their length. It is for a job that is known to be small and must be fast; do not set it on the job this page is about.

What you can do in the job#

Find less. The cheapest item is the one that is never listed.

  • Point the Find at the folder that matters, not at its parent.
  • Use the Find's own filter and its Last modified limits. A Find for *.csv newer than one day lists a folder once and keeps a few items; a Find for * followed by an Exclude keeps them all first.
  • Limit the Depth.
  • Max Items to Find caps one run. With a job that runs every few minutes and removes what it handled, a cap turns one huge run into many small ones.

Remember what was done. A FindCache remembers the files a job has seen, so that the next run only gets the new ones. That is how a folder with a million files that grows by a hundred a day is handled: the list is a hundred long.

Work in batches. A Loop For each item with Items per pass of 1000 does a thousand at a time and saves its place between passes.

Avoid the tasks that need the whole list at once.

Task With a long list
Sort has to see all items to order them. It does so on disk, which takes time.
Java is always handed the whole list in memory. Do not put one behind a Find of a million.
Email with a line per file makes a mail nobody reads. Send the count, {items_count}.
Wait / Joiner with Union or Intersection compares the lists of all branches

Give the job room of its own. In the job's Setup: Runner: A runner of its own, and Size: Large. A heavy job then cannot disturb the others, and the others cannot disturb it. A job that passed 250,000 items once is moved to its own runner by the server anyway: see How an engine stays healthy.

Watching one#

  • Under Active Jobs, a task that is working through a long list shows how far it is.
  • For a run in the shared runner, the monitor shows the size of its lists in memory and on disk; for a run in its own runner, the memory it holds against its limit.
  • The Engines section shows the engine's memory level. Green is fine. See Job engines.

What has limits#

  • A cluster and engines on other machines. A run that moves from one machine to another takes its lists with it; lists that are sent over a link are sent in pieces. Such moves have not been tried at this size.
  • A DMZ. Items for a task that works through a DMZ server are sent there in pieces too.
  • The designer. Clicking a task of a finished run shows the first 1,000 of its items. The counts are always the true ones.

A rule of thumb#

Below 10,000 items: nothing to do. Up to 100,000: nothing to do, the lists go to disk. Above: look at the Find first, then give the job its own runner, and test it once with Max Items to Find before it runs at night.