question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Quadratic processing time for array responses

See original GitHub issue

Consider the following contract:

contract Test {
  uint32 constant SIZE = // size here
  uint256[SIZE] private array;
  function get() external view returns (uint256[SIZE] memory) {
    return array;
  }
}

When SIZE is > ~1000 elements, the time spent waiting for a response to a web3 call() to get() starts to grow in a super-linear fashion.

NumElements: Time

1000: 1.0s 2000: 2.9s 3000: 5.6s 4000: 9.2s 5000: 13.9s 6000: 19.4s 7000: 25.9s

I’ve tested this both with the truffle web3js client as well as the rust-web3 client, both against ganache-cli and truffle develop and I see the same behavior. ganache-cli vs truffle develop have nearly the same response times, which makes leads me to believe there is some super-linear processing in ganache-core.

The cpu is spiked to 100% on a single core during the processing time.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
domohawkcommented, Aug 19, 2021

I can confirm that geth does not seem to have this growth behavior, it seems to grow pretty linearly.

geth 1.10.6-stable, (both websockets & http)

NumElements Time
1000 0.006s
5000 0.023s
25k 0.1s
50k 0.2s
100k 0.43s
500k 2.3s
1M 4.7s
0reactions
domohawkcommented, Aug 12, 2021

@davidmurdoch So using node v14 improves the times more, but still same growth behavior. Both websockets and http have the same times.

ganache@canary, node v14.17.5 (both websockets & http)

NumElements Time
1 0.015s
1000 0.8s
5000 4.0s
25k 25s
50k 68s
100k 251s
Read more comments on GitHub >

github_iconTop Results From Across the Web

How is union find quadratic algorithm? - java - Stack Overflow
Each invocation of union method requires you iterate over the id array, which takes O(n) time. If you invoke union method n times,...
Read more >
4.1 Analysis of Algorithms - Introduction to Programming in Java
The quadratic algorithm will be fastest for n up to about 1000, and the linear algorithm will never be faster than the linearithmic...
Read more >
Quadratic and Logarithmic Time Complexity - Data Structures ...
FREE Courses (100+ hours) - https://calcur.tech/all-in-ones Python Course - https://calcur.tech/python-courses✓ Data Structures ...
Read more >
Algorithms in plain English: time complexity and Big-O notation
O(n² ) — Quadratic Time: Given an input of size n, the number of steps it takes to accomplish a task is square...
Read more >
Signal Processing, IEEE Transactions on - CiteSeerX
quadratic processing is necessary for optimal performance. where is the length- complex array response vector. The vector contains all.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found