4,235 karma · joined Sep 10, 2015 (11y ago) · 1,525 submissions
comment 2y ago · link · parent
Assuming you use a set of slabs of fixed size objects and keep free objects in a linked list, both malloc and free are trivial O(1) operations.
Destructors with cascading deletions can take time bounded only by memory allocation, but you can solve that for instance by destroying them on a separate thread, or having a linked list of objects to be destroyed and destroying a constant number/memory size of them on each allocation.
comment 2y ago · link · parent
Since it's not needed and it's massively worse than reference counting (assuming you only change reference counts when essential and use borrowing normally) due to the absurd behavior of scanning most of the heap at arbitrary times, there is no Rust GC crate in widespread use.
comment 2y ago · link · parent
Assuming they can get their game discovered via some sort of non-store channel (e.g. Reddit, social media, YouTube, Twitch, ads, etc.), the user can simply search the web for the game, find the website, click "buy" and proceed.
Probably a bit more work than publishing on Steam but not that much. Seems worth it for large budget games or games that are very popular in a specific niche discoverable outside Steam.
comment 2y ago · link · parent
It seems that dry ice has 571 kJ/kg latent heat at -78.5 C sublimation, while lithium batteries have around 250 Wh/kg = 900 kJ/kg, but with batteries you have the extra weight of the refrigeration system plus whatever loss of efficiency it causes, as well as the risk of mechanical/electrical failure.
It seems that charging batteries is much cheaper though, with dry ice seemingly going for 2-6$/kg and electricity 0.1688 $/kWh = 0.04$/kg to charge batteries.
comment 2y ago · link · parent
If you know the set of locks ahead of time, just sort them by address and take them, which will always succeed with no deadlocks.
If the set of locks isn't known, then assign each transaction an increasing ID.
When trying to take a lock that is taken, then if the lock owner has higher ID signal it to terminate and retry after waiting for this transaction to terminate, and sleep waiting for it to release the lock.
Otherwise if it has lower ID abort the transaction, wait for the conflicting transaction to finish and then retry the transaction.
This guarantees that all transactions will terminate as long as each would terminate in isolation and that a transaction will retry at most once for each preceding running transaction.
It's also possible to detect deadlocks by keeping track of which thread every thread is waiting for and signaling the either the highest transaction ID in the cycle or the one the lowest ID is waiting for to abort, wait for ID it was waiting for terminate and retry.
comment 2y ago · link · parent
1. Using a proper programming language that doesn't allow you to setup arbitrary functions as signal handlers (since that's obviously unsafe on common libcs...) - e.g. you can't do that in safe Rust, or Java, etc.
2. Using a well-implemented libc that doesn't cause memory corruption when calling async-signal-unsafe functions but only deadlocks (this is very easy to achieve by treating code running in signals as a separate thread for thread-local storage access purposes), and preferably also doesn't deadlock (this requires no global mutexes, or the ability to resume interrupted code holding a mutex)
3. Thinking when changing and accepting code, not like the people who committed and accepted [1] which just arbitrarily removes an #ifdef with no justification
4. Using simple well-engineered software written by good programmers instead of OpenSSH
comment 2y ago · link · parent
The 630g Anker 737 PowerCore 24K might be a good option, and also the 765g HyperJuice 245W.
So this adds 0.3-0.45kg to the estimate.
comment 2y ago · link · parent
- Car campers, vanlifers or people living in a place permanently, which can just use the heavy Starlink version or go where there is LTE coverage
- Thru-hikers who hike every waking hour and want to be as light as possible and for which this system isn't even remotely light enough
- Casual weekend hikers for which it's going to be too expensive and also unnecessary since they'll have Internet access on Monday again.
It's only really a consideration for those who regularly go on multiweek trips or live long-term in the wilderness and move camp on a weekly/monthly frequency (rather than daily or never), and these people seem to be relatively rare.
comment 2y ago · link · parent
From an individual perspective, if you want Internet access and don't have to be in a specific place, the current alternative to Starlink is to simply limit your wilderness living to places with or near areas of cell phone coverage (which potentially results in tradeoffs, of course).
comment 2y ago · link · parent
- FlexSolar 40W panel: 1.35kg
- Nitecore NB20000 ~75Wh battery: 300g
- Starlink Mini: 1.1kg
- Smartphone: 250g
For 3kg you have something that should give 2-3 hours of Internet usage on an average EU/USA good weather day (assuming 20% solar panel for 10 hours = 80Wh/day, 25-35W power usage of Starlink Mini + smartphone).
For each extra 1.65kg you get an additional 2-3 hours, resulting in 7.95kg for 8-12 hours, 11.25kg for 12-16 hours.
Not bad, but not good either.
comment 2y ago · link · parent
If that's your identity, then not being able to solve hard Leetcode problems (which, to my knowledge, are not even actually hard, since they seem to be easier than the problems in actual top competitions like the IOI, ICPC, etc.) is completely unacceptable and thus you will study and practice relentlessly until you manage (if you can); conversely, if that's not your identity, it's probably going to be hard to find the motivation to do so.
comment 2y ago · link · parent
This essentially turns GraphQL into a DSL for implementing REST endpoints, which is still a useful thing since it allows to write the REST endpoint with only knowledge of the GraphQL API rather than knowledge of the whole backend architecture, which is generally useful if the backend and frontend are written by different people or teams.
That's the way Facebook uses it on their main website: they pass the query id in the "doc_id" form field, the arguement in the "variables" field, the server gets the actual GraphQL query based on the doc_id from some sort of internal dictionary and AFAIK no GraphQL query string ever goes on the wire in production.
comment 2y ago · link · parent
But Falcon 9 seems to cost $40-60 million and carries 200 tons of RP-1 which seems to cost $200-500k, and all other costs should either be small or removable by automation, so the reusable part is actually up to 98-99%, not 30%.
Of course if you just flush boatloads of money down the drain for each launch for no reason, reusing the booster doesn't change much.
Also in general that sort of mathematical modelling is usually worse than useless since the output is usually a straightforward function of the assumptions and the model just makes bullshit assumptions seem more legitimate.
comment 2y ago · link · parent
Presumably and perhaps more compatibly can also call the DOS function with interrupts disabled but with an interrupt line active (e.g. a timer) and handle it.
comment 2y ago · link · parent
Which includes "go to any website and run any app I can download from it, regardless of whether it's illegal or against any rules or against the interests of the phone maker" and "change any aspect of functionality that I don't like (e.g. apps being able to show ads) and that I can find out on the web how to change".
It doesn't include "Google or Apple make rules about what I can do with my phone that I can't override".
comment 2y ago · link · parent
In my view, my phone is MY DEVICE. It is most definitely not "Google/Apple's platform"!
Google is merely manufacturing my phone, and I intend Google to have no rights or control whatsoever regarding my phone, and merely have the obligation (not right, obligation) to manufacture it correctly and provide open-source software for it that works correctly and properly provides Android interfaces (obviously, I don't use an Apple phone since Apple doesn't offer that, while Google does since they provide devices with unlocked bootloaders that run open-source OSes).
It only runs Android because Google with Android happened to win the adoption lottery and it would run PodunkOS by ACME if PodunkOS by ACME had been the one that managed to gain critical mass.
Again it is absolutely not even remotely close to "Google/Apple's platform", and I have no intention for Google to interfere in my use of it and certainly not interfere in any relations I might have with people providing software for my phone like taking a cut of the transaction or deciding how that software should behave.