News for hackers. Stuff that matters.

cafxx

Re:Go Proposal: Secret Mode on Sunday December 14, 2025 @08:11PM (#46269120)
Filed a CL for this, hopefully it gets merged ~soon.

https://go-review.googlesource.com/c/go/+/729920

Re:Go Proposal: Secret Mode on Saturday December 13, 2025 @07:18PM (#46259581)
That's not how it's implemented (it returns false if you're inside a Do() on a unsupported platform), although I agree the wording should be clearer.
Re:Go Proposal: Secret Mode on Saturday December 13, 2025 @07:03PM (#46259495)
I find this example mildly infuriating/amusing:

    func Encrypt(message []byte) ([]byte, error) {
        var ciphertext []byte
        var encErr error
    
        secret.Do(func() {
            // ...
        })
        
        return ciphertext, encErr
    }
As that suggests that somehow for PFS it is critical that the ephemeral key (not the long-term one) is zeroed out, while the plaintext message - i.e. the thing that in the example we allegedly want secrecy for - is totally fine to be outside of the whole `secret` machinery, and remain in memory potentially "forever".

I get that the example is simplified (because what it should actually do is protect the long-term key, not the ephemeral one)... so, yeah, it's just a bad example.

Re:Golang's Big Miss on Memory Arenas on Friday December 12, 2025 @07:24PM (#46250702)
The point is that no-one is thinking to add knobs, or allow alternative GCs.
Re:Golang's Big Miss on Memory Arenas on Thursday December 11, 2025 @09:18PM (#46240149)
> GOGC was introduced in Go 1.5

yes, that's quite literally what I meant by "GOGC has always been there". 1.5 was released 10 years ago, just 3 years after 1.0.

So to summarize: there is one knob (that has been there from basically the beginning), plus a second one (if you squint hard enough: GOMAXMEM), and absolutely no plans to add further ones, or to add alternative GCs.

Re:Golang's Big Miss on Memory Arenas on Thursday December 11, 2025 @04:04PM (#46237129)
Your previous message was referring to Go "getting" knobs, but GOGC has always been there.

The older GC algorithm won't stay, IIRC the plan is for it to be removed in 1.27 (it's kept for now just to give a fallback in case of bugs in the first release).

Re:Golang's Big Miss on Memory Arenas on Thursday December 11, 2025 @09:50AM (#46232054)
I still would be wary, even in that case. Go does not guarantee that the address of an allocation won't change over the lifetime of the allocation (although current implementations do not make use of this).

If you really store just references to the same arena, better to use an offset from the start of the arena. Then it does not matter whether allocations are moved around.

Re:Golang's Big Miss on Memory Arenas on Thursday December 11, 2025 @09:45AM (#46232001)
Not sure what you are referring to. There are no knobs involved in the things I mentioned (aside from the one to enable the experiment, but that's just temporary until the experiment completes - one way or the other).
Re:Golang's Big Miss on Memory Arenas on Wednesday December 10, 2025 @10:05PM (#46227177)
> If you really want an arena like behavior you could allocate a byte slice and use unsafe to cast it to literally any type.

A word of caution. If you do this and then you store pointers into that slice, the GC will likely not see them (as if you were just storing them as `uintptr`s)

Re:Golang's Big Miss on Memory Arenas on Wednesday December 10, 2025 @10:00PM (#46227146)
There's a bunch of activity ongoing to make things better for memory allocation/collection in Go. GreenTeaGC is one that has already landed, but there are others like the RuntimeFree experiment that aims at progressively reduce the amount of garbage generated by enabling safe reuse of heap allocations, as well as other plans to move more allocations to the stack.

Somehow concluding that "By killing Memory Arenas, Go effectively capped its performance ceiling" seems quite misguided.

I think that the idea of not initiating writeback immediately derives mostly from the days of spinning rust, where read latencies would be noticeably impacted if you initiated writeback too aggressively: reads, contrary to writes, are synchronous by default, and spinning rust rarely allowed high (by modern standards) IOPS, so it made a lot of sense to buffer writes as much as possible to minimize the number of I/O operations spent on writes, as this would leave as many of those IOPS as possible available for reads.

This is probably much less of a concern today, as NVMe drives - beside having many orders of magnitude higher IOPS capacity - also have (at least on paper) much better hardware support for high I/O concurrency. It may still make sense, even today, if your hardware (or stack) limits IOPS.

Show HN: Mgo: build a single Go binary optimized for all GOAMD64 variants

https://github.com/CAFxX/mgo

mgo builds the same program once for each GOAMD64 variant, and then bundles all of them with a launcher that at runtime picks the correct one for the local system. Handy if you have CPU-heavy workloads, but you can't assume which processor they run on; we use it in our kubernetes workloads to reduce CPU usage by ~3%.

( Read More... | no comments | on HN )
Re:Introducing GPTs on Monday November 06, 2023 @02:31PM (#38167608)
Would be nice also if they fixed the ubiquitous "network errors" that happen approximately every single time...
Not to be the devil's advocate here, but almost certainly it can be the case that data was used to define heuristics (potentially using automated statistical methods) that a engineer then formalized as code. Without that data that specific heuristic wouldn't exist, at least very likely not in that form. Yet that data does not have to be included in any open source release. And obviously you as a recipient of the release can modify the heuristic (or at least, you can modify the version that was codified), but you can not reconstruct it from the original data.

I know my example is not exactly what is happening here, but the two sound pretty affine to me and there seem to be a fairly blurry line dividing the two... so I would argue that where "this must be included in a open source release" ends and "this does not need to be included in a open source release" starts is not always so cut and dry.

(A variant of this, that happens fairly frequently, is when you find a commit that says something along the lines of "this change was made because it made an internal, non-public workload X% faster"; if the data that measurement is based upon did not exist, or if the workload itself didn't exist, that change wouldn't have been made, or maybe it would have been made differently... so again you end up with logic due to data that is not in the open source release)

If we want to go one step further, we could even ask: what about static assets (e.g. images, photographs, other datasets, etc.) included in a open-source release... maybe I'm dead wrong here, but I have never heard that such assets must themselves be "reproducible from source" (what even is, in this context, the "source" of a photograph?).

That being said, I sure wish the training data used for all of these models was available to everyone...

...or maybe Microsoft should just offer an API for marking a file for deletion once it's not in use anymore.
Re:Designing a new concurrent data structure on Tuesday August 29, 2023 @03:18PM (#37312528)
Or you could simply invoke a GC periodically (or every N times a key is removed from the map, or similar schemes).

Another simple way, if we don't like the idea of triggering GCs manually,is to allocate the same buffer both off-heap and on-heap: use the off-heap one for actual key storage, and the on-heap one just to generate heap memory pressure.

Re:Designing a new concurrent data structure on Monday August 28, 2023 @06:36PM (#37301267)
Why not just allocating the blobs off-heap? (That is something you probably want to do anyway if it's cryptographic material, to avoid being at the mercy of the GC leaving copies around)

ByteBuffer.allocateDirect should do that IIRC. This allows you to use the standard ConcurrentHashMap while being able to get a stable pointer for use by the rust logic.

Re:Asteroid ZTm0038 with a >3% impact probability on Tuesday August 15, 2023 @05:43PM (#37139648)
Re:Optimizing a Ring Buffer for Throughput on Tuesday June 27, 2023 @06:19AM (#36491026)
In the example you linked it's comparing two threads reading from the same or separate cache lines, no? If so, that's not really the point I was referring to (as the two variables I mentioned as example are accessed by a single thread, not by two threads).
Re:Optimizing a Ring Buffer for Throughput on Tuesday June 27, 2023 @04:54AM (#36490498)
A point that AFAICT is not articulated in the article is why the two cached fields should be in their own dedicated cache line (e.g. why readIdxCached_ can not share the cache line with writeIdx_).
Re:How to make a QR code with Stable Diffusion on Monday June 12, 2023 @07:09AM (#36291596)
Yes, that's the whole point. I did not claim you can control every single module in the QR. I just said that you can get different QR codes for the same semantic content.
Re:How to make a QR code with Stable Diffusion on Monday June 12, 2023 @05:32AM (#36290671)
Yes, that's what I meant.
Re:How to make a QR code with Stable Diffusion on Monday June 12, 2023 @05:23AM (#36290590)
Sorry, yes, I should have clarified I meant "no-one has done it in the current batch of diffusion-based experiments". As you point out it has been done multiple times before, e.g. https://research.swtch.com/qart.
Re:How to make a QR code with Stable Diffusion on Monday June 12, 2023 @05:22AM (#36290576)
Sure, but as I mentioned it has absolutely nothing to do with the CRC calculation, that is what you claimed.
Re:How to make a QR code with Stable Diffusion on Monday June 12, 2023 @02:17AM (#36289101)
Also not sure the diffusion model has been taught yet that it could in some cases choose to deliberately ignore a (small) fraction of some of the elements/blocks, if it helps with composition.

Or even better just wire up a QR decoder to the loop and automatically reject images that don't decode correctly, and let the model sort out how far it can go.

Re:How to make a QR code with Stable Diffusion on Monday June 12, 2023 @02:11AM (#36289045)
None of what I wrote impacts the CRC calculation.
Re:How to make a QR code with Stable Diffusion on Sunday June 11, 2023 @11:52PM (#36288253)
The funny thing is that no-one AFAICT has realized that the same content can be encoded in different-looking QR codes. Beside the obvious (different error-correction levels), the content itself can be changed while maintaining its semantic meaning (e.g. "https://example.com/foo", "HTTPS://EXAMPLE.COM/foo", or "HtTpS://eXaMpLe.CoM/foo" are all semantically identical) and even the QR encoding itself can be tweaked (e.g. by changing the version and mask, see the demo on https://www.nayuki.io/page/qr-code-generator-library). Each combination would yield a different-looking QR code that would encode the same meaning, and it could therefore allow the diffusion models even greater freedom.

I'm sure somebody will get to this soon.

Older »