Skip to content

Commit

Permalink
feat(cu): remove metering flag, as this is instead controlled by modu…
Browse files Browse the repository at this point in the history
…le format in ao loader #1040

This reverts commit 4fdcbc4.
  • Loading branch information
TillaTheHun0 committed Oct 16, 2024
1 parent 258e733 commit 82658f4
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 15 deletions.
2 changes: 0 additions & 2 deletions servers/cu/src/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ export const createApis = async (ctx) => {
ctx.logger('Ignoring Arweave Checkpoints for processes [ %s ]', ctx.PROCESS_IGNORE_ARWEAVE_CHECKPOINTS.join(', '))
ctx.logger('Ignoring Arweave Checkpoints [ %s ]', ctx.IGNORE_ARWEAVE_CHECKPOINTS.join(', '))
ctx.logger('Trusting Arweave Checkpoint Owners [ %s ]', ctx.PROCESS_CHECKPOINT_TRUSTED_OWNERS.join(', '))
ctx.logger('Process metering applied set to "%s"', ctx.PROCESS_WASM_APPLY_METERING)
ctx.logger('Allowing only process owners [ %s ]', ctx.ALLOW_OWNERS.join(', '))
ctx.logger('Restricting processes [ %s ]', ctx.RESTRICT_PROCESSES.join(', '))
ctx.logger('Allowing only processes [ %s ]', ctx.ALLOW_PROCESSES.join(', '))
Expand Down Expand Up @@ -242,7 +241,6 @@ export const createApis = async (ctx) => {
fetch: ctx.fetch,
ARWEAVE_URL: ctx.ARWEAVE_URL,
WASM_BINARY_FILE_DIRECTORY: ctx.WASM_BINARY_FILE_DIRECTORY,
PROCESS_WASM_APPLY_METERING: ctx.PROCESS_WASM_APPLY_METERING,
logger: ctx.logger,
cache: WasmClient.createWasmModuleCache({ MAX_SIZE: ctx.WASM_MODULE_CACHE_MAX_SIZE })
})
Expand Down
2 changes: 0 additions & 2 deletions servers/cu/src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ const CONFIG_ENVS = {
PROCESS_WASM_COMPUTE_MAX_LIMIT: process.env.PROCESS_WASM_COMPUTE_MAX_LIMIT || 9_000_000_000_000, // 9t
PROCESS_WASM_SUPPORTED_FORMATS: process.env.PROCESS_WASM_SUPPORTED_FORMATS || DEFAULT_PROCESS_WASM_MODULE_FORMATS,
PROCESS_WASM_SUPPORTED_EXTENSIONS: process.env.PROCESS_WASM_SUPPORTED_EXTENSIONS || [],
PROCESS_WASM_APPLY_METERING: process.env.PROCESS_WASM_APPLY_METERING !== 'false',
WASM_EVALUATION_MAX_WORKERS: process.env.WASM_EVALUATION_MAX_WORKERS || Math.max(cpus().length - 1, 1),
WASM_EVALUATION_PRIMARY_WORKERS_PERCENTAGE: process.env.WASM_EVALUATION_PRIMARY_WORKERS_PERCENTAGE || 70, // 70% of worker threads allocated to primary workloads
WASM_EVALUATION_WORKERS_DRY_RUN_MAX_QUEUE: process.env.WASM_EVALUATION_WORKERS_DRY_RUN_MAX_QUEUE || 3000,
Expand Down Expand Up @@ -172,7 +171,6 @@ const CONFIG_ENVS = {
PROCESS_WASM_COMPUTE_MAX_LIMIT: process.env.PROCESS_WASM_COMPUTE_MAX_LIMIT || 9_000_000_000_000, // 9t
PROCESS_WASM_SUPPORTED_FORMATS: process.env.PROCESS_WASM_SUPPORTED_FORMATS || DEFAULT_PROCESS_WASM_MODULE_FORMATS,
PROCESS_WASM_SUPPORTED_EXTENSIONS: process.env.PROCESS_WASM_SUPPORTED_EXTENSIONS || [],
PROCESS_WASM_APPLY_METERING: process.env.PROCESS_WASM_APPLY_METERING !== 'false',
WASM_EVALUATION_MAX_WORKERS: process.env.WASM_EVALUATION_MAX_WORKERS || Math.max(cpus().length - 1, 1),
WASM_EVALUATION_PRIMARY_WORKERS_PERCENTAGE: process.env.WASM_EVALUATION_PRIMARY_WORKERS_PERCENTAGE || 70, // 70% of worker threads allocated to primary workloads
WASM_EVALUATION_WORKERS_DRY_RUN_MAX_QUEUE: process.env.WASM_EVALUATION_WORKERS_DRY_RUN_MAX_QUEUE || 3000,
Expand Down
4 changes: 0 additions & 4 deletions servers/cu/src/domain/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@ export const domainConfigSchema = z.object({
* The wasm extensions that this CU supports
*/
PROCESS_WASM_SUPPORTED_EXTENSIONS: commaDelimitedArraySchema,
/**
* Whether or not to apply metering to the wasm execution
*/
PROCESS_WASM_APPLY_METERING: z.preprocess((val) => !!val, z.boolean()),
/**
* The url for the graphql server to be used by the CU
* to query for metadata from an Arweave Gateway
Expand Down
11 changes: 4 additions & 7 deletions servers/cu/src/effects/wasm.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,12 @@ export function bootstrapWasmInstanceWith () {
}
}

export function loadWasmModuleWith ({ fetch, ARWEAVE_URL, WASM_BINARY_FILE_DIRECTORY, PROCESS_WASM_APPLY_METERING, logger, cache }) {
export function loadWasmModuleWith ({ fetch, ARWEAVE_URL, WASM_BINARY_FILE_DIRECTORY, logger, cache }) {
const streamTransactionData = fromPromise(streamTransactionDataWith({ fetch, ARWEAVE_URL, logger }))
const readWasmFile = fromPromise(readWasmFileWith({ DIR: WASM_BINARY_FILE_DIRECTORY }))
const writeWasmFile = writeWasmFileWith({ DIR: WASM_BINARY_FILE_DIRECTORY })

const compileStreaming = (stream, moduleOptions) => WebAssembly.compileStreaming(
wasmResponse(stream),
{ ...moduleOptions, applyMetering: PROCESS_WASM_APPLY_METERING }
)
const toWasmResponse = (moduleOptions) => fromPromise((stream) => WebAssembly.compileStreaming(wasmResponse(Readable.toWeb(stream), moduleOptions)))

function maybeCachedModule (args) {
const { moduleId } = args
Expand All @@ -155,7 +152,7 @@ export function loadWasmModuleWith ({ fetch, ARWEAVE_URL, WASM_BINARY_FILE_DIREC

return of(moduleId)
.chain(readWasmFile)
.chain(fromPromise((nStream) => compileStreaming(Readable.toWeb(nStream), moduleOptions)))
.chain(toWasmResponse(moduleOptions))
.bimap(always(args), identity)
}

Expand All @@ -172,7 +169,7 @@ export function loadWasmModuleWith ({ fetch, ARWEAVE_URL, WASM_BINARY_FILE_DIREC
.chain(fromPromise(([s1, s2]) =>
Promise.all([
writeWasmFile(moduleId, Readable.fromWeb(s1)),
compileStreaming(s2, moduleOptions)
WebAssembly.compileStreaming(wasmResponse(s2), moduleOptions)
])
))
.map(([, res]) => res)
Expand Down

0 comments on commit 82658f4

Please sign in to comment.