GithubHelp home page GithubHelp logo

Comments (6)

dharmit avatar dharmit commented on May 27, 2024

Ah, I found #14 after opening the issue. I had searched only in the issues, not in PRs. :)

I modified the code to use defer everywhere and found that the performance reason still holds true at few places.

from golang-set.

deckarep avatar deckarep commented on May 27, 2024

from golang-set.

dharmit avatar dharmit commented on May 27, 2024

Also, since a lot of locking/unlocking is already small in scope (very small functions) it’s easy to see that defer is practically unnecessary anyway.

Indeed! And this is something I had in the back of my mind while opening the issue, that it's not a big deal to not have defer because of the size of the functions. But I found a few occurrences of defer so asked here nonetheless.

But defer's performance penalty was definitely a TIL for me. :)

from golang-set.

deckarep avatar deckarep commented on May 27, 2024

from golang-set.

Darkheir avatar Darkheir commented on May 27, 2024

I think that since go 1.14 defer doesn't bring any performance penalty:

This release improves the performance of most uses of defer to incur almost zero overhead compared to calling the deferred function directly. As a result, defer can now be used in performance-critical code without overhead concerns.

Anyway this lib was created long before the 1.14 release :)

from golang-set.

deckarep avatar deckarep commented on May 27, 2024

I remember this release and the Go team claiming this but later it was actually revealed with more analysis that defer does still have some non-negligible overhead.

At some point I’ll check into this again.

from golang-set.

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.