You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
There's a 30% overhead cost converting things back a forth to wasm friendly formats
For context this is only really noticeable when loading states from disk where the full BeaconState has to be hashed. There the saving are in the order of 1s -> 0.7s. However when signing gossip messages the savings are not too significant. Maybe they will be to hash full large ExecutionPayloads.
Summary: cool optimization, not high priority
Describe the solution you'd like
enumHashInputType{HashObject,Uint8Array,Uint64,}typeHashInput=|{type: HashInputType.HashObject;hashObject: HashObject}|{type: HashInputType.Uint8Array;uint8Array: Uint8Array}|{type: HashInputType.Uint64;uint64: number};enumHashOutputType{HashObject,Uint8Array,}functionsetHashInput(input: HashInput,offset32: number): void{switch(input.type){caseHashInputType.HashObject: {constoffset4=offset32*8;const{hashObject}=input;inputUint32Array[offset4+0]=hashObject.h0;inputUint32Array[offset4+1]=hashObject.h1;inputUint32Array[offset4+2]=hashObject.h2;inputUint32Array[offset4+3]=hashObject.h3;inputUint32Array[offset4+4]=hashObject.h4;inputUint32Array[offset4+5]=hashObject.h5;inputUint32Array[offset4+6]=hashObject.h6;inputUint32Array[offset4+7]=hashObject.h7;break;}caseHashInputType.Uint8Array: {inputUint8Array.set(input.uint8Array,offset32*32);break;}caseHashInputType.Uint64: {constoffset4=offset32*8;constoffset1=offset32*32;inputDataView.setUint32(offset1,input.uint64&0xffffffff,true);inputDataView.setUint32(offset1+4,(input.uint64/NUMBER_2_POW_32)&0xffffffff,true);inputUint32Array[offset4+2]=0;inputUint32Array[offset4+3]=0;inputUint32Array[offset4+4]=0;inputUint32Array[offset4+5]=0;inputUint32Array[offset4+6]=0;inputUint32Array[offset4+7]=0;}}}exportfunctiondigest64TypedData(input1: HashInput,input2: HashInput,outputType: HashOutputType.HashObject): HashObject;exportfunctiondigest64TypedData(input1: HashInput,input2: HashInput,outputType: HashOutputType.Uint8Array): Uint8Array;/** * Digest 2 objects, each has 8 properties from h0 to h7. * The performance is a little bit better than digest64 due to the use of Uint32Array * and the memory is a little bit better than digest64 due to no temporary Uint8Array. * @returns */exportfunctiondigest64TypedData(input1: HashInput,input2: HashInput,outputType: HashOutputType): HashObject|Uint8Array{setHashInput(input1,0);setHashInput(input2,1);ctx.digest64(wasmInputValue,wasmOutputValue);switch(outputType){caseHashOutputType.HashObject:
// extracting numbers from Uint32Array causes more memoryreturnbyteArrayToHashObject(outputUint8Array);caseHashOutputType.Uint8Array:
// TODO: Benchmark fastest way to copy bytesreturnoutputUint8Array.slice(0,32);}}
Is your feature request related to a problem? Please describe.
There's a 30% overhead cost converting things back a forth to wasm friendly formats
For context this is only really noticeable when loading states from disk where the full BeaconState has to be hashed. There the saving are in the order of 1s -> 0.7s. However when signing gossip messages the savings are not too significant. Maybe they will be to hash full large ExecutionPayloads.
Summary: cool optimization, not high priority
Describe the solution you'd like
Additional context
From #244
The text was updated successfully, but these errors were encountered: