A question about nanos performance

Recently I conducted an experiment where I measured energy used by docker image, and nanos unikernel.

I used a few benchmark functions, bubble sort, merge sort, a loop of hashing, etc. and saw significant improvement in bubble sort and merge sort execution time with low energy consumption.

, similar profile shows in merge sort as well. In the loop of hashing, it also shows less energy consumption. However, nanos also performes less cycles than docker.

Attached is the graph of energy profile and cycle completed.


here is the function.

    function performComplexHash(input) {
        let currentHash = input;
        const hash = crypto.createHash(hashTypes[0]);
        hash.update(currentHash);
        currentHash = hash.digest('hex');
        currentHash = currentHash.split('').reverse().join('');
        currentHash = Buffer.from(currentHash).toString('base64');

        return currentHash;
    }

 while (performance.now() - startTime < durationMs) {
        lastHash = performComplexHash(lastHash);
        iterations++;
    }

what could be the possible reason for such behaviour?

While this is interesting to see - it’s kind of hard to tell from only what you posted. It’s also kind of unclear how you’re measuring energy consumption unless that’s really just cycles used?

I assume you’re comparing a node.js docker image to a node.js unikernel? Are you measuring the starting time? If os perhaps what you are seeing is that just more files are being loaded and that takes more time.

Using something like perf might give a bit more information.

yes, I am measuring node js docker vs nodejs unikernel.

for the energy measurement, I am using MODBUS tcp supported wattmeter, that gives me reading every 60 ms. The measurement starts when I send request to the api (docker / unikernel), and ends in 1 minute after receiving 200 ok. Then I calculate the energy with formula E = sum(P * interval ).

The measurement is being taken on a completely different device. both unikernel and docker has the same files and CPU/memory bound. (1 core, 2 gb, and unikernel is accererated)

what seems to me is for iterative tasks with low depth of workload draws less energy in unikernel for the streamlined structure, where docker needs to draw energy more aggresivly, due to additional layers.

but it doesn’t make any sense when it comes to the hashing loops. (please note that the hash function is looping for a given time around 60 sec or so. )

If you’re including the network request you might see different results depending on how that is setup. There could be differences if tap devices are being used vs usermode networking or if you are going through k8s vs docker.

Also - are both of these running on linux? You mentioned the unikernel is using hardware accel - is the docker image as well? The hash could be using instructions that are only available for native deploys.

Both unikernel and docker was deployed in a desktop with ubuntu server.
I don’t know if docker is taking any advantage from the linux kernel or something

@eyberg One thing to mention the execution time of the sorting functions are very low compared to docker, but semiprime finding (in a given range), and recursive fibonacchi shows somewhat similer energy profiile.

It’s kind hard to drill into what you’re seeing without having the exact setup you’re using. Are they both using bridges? When you say the files are the same - are you saying the entire filesystem is precisely the same or just your test scripts - that can add a significant source of load time which could add a lot more cycles.