Coder Social home page Coder Social logo

Comments (19)

tsvayer avatar tsvayer commented on June 14, 2024 1

@dapi I understand you reasoning and mostly agree.
But to discuss anything concrete we need to create a well defined context. I am not aware of any usage of Futex and have no idea what Zold is. All I know is the list of features/requirements listed by an original author in Readme file of this repository and that is a context for me. If we are to question any specific usage of locking in general, then lets find a better context for it, maybe another issue under Zold repository.
As @yegor256 clearly stated here he has no plans to change feature list.

from futex.

dapi avatar dapi commented on June 14, 2024

Put it here: https://stackoverflow.com/questions/1632470/accessing-a-single-file-with-multiple-threads

from futex.

dapi avatar dapi commented on June 14, 2024

@yegor256 did you see this gem? https://github.com/sheerun/filelock

from futex.

yegor256 avatar yegor256 commented on June 14, 2024

@dapi yes, it's a good gem, but we need more logging. That gem won't report the cause of deadlock correctly. We need to know what's going on and why.

from futex.

yegor256 avatar yegor256 commented on June 14, 2024

@tsvayer maybe you can help us here?

from futex.

dapi avatar dapi commented on June 14, 2024

@yegor256 better way is to design application without mutex. Spend time to think how to do it rather than make you own bicycle.

For example Zoldy has stores that does not require a mutex at all - https://github.com/dapi/zoldy/tree/master/app/stores

from futex.

yegor256 avatar yegor256 commented on June 14, 2024

@dapi are you sure they are thread safe?

from futex.

dapi avatar dapi commented on June 14, 2024

Of course.

Give me described (human readable) usage example of mutex/futex in Zold and I show solution without it.

from futex.

yegor256 avatar yegor256 commented on June 14, 2024

@dapi just a list of remote nodes, as a simple file. How can you make it thread-safe without Mutex?

from futex.

dapi avatar dapi commented on June 14, 2024

One node - one file/directory by specific path. List of these directories is list of nodes.

screenshot 2018-12-26 at 09 17 08

from futex.

dapi avatar dapi commented on June 14, 2024

Create a directory when you met a node, save to it standalone file with score and errors log and so on.

from futex.

yegor256 avatar yegor256 commented on June 14, 2024

@dapi nice :) But then you need to update the information about this node. Say, you want to change the number of errors in the node. You will have to update the content of the file. How do you do that without Mutex?

from futex.

dapi avatar dapi commented on June 14, 2024

@yegor256 replied above )

screenshot 2018-12-26 at 09 24 42

score rewritten every time it comes
.error creates every time it comes and purges sometimes

from futex.

dapi avatar dapi commented on June 14, 2024

in any cases mutex is too common/standard/old method to do it yourself. It is better to find existing solutions and implementations

from futex.

yegor256 avatar yegor256 commented on June 14, 2024

@dapi well, yes, this is an option) You simply shift the synchronization problem to the file system. It will synchronize all operations for you. This will work, of course, but not always. What if you do need a file to be shared by multiple threads (like a wallet file). How will you synchronize access to it without Mutex?

from futex.

tsvayer avatar tsvayer commented on June 14, 2024

@dapi, @yegor256

https://github.com/sheerun/filelock provides ONLY exclusive locking. Futex provides both exclusive AND shared locking. This combination is where it becomes "complicated".
Additionally here is what it says about cleaning garbage:

How it's different from cleverua-lockfile gem?

Cleverua removes lockfile after unlocking it. Thas has been proven fatal both in my tests and in filelocking advices from the Internet. You could try find a way to remove lock file without breaking Filelock tests. I will be glad to accept such pull-request.

and cleverua-lockfile itself provides very simplistic exclusive locking, exactly what @tank-bohr shows in his comment. And this cleaning is where it becomes really complicated.

from futex.

dapi avatar dapi commented on June 14, 2024

@yegor256

You simply shift the synchronization problem to the file system.

Yeah. We use filesystem in any cases.

What if you do need a file to be shared by multiple threads (like a wallet file). How will you synchronize access to it without Mutex?

Tell real example scenario, please.

Here https://github.com/dapi/zoldy application stores wallet's copies in separate directories and create a symlink to best one. The name of a directory is a SHA digest of wallet's body. Every copy contains

screen shot 2018-12-26 at 17 13 43

from futex.

dapi avatar dapi commented on June 14, 2024

@tsvayer yeah.

I think today it is very suspiciously to make a custom mutex library.

I believe if we need to make our own mutex library than we do something wrong. Using mutex is critical to performance and it requires major attention. Probably we need to rethink application's design. There are many other solutions (redis as example).

As I see futex was born for Zold.

But Zold is not about mutexes. It is about safe micropayments and zold's developers must think about safety and payments and must not spent time to develop custom solution for typical situations.

Decision about custom mutexes usage could be delayed and this is why it must be delayed.

from futex.

tank-bohr avatar tank-bohr commented on June 14, 2024

🍿

from futex.

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.