• This repository has been archived on 09/Jan/2023
  • Stars
    star
    554
  • Rank 80,342 (Top 2 %)
  • Language
    JavaScript
  • License
    Other
  • Created about 7 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Unity CacheServer optimized for multi-client local networks

Cache Server v6.4 Build Status Coverage Status

The Unity Cache Server, optimized for locally networked team environments.

Overview

Note: This version of the cache server does not support the new Asset Database Version 2 introduced in Unity 2019.3. For projects using the new Asset import pipeline, use the Accelerator

This repository contains an open-source implementation of the Cache Server. This stand-alone version of Cache Server is specifically optimized for LAN connected teams. The Cache Server speeds up initial import of project data, as well as platform switching within a project.

This open-source repository is maintained separately from the Cache Server available on the Unity website and the implementation of the Cache Server that is packaged with the Unity installer.

Table of Contents

Server Setup

Download and install LTS version 12.13.x of Node.js from the Node.JS website.

Install from npm registry

npm install unity-cache-server -g

For the latest beta release:

npm install unity-cache-server@beta -g

Install from GitHub source

npm install github:Unity-Technologies/unity-cache-server -g

Note: GitHub source install from master branch might be ahead of latest release version.

Usage

Default options are suitable for quickly starting a cache server, with a default cache location of .cache_fs

unity-cache-server [arguments]
Option Description
-V, --version Show the version number of the Cache Server.
-h, --host <address> The interface on which the Cache Server listens. The default is to listen on all interfaces.
-p, --port <n> The port on which the Cache Server listens. The default value is 8126.
-c, --cache-module [path] The path to cache module. The Default path is 'cache_fs'.
-P, --cache-path [path] The path of the cache directory.
-l, --log-level <n> The level of log verbosity. Valid values are 0 (silent) through 4 (debug). The default is 3 (info).
-w, --workers <n> The number of worker threads to spawn. The default is 0.
--diag-client-recorder Record incoming client network stream to disk.
-m, --mirror <host:port> Mirror transactions to another cache server. Repeat this option for multiple mirrors.
-W, --putwhitelist <host:port> Only allow PUT transactions (uploads) from the specified client address. Repeat this option for multiple addresses.
--dump-config Write the active configuration to the console.
--save-config [path] Write the active configuration to the specified file and exit. Defaults to ./default.yml.
-h, --help Show usage information.

Configuration files

The config/default.yml file contains configuration values for the cache modules (see below) and other features. The config system is based on the node-config module. For additional information on how to manage environment specific config files, see the Configuration Files documentation on the node-config GitHub repository.

General Options

Option Default Description
Global.logLevel 3 Logging level; override with the --log-level CLI command
Cache.options.processor.putWhitelist [] Only allow PUT transactions (uploads) from the specified array of IP addresses (string values)
Cache.options.workers 1 Number of worker threads; override with the --worker CLI command
Server.host 0.0.0.0 The interface on which the Cache Server listens. Override with the --host CLI command
Server.port 8126 The port on which the Cache Server listens. Override with the --port CLI command
Server.options.allowIPv6 false Listen for client connections on both IPv4 and IPv6

Examples (Mac/Linux)

You can have multiple configuration files based on environment:

  1. export NODE_ENV=development
  2. unity-cache-server --save-config config/local-development.yml

To use a custom configuration directory:

  1. mkdir myCustomConfig
  2. unity-cache-server --save-config myCustomConfig/default.yml
  3. export NODE_CONFIG_DIR=myCustomConfig
  4. unity-cache-server

To dump the current config to the console, run the following command:

unity-cache-server --dump-config

Client Configuration

The Cache Server section of the Unity Manual contains detailed information on connecting clients to remote Cache Servers.

Cache Modules

Cache Server supports two caching mechanisms:

  • A file system based cache.
  • A fully memory (RAM) backed cache.

The file system module is the default and suitable for most applications. The RAM cache module provides optimal performance but requires a sufficient amount of physical RAM in the server system. Typically, this is two to three times size of your Project's Library folder on disk.

Configuration options for all modules are set in the config/default.yml file.

cache_fs (default)

A simple, efficient file system backed cache.

Usage

--cache-module cache_fs

Options

Option Default Description
cachePath .cache_fs The path to the cache directory.
cleanupOptions.expireTimeSpan P30D ASP.NET or ISO 8601 style timespan. Cache files that have not been accessed within this timespan are eligible for cleanup. For more information on duration syntax, see the moment library documentation.
cleanupOptions.maxCacheSize 0 The maximum size, in bytes, of the cache on disk. To bring the total disk utilization under this threshold, the cleanup script considers files for removal in least recently used order. Set the value to zero (0) to disable the cleanup feature.

Notes

  • cache_fs is backwards compatible with v5.x Cache Server directories.
  • Supports worker threads using the --workers option.
  • When you run the cleanup script, the value of the expireTimeSpan option is used to determine which files to delete. If maxCacheSize is specified the script checks whether the cache exceeds the value of maxCacheSize. If it does, the script deletes files in least-recently-used order until the cache no longer exceed maxCacheSize.

cache_ram

A high performance, fully in-memory LRU cache.

Usage

--cache-module cache_ram

Options

Option Default Description
pageSize 100000000 The page size, in bytes, used to grow the cache.
maxPageCount 10 The maximum number of pages to allocate in the cache. The combination of pageSize and maxPageCount limits the overall memory footprint of the cache. When this threshold is reached, memory is recovered using a Least Recently Used (LRU) algorithm.
minFreeBlockSize 1024 The size of the minimum allocation unit, in bytes, within a page. You can specify a lower value for smaller projects.
cachePath .cache_ram The path to the cache directory. Dirty memory pages are saved to disk periodically in this directory, and loaded at startup.
persistence true Enable saving and loading of page files to disk. If false, the cache is emptied during restart.
persistenceOptions.autosave true When set to true, automatically save changed memory pages; set to false to disable. If false, pages are only saved when the cache server is stopped with the q console command or with upon a SIGTERM.
persistenceOptions.autosaveInterval 10000 The frequency, in milliseconds, to save pages that have changed.

Notes

  • Does not support worker threads.

Cache Cleanup

Due to performance considerations, the cache_fs module shipped with Cache Server v6.0 does NOT operate as an LRU cache and does not enforce overall cache size restrictions. This is a change from previous versions of Cache Server. To manage disk usage, a separate cleanup script is provided that can either be run periodically or in "daemon" mode to automatically run at a given time interval.

Usage

unity-cache-server-cleanup [option] or node cleanup.js [options]

Option Description
-V, --version Show the version number of cleanup script.
-c --cache-module [path] The path to the cache module.
-P, --cache-path [path] The path of the cache directory.
-l, --log-level The level of log verbosity. Valid values are 0 (silent) through 4 (debug)
-e, --expire-time-span Override the configured file expiration timespan. Both ASP.NET style time spans (days.minutes:hours:seconds, for example '15.23:59:59') and ISO 8601 time spans (For example, 'P15DT23H59M59S') are supported.
-s, --max-cache-size Override the configured maximum cache size. Files will be removed from the cache until the max cache size is satisfied, using a Least Recently Used search. A value of 0 disables this check.
-d, --delete Delete cached files that match the configured criteria. Without this, the default behavior is to dry-run which will print diagnostic information only.
-D, --daemon Daemon mode. Execute the cleanup script at the given interval in seconds as a foreground process.
-h, --help Show usage information.

Notes

  • Only the cache_fs module supports cache cleanup (cache_ram does not).

Mirroring

Usage

Use the --mirror [host:port] option to relay all upload transactions to one or more Cache Server hosts (repeat the option for each host).

Important: Use the --mirror option cautiously. There are checks in place to prevent self-mirroring, but it is still possible to create infinite transaction loops.

Options

