Code Monkey home page Code Monkey logo

Comments (7)

IllIllI000 avatar IllIllI000 commented on August 16, 2024 1

the issue referenced mentions that memory is cheaper if you access more than once, but if you're accessing more than once, you should be using a stack variable anyway. I'll try to come up with some test cases to tease out when it make sense to use one vs the other

from 4naly3er.

CodeSandwich avatar CodeSandwich commented on August 16, 2024 1

@IllIllI000 I think that your results are spot on, memory only makes sense for types smaller than the word.

I've tried doing some benchmarks myself and for arrays of uint256 calldata was always cheaper no matter how many times the array was accessed, and for uint248 or smaller memory was always cheaper. It's also true for bytes, they are marginally cheaper as calldata. Out of curiosity I've tried uint256[][], and still calldata is cheaper.

from 4naly3er.

Picodes avatar Picodes commented on August 16, 2024

@IllIllI000 I am definitely interested in such test cases

from 4naly3er.

IllIllI000 avatar IllIllI000 commented on August 16, 2024

please remind me after March 25th (GMX contest end)

from 4naly3er.

InfectedIsm avatar InfectedIsm commented on August 16, 2024

@IllIllI000

⏰ it's after March 25th (sorry was reading the issues and maybe you still want to be reminded lol)

from 4naly3er.

IllIllI000 avatar IllIllI000 commented on August 16, 2024

Ah, thanks I did indeed forget. Still busy with other work, but won't submit this finding again until I have it worked out

from 4naly3er.

IllIllI000 avatar IllIllI000 commented on August 16, 2024

@CodeSandwich do you have an example where memory is cheaper than calldata when the array isn't an array where each array value is smaller than a word? That's the only type of scenario for which I was able to reproduce it: https://gist.github.com/IllIllI000/2ac9a647be917f58ffe5baa2cecbbc42

from 4naly3er.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.