HNHacker News
TopNewBestAskShowJobs

charleslmunger

1,327 karma · joined March 3, 2013

submissionscomments
charleslmunger··on FCC Bans Authorizations for Devices That Pose National Security Threat
>How do we know that the Cisco equipment also isn't backdoored and if I send a few malformed TCP packets it opens up its control plane on the receiving port?

Nothing so sophisticated is required. Look at the sheer number of "default credential" and "static credential" for a whole variety of products:

https://cve.mitre.org/cgi-bin/cvekey.cgi?keyword=Cisco+crede...

charleslmunger··on FTX fiasco sparks billions of dollars of outflows from exchanges
Does uniswap actually have a pair with USD, or is it "USD" that's actually a token someone else promises is redeemable for USD?
charleslmunger··on In defense of linked lists
I did this for an object pool in re2j and saw even single threaded performance improve.

https://github.com/google/re2j/blob/dc7d6e5d41225dc0825ea6fe...

Java doesn't suffer from pointer address ABA but I did have to handle reinsertion (except when the stack had only one element).

charleslmunger··on Dozens of malicious PyPI packages discovered targeting developers
And it didn't really work in practice. Every callback or thread hop is a security vulnerability by default.
charleslmunger··on Ask HN: Are there recorded instances of people being framed through hacking?
https://www.nytimes.com/2016/12/09/world/europe/vladimir-put...
charleslmunger··on A Cheap 2.5GbE PoE Unmanaged Switch
The normal way to do this is to get a dodgy CCA cable with insulation that is not riser rated, and run a bundle of them together into a wall.
charleslmunger··on Show HN: RankedVote – SurveyMonkey but focused on ranked-choice voting
Not all ranked choice methods are identical - if you're interested in this topic, check out https://www.researchsquare.com/article/rs-2026611/latest.pdf
charleslmunger··on Ask HN: Books on designing disk-optimized data structures?
Write amplification is a concern on flash memory. The other secret is that just like flash didn't eliminate the cost of seeks, RAM isn't as fast for random access as sequential. All modern systems benefit from data locality, to varying degrees.

A CPU has layers of caches in front of memory, which then has its own caches on front of NVMe, which has its own controller usually with an SLC cache in front of MLC, which often times is being used as a cache on front of the network or slower storage.

For many problems modern hardware is fast enough, but if your problem is attempting to make use of all modern hardware offers, you need to optimize for it. Meaningfully saturating a 100gbps network connection, for example, is hard to do without considering data locality.

charleslmunger··on Wildfire smoke is exposing millions of Americans to extreme pollution levels
For a specific recommendation try the 3M HF-800 series with p100 filters. The silicone is very comfortable and it has a button for self-fit-test, which allows you to loosen the straps while remaining confident that you are protected. The large amount of filter surface area results in very low breathing resistance, and the exhalation valve improves comfort for extended wear.
charleslmunger··on Wildfire smoke is exposing millions of Americans to extreme pollution levels
If you don't mind looking like a comic book villain, try the 3M HF-800 series with p100 filters. The silicone is very comfortable and it has a button for self-fit-test, which allows you to loosen the straps while remaining confident that you are protected. The large amount of filter surface area results in very low breathing resistance, and the exhalation valve improves comfort for extended wear.
charleslmunger··on Ask HN: Expert Advices for New Learners in Android Kotlin Development?
The best pieces of advice that I can share from experience:

Do not do eager work at process startup (application onCreate, content provider onCreate, etc). Your process starts up for many different reasons, and work done there except for a narrow subset (crash reporting setup) is unlikely to apply to all of them. However, once the code is there it's hard to find what else might be depending on it later.

Do not use inheritance to share code. Androids APIs were designed to point you in this direction, but overrides upon overrides will make your life miserable. Once you have a base class from Hilt or AppCompat to provide composition for you (via DI or lifecycle), add no further layers of inheritance.

Avoid the event bus pattern. It was fashionable for a while but it turns the codebase to spaghetti. It tends to make error handling impossible or at least convoluted and debugging is a huge challenge.

charleslmunger··on Ask HN: What are some cool but obscure data structures you know about?
Another option that makes appends cheaper would be to use a Treiber stack (one acquire, one release!), but maintain a separate path for readers. When pushing, do a read (acquire) of the tail, then set (relaxed) a back link on the second-from-top element pointing to the current top, then CAS (release) to push your node. Since the back link will always write the same value, it's ok for contending writers to submit racing writes.

Readers start by reading the tail(acquire) and storing a pointer to the node before it. They then traverse from head until they reach the node before the tail, then skip reading its back link pointer (as they already know it will point to the tail).

charleslmunger··on Ask HN: What are some cool but obscure data structures you know about?
I think this can be done completely lock free with almost same number of memory barriers as a mutex when writing - read the tail pointer (acquire), append your node using CAS(release), then update the tail pointer with CAS (release).

For reads, start with an acquire read of the tail pointer, which will make all preceding writes to the list visible to you. Then you can read the list all you want up until you hit the node you read from the tail pointer without synchronization.