Option Default Description
queueProcessDelay 2000 The period, in milliseconds, to delay the start of processing the queue, from when the first transaction is added to an empty queue. Each transaction from a client is queued after completion. It's a good idea to keep this value at or above the default value to avoid possible I/O race conditions with recently completed transactions.
connectionIdleTimeout 10000 The period, in milliseconds, to keep connections to remote mirror hosts alive, after processing a queue of transactions. Queue processing is bursty. To minimize the overhead of connection setup and teardown, calibrate this value for your environment.

High Reliability Mode

High Reliability Mode imposes stricter requirements on upload transactions to increase the integrity of cached data.

Background

Asset versions are cached based on the Asset GUID and Asset hash reported by the client (Unity Editor). The Asset hash is calculated from the inputs to the Asset import process. The import process should produce the same binary result for a given set of inputs, but there is no guarantee that it will. Instability in the import process is typically an indication of a bug or design problem in the Asset importer.These errors can be propagated to other clients because Unity is not able to detect these instabilities before committing them to the Cache Server.

Function

In the default operating mode (highReliability is false), the Cache Server accepts all transactions for all versions of an Asset from any Unity client. In this scenario, the version of an Asset can change after it is already committed and the commit can cause an incorrect or unstable import.

High Reliability Mode allows the Cache Server to compare multiple transactions for the same version for binary stability before committing a version to the cache, and disallows further modifications to already committed versions. When an instability is detected, warning messages are logged and caching of the Asset is suspended until a team member uploads a new version of the Asset.

Requiring multiple imports of the same Asset to ensure the stability of each Asset version is resource intensive. High Reliability Mode is primarily beneficial to developers in networked team environments, where the increased overhead of importing Assets multiple times is distributed across the entire team. The larger the team, the smaller the impact on any individual.

Configuration

When highReliability is true, a counter for an Asset version is incremented with each transaction that is binary identical to the previous. When the counter reaches the configured reliabilityThreshold, the version is committed to the cache and served. For networked team environments, setting multiClient to true forces more than one client to commit the same transaction to increment the counter. Setting reliabilityThreshold to a value of 0 or 1 disables the reliability checks, but still prevents versions from changing. For debugging purposes, setting saveUnreliableVersionArtifacts to true isolates and saves all uploads of unstable Asset versions for later inspection and diffing.

Option Default Description
highReliability false Enable high reliability mode.
highReliabilityOptions.reliabilityThreshold 2 Number of binary-stable imports of the same version required before a version is cached and served.
highReliabilityOptions.saveUnreliableVersionArtifacts true After a version is declared unreliable, save all subsequent transactions for the version for later inspection and debugging.
highReliabilityOptions.multiClient false Require multiple clients to upload the same binary-stable version to increment the stability factor. For example, if the same client uploads the same version twice in a row, it does not increase stability of the version.

Unity project Library Importer

Tools are provided to quickly seed a Cache Server from a fully imported Unity project (a project with a Library folder).

Steps to Import a Project

  1. Add the CacheServerTransactionImporter.cs script to the Unity project to export.
  2. To save an export data file in .json format, in the Unity Editor, select Cache Server Utilities > Export Transactions . Alternatively, with the script added to your project, you can run Unity in batch mode using the -executeMethod option. For the <ClassName.MethodName>, use CacheServerTransactionExporter.ExportTransactions([path]) where path is the full path and filename to export. For more information on running the Editor in silent mode and the -executeMethod option, see Command line arguments.
  3. Run the import utility to begin the import process: unity-cache-server-import <path to json file> [server:port]

Notes

  • On very large projects, Unity might appear to freeze while generating the exported JSON data.
  • The default server:port is localhost:8126
  • The import process connects and uploads to the target host like any other Unity client, so it should be safe in a production environment.
  • Files are skipped if any changes were detected between when the JSON data was exported and when the importer tool is executed.

Diagnostics

Client Recorder (--diag-client-recorder)

Starting up the Cache Server with the --diag-client-recorder option will write to disk raw data from all incoming client connections (by default to the diagnostics/client-recordings folder). Example tools and libraries for analysing recorded sessions can be found in the ucs-diag-tools repository.

Configuration

