Short Contents

7.14 Network Cache

3Delight offers a special extension for more efficient rendering in networked environments: a local file cache for textures and archives to minimize network traffic and file server load. This proves particularly powerful when using a large quantity of rendering servers.

The working principle of 3Delight's network cache is to copy files to a local file system and reuse them when needed. If either a texture or a RIB archive is cacheable and the file cache is full, one or more files are removed from the cache to make space for the new one; a LRU (Least Recently Used) strategy is used to choose which texture(s) or archive(s) to remove from the cache.

Eligibility to caching is different for textures and archives, in summary:

` Textures'
` Shadow maps'
` Environment maps'
Cached when accessed through the texture(), shadow() and environment() shadeops, meaning that textures that are never accessed do not waste cache space.
` Delayed Archives'
Cached only if occlusion culling determines that the "archive is visible", meaning that invisible models do not waste cache space.
` Archives'
Cached immediately.

The design of the network cache was justified by the following observations:

Activating the Network Cache

To enable the network cache, use the following RiOption:

Option "netcache" "string cachedir" ["/tmp/3delight_cache/"]

This informs 3Delight to use a directory named `/tmp/3delight_cache/' to cache textures files. If the directory is already created, 3Delight uses whatever cached files it contains. It is important to use a locally mounted directory since caching network files on a network volume is useless. The chosen directory should be dedicated to 3Delight: do not put any files in that directory since they can disappear without notice. It is possible to disable the cache again by calling the same RiOption with a null file name. This can be useful in multi-frame RIBs.

Option "netcache" "string cachedir" [""]

Cache size is controlled using another RiOption. For example, to specify 1000 megabytes of network cache, use:

Option "netcache" "integer cachesize" 1000

Specifying a size which is smaller than the actual cache size causes files to be removed from the cache until the specified size is reached.

There is no need to specify which files to cache, 3Delight detects automatically slow access files and caches them. Slow access files are files mounted on a NFS disk or a CD-ROM.

It is also possible to instruct 3Delight to cache some output files by using:

Option "netcache" "integer writecache" 1

This can save a great deal of bandwidth when the output file is going to be reused as the input to another render on the same machine. Shadowmaps are a common example of this. Even for files which are not going to be reused, it is usually more efficient for the file server to receive them in one large chunk. Note that because the size of output files is not known in advance, they do not count towards the maximum cache size until they are finished writing. This means the cache can temporarily grow larger than the set size so ensure there is some extra space available on the drive used.

It is possible to override the network cache's choices about which files are eligible for caching. Refer to Network Cache Options for more information.

Purging the Network Cache

The network cache can be purged manually at any moment if no renderings are running on the machine. Simply erase the directory and all its contained files:

rm -rf /tmp/3delight_cache

Using Directory Textures For Large Textures

The network caching algorithm copies the entire content of the texture from the server to the local machine, which is desirable in most cases. In some situations however, when the textures are very large but the quality settings are not high enough to see all the details, copying the entire texture might be a waste of resources. For such cases, 3Delight provides "directory textures": textures saved in a format that permits the caching of data with a mipmap granularity level. The format is quite simple: the texture becomes a directory with all the mipmap levels saved as individual TIFF files that area cacheable independently. Creating such textures is straightforward:

tdlmake -dirtex source.tif destination.tdl

This command will create a directory named "destination.tdl" that contains all the mipmap levels.
To know if directory textures are beneficial in a particular situation, one should analyze texture access statistics to see if the most detailed mipmaps are accessed or not.

Safety

Many precautions have been taken to ensure the proper operation of the network cache:

  1. 3Delight does not access the original textures or archives in any dangerous way, only reading is performed on those files.
  2. The cache is kept synchronized with the files it mirrors: if an original texture is newer than the cached one, the cache is updated.
  3. A file is identified by its full path: files that have the same name in different directories do not collide.
  4. UNIX file links are resolved prior to caching, this ensures that a given file is cached only once even if many links point to it.
  5. The network cache is multiprocess safe. Even if many renders are running on the same machine, the cache is kept in a consistent state: one 3Delight instance does not remove a texture or archive used by another instance!
  6. Cache directory is created with full access permissions to `user' and `group', but only read access to `other'(60).
  7. If, for any reason, 3Delight is unable to cache a file, it reverts to use the original, and this is the worst case scenario.

3Delight 10.0. Copyright 2000-2011 The 3Delight Team. All Rights Reserved.