charleslmunger··on My Preferred Smart Home Vendors
Interesting that open source stuff (like tasmota for sonoff devices is not mentioned - a number of OEMs offer pre flashed devices. Athom, Kauf, cloudfree, and Martin Jerry just to name a few. These are wonderful to use with home assistant.

Similarly, I've had real trouble with some reolink products - they're very cheap, but have codec issues. Were I buying cameras again I'd go with amcrest, which are mostly white label dahua.

charleslmunger··on Don’t mock what you don’t own
Check out this[1] API for enforcing rules like this in your codebase.

[1] https://javadoc.io/doc/org.mockito/mockito-core/latest/org/m...

charleslmunger··on Setting up a Pi Hole made my home network faster
Very likely URL.equals()
charleslmunger··on PSA: HelloFresh doesn't delete data when asked, only changes the email address
I have no knowledge of how Facebook or anybody else does their backup deletion - but one way to accomplish this is to encrypt parts of the backups with a per user key, and delete the key when deletion is requested - tapes (or whatever) stay in cold storage but the data is irretrievable.
charleslmunger··on Overhauling Mario 64's code to reach 30 FPS and render 6x faster on N64 [video]
It depends what you're optimizing. Mature c++ codebase that is routinely profiled? Large legacy codebase with few tests? Mixed workloads?

All hard. But there's also a lot of easy cases out there - even good engineers might code like monkeys if they're under time pressure and trying to grow the business.

I've done a lot of performance work, and while of course no one individual could achieve a 1% savings per month on the entirety of FAANG compute loads, there is lots of code out there that nobody thought would run at scale or be on the critical path of something important, but now it is and it has gotten expensive.

charleslmunger··on Overhauling Mario 64's code to reach 30 FPS and render 6x faster on N64 [video]
Improvements are one-time investments of engineering time, but ongoing savings in infra costs. Consider also that these savings also permit scaling to more customers or more work.

Suppose you have two engineers that total to $1M of personnel cost. If they deliver a cost savings of 1% per month (compounding) the savings-per-month will have surpassed their pay per month; you will see your infra costs at 85% of what they were after 16 months, and on month 17 you will have made a net profit on those engineers, where the savings they got you has totalled more than what you've paid them.

If your business is growing, you could project your infra costs to grow beyond $1M per month, and the numbers become even more favorable.

charleslmunger··on Why and how we use primitive maps
Indeed, although userspace spinlocks are almost always a bad idea, it's possible to write a much better one than repurposing ReadWriteLock.

1. As you say, use onSpinWait

2. It emits a load barrier on each failed trylock call, from the underlying strong integer CAS. Ideally it would use a cas with relaxed memory order, and use an acquire fence only if successful.

3. The read path emits store barriers on release, which is unnecessary. Releasing could use a relaxed order fetch-add instruction.

It's theoretically possible that the JIT would be smart enough to optimize these with the existing code, but that's asking a lot from its analysis, including that the thread local storage writes for detecting reentrance aren't "real" writes that need to be made visible to other threads.

charleslmunger··on Concurrency in Java – I came up with a design I feel comfortable with
I prefer Guava's ListenableFuture for java concurrency. No reason to use http or json for in-process work.
charleslmunger··on I used Apple AirTags, Tiles and a GPS tracker to watch my husband’s every move
If you're interested in local control and open source:

https://circuitsetup.us/

charleslmunger··on Ask HN: Electic car (new) in Italy for 3000€ only. State pays 85%: is it sane?
Internal Combustion Engine
charleslmunger··on Almost Always Unsigned
This is true, but if your runtime is actually running stack-based interpretation of your java code (rathe than JIT) you have bigger performance problems.

    static int square(int);
       0: iload_0
       1: iload_0
       2: imul
       3: ireturn
is java; compare to the c++ equivalent (used unsigned to avoid any possibility of undefined behavior):

    unsigned char square(unsigned char num) {
      return num * num;
    }
Which compiles to:

        mov     eax, edi
        imul    eax, edi
        ret
on x86

        mul     w0, w0, w0
        ret
on arm.

By this definition, c and c++ don't have "real" byte types either, because they undergo integer promotion for operations, and the generated code is operating on register sized values, not bytes. Java bytes use 8 bits as part of an object (with a fixed-cost padding); 8 bits as part of an array, etc. The fact that the bytecode has intermediate casts is not relevant to the actual code executed on CPU.

charleslmunger··on Almost Always Unsigned
Citation needed? Java primitive fields are padded for alignment, but that's not unique to java.

https://www.baeldung.com/java-memory-layout#layout

charleslmunger··on State of Valhalla
Indeed. I recommend using tsan for java.

https://wiki.openjdk.java.net/display/tsan/Main

But the types of races I struggle with in java I suspect are similarly hard in Rust.

Here's two pieces of concurrent code I struggled with:

https://github.com/google/guava/blob/master/guava/src/com/go...

https://github.com/google/guava/blob/master/guava/src/com/go...

I'm not sure reasoning about the correctness of those would be easier in Rust, but if there are any rust experts reading this I'd love your perspective.

charleslmunger··on Parsing JSON Is a Minefield (2016)
To clarify, tags unknown to the IDL are propagated without parsing, not ignored.
charleslmunger··on Thread Pools on the JVM
Another tip - If you have a dynamically-sized thread pool, make it use a minimum of two threads. Otherwise developers will get used to guaranteed serialization of tasks, and you'll never be able to change it.
charleslmunger··on Reviews of Android TV launcher after Google added ads to the homescreen
If it has a cloud dependency, you can be confident that the system it controls will probably outlive the service's free lifetime.

If you're willing to do some technical work, there is fantastic open source tooling in this space. Then you'll have a setup that isn't affected by the business desires or financial problems of others. As a bonus, you get better latency over lan.

https://tasmota.github.io/docs/Tasmota-IR/#sending-irhvac-co...

charleslmunger··on 4k 144Hz no longer available after upgrade to Big Sur
Not the op, but I was shocked to see how much effort was required to disable mouse acceleration on a mac. Dragging the slider to 0 doesn't do it. Editing the plist doesn't do it. You need to install some custom mouse driver with kernel extensions to have 1:1 mouse movement.
← PreviousPage 7 of 16Next →