-
Notifications
You must be signed in to change notification settings - Fork 334
E2 Guide: Ops
Ops are E2's main method of limiting its performance cost. Every single action in E2 is assigned an op cost, ranging from fractions to hundreds. Ops provide a simple way to track performance in a way that is the same for every user: as long as you stay under the quota, your E2 chip will run on every server you visit. When you reach the op quota, the maximum limit of ops you can have at any moment, your chip will halt and error. Generally speaking, a chip with a lower op cost is more efficient than a chip with a higher op cost.
Note
Op costs are subject to change. Some op costs do not reflect the performance of functions accurately.
There are three op quotas used by E2; soft quota, hard quota, and tick quota. Soft quota is the amount of ops you can use in a tick before you run into "op debt", which is where you start adding to the op count. Hard quota is the maximum amount of "op debt" that you can have over an indeterminate amount of time[1]. Tick quota is the maximum number of ops you can use over a single tick. For the most part, the differences of these quotas aren't very significant to know as you'll mostly only be working around the soft quota and tick quota. By default, quotas are 10,000
, 100,000
, and 25,000
for soft, hard, and tick quota respectively.
1: More specifically, hard quota is determined by op count + current ops - soft quota
, and op count = max((op count + current ops - soft quota), 0)
, where hard quota is recalculated on execution while op count is recalculated each tick.
Ops have been decided as the simplest and most efficient solution to ensure players don't crash servers with expensive E2 chips. The main benefits of ops are that they are consistent, so two servers with similar quotas can run the same chips, and that they are lightweight, being only a number that's incremented as opposed to CPU time benchmarking which varies greatly depending on outside factors. Additionally, ops provide a built-in method to openly discourage using certain functions, such as deprecated or inefficient functions.
The easiest way to avoid reaching op quotas is to write efficient code. Usually this is in more obvious forms such as using foreach
instead of for
and avoiding redundant expressions, but sometimes it may take some ingenuity and scouring of the E2Helper or Wiki to find more efficient methods of accomplishing a task. Alternatively, you can use the functions perf()
or perf(n)
in your code to query if your chip has reached a percentage of the op quota.
I = 0
while(perf(80)) { # Runs the loop until the chip reaches 80% quota usage
I++
}
print(I)
By combining perf()
with timers, you can use it to split a loop among multiple executions.
if(clk("iter")) {
for(I = Index, Max) { # Note with some ingenuity you can also use foreach with perf.
Index++ # Some persistent variable Index to track position.
if(perf()) {
# ... code
} else { break }
}
if(Index != Max) {
timer("iter", tickInterval()*1000)
} else {
# Trigger some signal/timer to indicate the loop is finished
}
}
Please do not alter the e2 docs ...
pages manually.
They are autogenerated from the E2Helper. In the future, this will hopefully be its own dedicated website or tool.
Basic Features: core, debug, number, selfaware,
string, timer
🌎 World: angle, color, find, ranger, sound,
🔣 Math: bitwise, complex, matrix, quaternion, vector, vector2/4
📦 Entities: bone, constraint, egp, entity, hologram, npc
👨 Players: chat, console, player, weapon
📊 Data storage: array, files, globalvars, serialization, table
💬 Communication: datasignal, http, signal, wirelink,
❓ Informational: gametick, serverinfo, steamidconv, unitconv
Disabled by default: constraintcore, effects, propcore, remoteupload, wiring
Wire-Extras (repo): camera, ftrace, holoanim, light, stcontrol, tracesystem
- Home 🏠
- Syntax 🔣
- Directives 🎛️
- Editor 🖥️
- Events 🌟 (new!)
Click To Expand
- 🟥 SPU
- 🟥 Address Bus
- 🟥 Extended Bus
- 🟥 Plug/Socket
- 🟥 Port
- 🟥 Transfer Bus
- 🟩 GPU
- 🟥 Dynamic Memory
- 🟥 Flash EEPROM
- 🟥 ROM
- 🟧 Beacon Sensor
- 🟧 Locator
- 🟧 Target Finder
- 🟧 Waypoint
- 🟥 XYZ Beacon
- 🟩 CPU
- 🟩 Expression 2
- 🟩 Gates
- 🟥 PID
- 🟧 CD Disk
- 🟥 CD Ray
- 🟧 DHDD
- 🟥 Keycard
- 🟥 RAM-card
- 🟧 Satellite Dish
- 🟧 Store
- 🟧 Transferer
- 🟥 Wired Wirer
- 🟧 Adv Entity Marker
- 🟧 Damage Detector
- 🟧 Entity Marker
- 🟧 GPS
- 🟧 Gyroscope
- 🟥 HighSpeed Ranger
- 🟧 Laser Pointer Receiver
- 🟥 Microphone
- 🟧 Ranger
- 🟧 Speedometer
- 🟧 Water Sensor
- 🟧 7 Segment Display
- 🟥 Adv. Hud Indicator
- 🟧 Console Screen
- 🟧 Control Panel
- 🟧 Digital Screen
- 🟧 EGP v3
- 🟧 Fix RenderTargets
- 🟥 GPULib Switcher
- 🟧 Hud Indicator
- 🟧 Indicator
- 🟧 Lamp
- 🟧 Light
- 🟧 Oscilloscope
- 🟧 Pixel
- 🟧 Screen
- 🟧 Sound Emitter
- 🟧 Text Screen
- 🟩 Cam Controller
- 🟧 Colorer
- 🟧 FX Emitter
- 🟧 HighSpeed Holoemitter
- 🟧 HoloEmitter
- 🟧 HoloGrid
- 🟥 Interactable Holography Emitter
- 🟥 Materializer
- 🟥 Painter
- 🟧 Adv. Input
- 🟧 Button
- 🟧 Constant Value
- 🟥 Door Controller
- 🟧 Dual Input
- 🟧 Dynamic Button
- 🟧 Eye Pod
- 🟧 Graphics Tablet
- 🟧 Keyboard
- 🟥 Lever
- 🟧 Numpad
- 🟧 Numpad Input
- 🟧 Numpad Output
- 🟧 Plug
- 🟧 Pod Controller
- 🟧 Radio
- 🟧 Relay
- 🟧 Text Receiver
- 🟧 Two-way Radio
- 🟧 Vehicle Controller
- 🟥 Door
- 🟥 Adv. Dupe. Teleporter
- 🟥 Buoyancy
- 🟧 Clutch
- 🟧 Detonator
- 🟧 Explosives
- 🟧 Explosives (Simple)
- 🟥 Forcer
- 🟩 Freezer
- 🟧 Gimbal (Facer)
- 🟧 Grabber
- 🟧 Hoverball
- 🟧 Hoverdrive Controller
- 🟥 Hydraulic
- 🟧 Igniter
- 🟧 Nailer
- 🟩 Prop Spawner
- 🟥 Servo
- 🟥 Simple Servo
- 🟧 Thruster
- 🟥 Touchplate
- 🟥 Trail
- 🟩 Turret
- 🟩 User
- 🟥 Vector Thruster
- 🟥 Vehicle Exit Point
- 🟧 Weight (Adjustable)
- 🟧 Weld/Constraint Latch
- 🟥 Wheel
- 🟥 Wire Magnet
- 🟥 Wired Npc Controller
- 🟧 Debugger
- 🟥 GUI Wiring
- 🟥 Multi Wire
- 🟧 Namer
- 🟥 Simulate Data
- 🟩 Wiring
- 🟥 Beam Reader
- 🟥 Implanter
- 🟥 Reader
- 🟥 Target Filter
- 🟥 User Reader
Gates 🚥
Click To Expand
TBD