GithubHelp home page GithubHelp logo

Comments (4)

wcampbell0x2a avatar wcampbell0x2a commented on May 18, 2024 1

fyi: bitvec needs to use heavy usage of inline already to get decent performance: https://github.com/search?q=repo%3Aferrilab%2Fbitvec+inline&type=code

from deku.

hecatia-elegua avatar hecatia-elegua commented on May 18, 2024

I might have misunderstood deku's purpose. Is it really meant for any kind of bitfield?

Comparing asm output of some bitfields implemented in deku vs other bitfield crates, deku produces 20x more code.
This is, with deku = "0.16" using cargo-show-asm.

When looking at cargo expand, I noticed the cause is likely DekuRead and Co. not being const. It would be very interesting to see what happens if it were (nightly) const behind a feature gate.

could open another issue if you want

from deku.

wcampbell0x2a avatar wcampbell0x2a commented on May 18, 2024

When looking at cargo expand, I noticed the cause is likely DekuRead and Co. not being const. It would be very interesting to see what happens if it were (nightly) const behind a feature gate.

Could you explain the nightly feature and what this would do? I'm not familiar and curious.

from deku.

hecatia-elegua avatar hecatia-elegua commented on May 18, 2024

@wcampbell0x2a it could call all those trait methods at compile time if possible and/or optimize them out:
image
see feature const-trait-impl

I'm not sure how #[inline] interacts with this. I'm guessing if the call can't be optimized out at compile time, it inlines. It could also be the case that constness is only relevant to the crate where it is defined.
See the last line here (which I used on some From impls lately):

None: The compiler will decide itself if the function should be inlined. This will depend on factors such as the optimization level and the size of the function. Non-generic functions will never be inlined across crate boundaries unless link-time optimization is used; generic functions might be.

#[inline]: This suggests that the function should be inlined, including across crate boundaries.

Then again, I might have mixed this up (even non-const stuff can get computed at compile time), so if someone wants to go at this, it's probably best to first try to put #[inline] on those trait methods and compare asm outputs.
Edit: I quickly tried adding #[inline] to all the reads and writes in impls::primitives, it didn't inline (and I wouldn't use inline(always)).

from deku.

Related Issues (20)

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.