alexcasalboni / aws-lambda-power-tuning

AWS Lambda Power Tuning is an open-source tool that can help you visualize and fine-tune the memory/power configuration of Lambda functions. It runs in your own AWS account - powered by AWS Step Functions - and it supports three optimization strategies: cost, speed, and balanced.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

What is the URL hash algorithm?

dz902 opened this issue · comments

commented

Out of interest, what is the hash algorithm used? It seems to pack quite some data with very small size.

Thanks for the useful tool.

Hi @dz902 :)

The encoding is documented in the visualization repository: https://github.com/matteo-ronchetti/aws-lambda-power-tuning-ui

It's very simple, only the 3 series of numbers are serialized with a simple base64 encoding.

Something like this:

// encoding function
const computeHash = (powerValues, speedValues, costValues) => {
    return encode(powerValues, Int16Array) + ";" + encode(speedValues) + ";" + encode(costValues);
}

// power tuning results
let powerValues = [128, 256, 512, 1024, 1536];
let speedValues = [16.0, 8.0, 4.0, 2.8, 2.1];
let costValues = [0.01, 0.008, 0.005, 0.009, 0.012];

// URL hash
const hash = computeHash(powerValues, speedValues, costValues);

const fullURL = `${BASE_URL}#${hash}`;

The encoding is designed to be very generic, light, and anonymous (no references to function ARN's or Account ID's are included).

commented

Right...tried to base64 decode but got a bunch of binary gibberish, thought there were some compression or something. So it was indeed encoded using binary input.

Thanks! Will close this issue.