Option Default Description
Diagnostics.clientRecorder false Enable client network stream recording.
Diagnostics.clientRecorderOptions.bufferSize 10000000 Size of in-memory buffer for client network stream recording.
Diagnostics.clientRecorderOptions.saveDir "diagnostics/client-recordings" Directory where client network stream recordings will be saved. A relative directory will be relative to the server application startup directory.

Contributors

Contributions are welcome! Before submitting pull requests please note the Submission of Contributions section of the Apache 2.0 license.

The server protocol is described in protocol.md

License

Apache-2.0 Β© Unity Technologies

More Repositories

1

ml-agents

The Unity Machine Learning Agents Toolkit (ML-Agents) is an open-source project that enables games and simulations to serve as environments for training intelligent agents using deep reinforcement learning and imitation learning.
C#
16,946
star
2

UnityCsReference

Unity C# reference source code.
C#
10,410
star
3

EntityComponentSystemSamples

C#
7,135
star
4

FPSSample

A first person multiplayer shooter example project in Unity
C#
4,864
star
5

PostProcessing

Post Processing Stack
C#
3,665
star
6

arfoundation-samples

Example content for Unity projects based on AR Foundation
C#
3,040
star
7

NavMeshComponents

High Level API Components for Runtime NavMesh Building
C#
3,008
star
8

BoatAttack

Demo Project using the Universal RP from Unity3D
C#
2,534
star
9

Graphics

Unity Graphics - Including Scriptable Render Pipeline
C#
2,504
star
10

com.unity.netcode.gameobjects

Netcode for GameObjects is a high-level netcode SDK that provides networking capabilities to GameObject/MonoBehaviour workflows within Unity and sits on top of underlying transport layer.
C#
2,138
star
11

AssetBundles-Browser

Editor tool for viewing and debugging asset bundle contents before and after builds
C#
1,940
star
12

UniversalRenderingExamples

This project contains a collection of Custom Renderer examples. This will be updated as we refine the feature and add more options.
C#
1,923
star
13

com.unity.multiplayer.samples.coop

A small-scale cooperative game sample built on the new, Unity networking framework to teach developers about creating a similar multiplayer game.
C#
1,595
star
14

VolumetricLighting

Lighting effects implemented for the Adam demo: volumetric fog, area lights and tube lights
C#
1,576
star
15

Unity-Robotics-Hub

Central repository for tools, tutorials, resources, and documentation for robotics simulation in Unity.
C#
1,544
star
16

AutoLOD

Automatic LOD generation + scene optimization
C#
1,534
star
17

VisualEffectGraph-Samples

Visual Effect Graph - Samples Project
C#
1,498
star
18

InputSystem

An efficient and versatile input system for Unity.
C#
1,428
star
19

game-programming-patterns-demo

A repo of small demos that assemble some of the well-known design patterns in Unity development to support the ebook "Level up your code with game programming patterns"
C#
1,427
star
20

2d-extras

Fun 2D Stuff that we'd like to share!
C#
1,387
star
21

Animation-Instancing

This technique is designed to instance Characters(SkinnedMeshRender).
C#
1,366
star
22

Unity.Mathematics

The C# math library used in Unity providing vector types and math functions with a shader like syntax
C#
1,354
star
23

multiplayer

Unity multiplayer packages and samples
1,328
star
24

UnityRenderStreaming

Streaming server for Unity
C#
1,306
star
25

DOTS-training-samples

Samples designed as exercises to be ported from Unity GameObjects/MonoBehaviours to Unity DOTS.
C#
1,281
star
26

Addressables-Sample

Demo project using Addressables package
C#
1,277
star
27

ShaderGraph

Unity ShaderGraph project
C#
1,154
star
28

AssetGraph

Visual Workflow Automation Tool for Unity.
C#
1,088
star
29

XR-Interaction-Toolkit-Examples

This repository contains various examples to use with the XR Interaction Toolkit
C#
1,068
star
30

FontainebleauDemo

Fontainebleau demo
C#
947
star
31

uGUI

Source code for the Unity UI system.
C#
937
star
32

DOTSSample

A third person, multiplayer sample project. Built with Unity and using the new Data Oriented Tech Stack (DOTS).
C#
932
star
33

EditorXR

Author XR in XR
C#
925
star
34

SpaceshipDemo

Spaceship Demo - AAA Playable First person demo showcasing effects made with Visual Effect Graph and rendered with High Definition Render Pipeline
C#
916
star
35

VFXToolbox

Additional tools for Visual Effect Artists
C#
909
star
36

2d-techdemos

Tech Demos for Unity 2D Features
C#
881
star
37

ProjectTinySamples

Samples for Project Tiny
C#
880
star
38

HLODSystem

C#
844
star
39

ProjectAuditor

Project Auditor is an experimental static analysis tool for Unity Projects.
C#
815
star
40

UnityPlayground

A collection of simple scripts to create 2D physics game, intended for giving workshops to a young audience
C#
806
star
41

com.unity.formats.alembic

Alembic importer and exporter plugin for Unity
C#
786
star
42

HLSLcc

DirectX shader bytecode cross compiler
C++
770
star
43

com.unity.webrtc

WebRTC package for Unity
Assembly
753
star
44

giles

GILES: A Runtime Level Editor for Unity3D
C#
743
star
45

com.unity.perception

Perception toolkit for sim2real training and validation in Unity
C#
734
star
46

BackgroundDownload

Plugins for mobile platforms to enable file downloads in background
C#
721
star
47

UniteAustinTechnicalPresentation

C#
721
star
48

com.unity.demoteam.hair

An integrated solution for authoring / importing / simulating / rendering strand-based hair in Unity.
C#
712
star
49

SuperScience

Gems of Unity Labs for our user-base.
C#
711
star
50

com.unity.multiplayer.docs

Open Source documentation for Unity Multiplayer, which includes Netcode for GameObjects, the Unity Transport Package, Multiplayer Tools and Educational references and Sample Games such as Boss Room.
JavaScript
634
star
51

NativeRenderingPlugin

C++ Rendering Plugin example for Unity
C
633
star
52

guid-based-reference

A component for giving Game Objects a GUID and a class to create references to objects in any Scene by GUID
C#
615
star
53

uaal-example

Objective-C++
605
star
54

com.unity.uiwidgets

UIWidgets is a Unity Package which helps developers to create, debug and deploy efficient, cross-platform Apps.
C#
603
star
55

Standard-Assets-Characters

Unity Standard Asset Controllers
C#
602
star
56

megacity-metro

Megacity-Metro: a thrilling shooter game, using Netcode for Entities for a multiplayer experience supporting 128+ players. Latest DOTS packages and Unity Gaming Services elevate the user experience, demonstrating how to craft engaging multiplayer games.
C#
567
star
57

barracuda-release

C#
565
star
58

MeshApiExamples

Example project for Unity 2020.1 Mesh API improvements
C#
558
star
59

SimpleAnimation

A simple Animation Component that leverages PlayableGraphs
C#
539
star
60

GenericFrameRecorder

