4

Suppose I have a long array of values:

x = [1, 2, 3, ..., N] # shape [N, ] array

and a function

def f(x):
    return x ** 2

then I'd do something like (similar to python's multiprocessing)

with SmartContractPool(N) as p:
    p.map(f, x)

and the x would now be

x = [1, 4, 9, ..., N^2].

This would be O(N) as a sequential operation, but obviously O(1) on N smart contracts/ nodes each implementing f asynchronously and in parallel.

This would require that x is in fact some kind of a shared storage variable accessible by all the nodes.

Probably this will never be possible on L1 but I can't see why it wouldn't be possible on e.g. zk rollups, i.e. there will simply be a proof that everything was computed correctly.

Motivation: this is basically how linear algebra ops are parallelized on thousands of GPU cores, see e.g. here how to do an array sum in log_2(N) time instead of O(N) on a GPU with CUDA C. This would be the only sensible way to some day run neural networks in Ethereum L2.

1

2 Answers 2

0

I don't have a concrete answer to the original question - nobody does, really. Parallelism isn't exactly the focus at the moment and I don't believe it's specifically on the roadmap

That said, there's actually a good twitter thread by Brock Elmore from Nascent on the potential speed-up of a parallel EVM and the issues it faces

An important thing to point out though

This would be O(N) as a sequential operation, but obviously O(1) on N smart contracts/ nodes each implementing f asynchronously and in parallel.

You're right that the time execution takes would go from O(N) -> O(1), but that doesn't mean the cost would go down by a factor of N. You aren't using less resources by parallelizing, you're actually likely using more resources by parallelizing it

Execution time is of course part of the cost, but the resource usage (and the resources usage overhead added by parallelism) must be accounted for as well

-2

The EVM is actually multithreading because it runs on any machine, even your own so you can write multithreaded code. Also Vyper is just python so you can just use multithreading or multiprocessing library in ethireum!

1
  • 1
    None of this is true...
    – natewelch_
    Commented Aug 30, 2022 at 19:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.