• 0 Posts
  • 620 Comments
Joined 2 years ago
cake
Cake day: June 21st, 2023

help-circle


  • Tokio’s broadcast module is a mpmc messaging queue.

    The terms “mpsc” and “mpmc” refer to how the channels can be used. Breaking down the letters, there are two sides to a channel:

    • p is producer, or transmitter/sender. This side sends data
    • c is consumer, or receiver/reader. This side receives data.

    Data only flows one way through a channel. Each side may have a restriction on how many members can be on that side:

    • s is single, so this side cannot be cloned. You only have one object that can interact with this side (so only one sender or only one receiver)
    • m is multiple, so this side can be cloned. Any number of objects can exist that interact with this side (so a bunch of simultaneous senders or receivers)

    A mpsc channel can only have one consumer, so only one thread can receive messages at a time, and it can only receive those messages once.

    A mpmc channel can have many consumers, so multiple threads can receive messages at once, and a thread can receive a message multiple times (through multiple receivers).

    Both can have multiple simultaneous producers.



  • When you tariff them by over 100% of their value, they tend to cost more to import.

    My whole comment was on the tariffs specifically, and there is a 100% chance they affect sales in the US. Even with cost reductions in manufacturing over the total lifetime of the console, there’s no chance they cut costs enough to keep up with the tariffs, and there is no chance they planned for the tariffs to be this high in their planning.

    Outside the US? These tariffs aren’t applied, but raising the prices globally limits the impact of them on one of their largest markets since they can amortize the cost across all their markets instead of just one.


  • If you are new to something and want to learn, seek resources and educate yourself with them. Learning takes time, and there are no shortcuts.

    A hot DB should not run on HDDs. Slap some nvme storage into that server if you can. If you can’t, consider getting a new server and migrating to it.

    SQL server can generate execution plans for you. For your queries, generate those, and see if you’re doing any operations that involve iterating the entire table. You should avoid scanning an entire table with a huge number of rows when possible, at least during requests.

    If you want to do some kind of dupe protection, let the DB do it for you. Create an index and a table constraint on the relevant columns. If the data is too complex for that, find a way to do it, like generating and storing hashes, sorting lists/dicts, etc just so that the DB can do the work for you. The DB is better at enforcing constraints than you are (when it can do so).

    For read-heavy workflows, consider whether caches or read replicas will benefit you.

    And finally back to my first point: read. Learn. There are no shortcuts. You cannot get better at something if you don’t take the time to educate yourself on it.





  • For your second part:

    A lot of open source projects exist to make people’s lives easier at work. The people developing these projects are often also people who have jobs as devs and have a use for the projects. It just so happens that it’s easier to use these libraries at work and share them with others when they’re more permissively licensed, and there are community benefits when people all contribute back to it.

    There’s nothing wrong with wanting to go the AGPL route and forcing everyone into open source, but that makes it much harder to use these tools at work, which often kills the motivation behind building them in the first place.

    I tend to be of the opinion that community tools should be GPL/AGPL, while libraries can be anything. It works as a compromise for both - so devs can have an easier time at work while also forcing contributions back to community-developed tools.

    Edit: I should also mention dual licensed AGPL/paid commercial. That model is probably my favorite, but unfortunately uncommon.





  • TehPers@beehaw.orgtoProgramming@programming.devThe Innocent Loop
    link
    fedilink
    English
    arrow-up
    2
    ·
    edit-2
    16 days ago

    This seems to me more like a complaint about JS’s functional methods on arrays being eager rather than a complaint about loops. All of this is solved in languages with iterators (or async iterators for a potentially better solution).

    For example, in C#, .Where does nothing immediately on enumerable types, and on IAsyncEnumerable, you can go as far as streaming/chunking results from a DB into the enumerable and filtering off the DB asynchronously just by passing the enumerable into an await foreach. In Rust, you get the same options (though more verbose) using streams from futures.

    Edit: the rest of the article doesn’t really have much to do with loops, but these are all solved problems in C#, Rust, and I assume other languages too. Even Python has iterables, and you can configure your thread pools however you want to for concurrency.