This GitHub package is DEPRECATED. Please get the new Unity Recorder from the Asset Store (https://assetstore.unity.com/packages/essentials/unity-recorder-94079) Use the editor builtin Bug Reporter to report issues. You can track and vote for issues on the Issue Tracker (https://issuetracker.unity3d.com)
C#
533
star
61

obstacle-tower-env

Obstacle Tower Environment
Python
532
star
62

graph-visualizer

Visualizer for your Playable graphs
C#
522
star
63

DeLightingTool

De-Lighting tool
C#
518
star
64

com.unity.demoteam.digital-human

Library of tech features used to realize the digital human from 'The Heretic' and 'Enemies'.
C#
517
star
65

PhysicsExamples2D

Examples of various Unity 2D Physics components and features.
C#
512
star
66

com.unity.cinemachine

Smart camera tools for passionate creators
C#
503
star
67

usd-unity-sdk

Integration of Pixar's Universal Scene Description into Unity. UPDATE: This package has been superseded by our new bundle of USD packages. Please see README & link below for further details.
C#
498
star
68

arfoundation-demos

AR Foundation demo projects
C#
494
star
69

facial-ar-remote

**This project is discontinued** Facial AR Remote is a tool that allows you to capture blendshape animations directly from your iPhone X into Unity 3d by use of an app on your phone.
C#
482
star
70

animation-jobs-samples

Code samples using the animation C# jobs feature.
C#
464
star
71

vscode-unity-debug

Unity debugging support for VS Code
C#
459
star
72

MeshSyncDCCPlugins

DCC plugins for MeshSync in Unity. Supported tools: Maya, Maya LT, 3ds Max, Motion Builder, Modo, Blender, Metasequoia
C++
438
star
73

UIElementsExamples

Unity project containing examples to use UIElements in the Editor
C#
436
star
74

Unity.Animation.Samples

Repository of projects that showcase the new DOTS animation package (com.unity.animation).
C#
419
star
75

com.unity.demoteam.mesh-to-sdf

A light and fast real-time SDF generator, primarily for animated characters. The dynamic SDF can be used for all sorts of VFX. Also enables hair-to-character collisions in the new hair package.
C#
402
star
76

MeasuredMaterialLibraryURP

HLSL
377
star
77

BatchBreakingCause

This project demonstrates different cases when Unity has to break a batch while rendering.
GLSL
355
star
78

MeasuredMaterialLibraryHDRP

C#
355
star
79

UIToolkitUnityRoyaleRuntimeDemo

This is a sample project to introduce the use of UI Toolkit in Runtime
C#
351
star
80

UnityDataTools

Experimental tools and libraries for reading and analyzing Unity data files.
C#
328
star
81

HDRPRayTracingScenes

This repository contains a startup DXR project.
327
star
82

SynthDet

SynthDet - An end-to-end object detection pipeline using synthetic data
C#
324
star
83

EndlessRunnerSampleGame

Repository for the Endless Runner Game Sample (Trash Dash)
C#
324
star
84

boat-attack-water

Package repo containing the water system created for the URP Boat Attack demo project.
C#
318
star
85

BuildReportInspector

Editor script which implements an inspector for the BuildReport class
C#
317
star
86

multiplayer-community-contributions

Community contributions to Unity Multiplayer Networking products and services.
C#
316
star
87

com.unity.services.samples.use-cases

The collection of samples in this repo use Unity Gaming Services in a Unity project to demonstrate live gaming operations.
C#
312
star
88

com.unity.probuilder

C#
305
star
89

XRLineRenderer

An XR-Focused line renderer that mimics rendering with 3d capsules while only using two quads worth of geometry.
C#
299
star
90

com.unity.demoteam.digital-human.sample

Character sample featuring the digital human from 'The Heretic'.
C#
298
star
91

VRAlchemyLab

VR Demo project using HDRP and unity 2019.3
C#
283
star
92

marathon-envs

A set of high-dimensional continuous control environments for use with Unity ML-Agents Toolkit.
C#
279
star
93

articulations-robot-demo

C#
278
star
94

NotificationsSamples

Sample project for Unity Notifications
C#
265
star
95

SkyboxPanoramicShader

Skybox shader for support of 360/180/cubemap video and static content
ShaderLab
265
star
96

PeopleSansPeople

Unity's privacy-preserving human-centric synthetic data generator
C#
261
star
97

Robotics-Object-Pose-Estimation

A complete end-to-end demonstration in which we collect training data in Unity and use that data to train a deep neural network to predict the pose of a cube. This model is then deployed in a simulated robotic pick-and-place task.
Python
250
star
98

ECS-Network-Racing-Sample

ECS multiplayer racing sample to showcase using Unity Entities and netcode with best practices
C#
248
star
99

2d-pixel-perfect

Pixel Perfect Camera
C#
244
star
100

ShaderGraph-Custom-Lighting

A sample project showcasing a simple method to calculate custom lighting inside of Shader Graph for the Lightweight Render Pipeline. Includes a sample toon shaded scene and example assets. Built for Unity 2019.2 .
Mathematica
244
star