Code Monkey home page Code Monkey logo

Comments (4)

cdkrot avatar cdkrot commented on May 22, 2024

I have looked over the defer.c's defer_perform_in_fork, and for me it seems, that the main culprit is defer.c:382

pids_count++;

This makes the loop under 'finish:' to fall over the allocated memory, deleting this line fixes the valgrind error.

Hope this helps :)

from facil.io.

boazsegev avatar boazsegev commented on May 22, 2024

Thanks 🙏🏻 🎉👍🏻👏🏻👏🏻

I re-read that piece of code and I have no idea what that line was doing there... 😂 I guess it was a leftover from a previous implementation.

Thank you very much for spotting it. 👍🏻

from facil.io.

cdkrot avatar cdkrot commented on May 22, 2024

Thank you for your work :)

Out of curiosity, why do you use hand-written spinlocks, and not mutexes?

from facil.io.

boazsegev avatar boazsegev commented on May 22, 2024

You're welcome :-)

why do you use hand-written spinlocks, and not mutexes?

It's a combination of performance testing and my own foolishness.

When I started the project, some of my design choices were a bit foolish and resulted in higher lock contention. Some of the lock contention issues couldn't be avoided (i.e. the defer library's queue access).

The original locking used mutexes and I noticed that mutexes were slower than I would like them to be. Something about the rescheduling mechanism was taking a long time to wake the threads up. Conditional variables weren't any better...

I tested it against spin locks using stdatomic.h . The spinlocks were noticeably faster for the defer queue (where contention can't be avoided).

But stdatomic.h wasn't available on Linux 14.04 (I was deploying on Heroku) so I just ended up writing the thing myself.

from facil.io.

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.