-
Notifications
You must be signed in to change notification settings - Fork 17.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
runtime: remove implementation restriction on channel element size #9120
Comments
Ken put the limit there. I have always assumed it was something like the "stupid shift" errors, where if you have that big an element size you are probably doing something wrong. The fact that it took this long for someone to report a problem suggests he was right. (And even Brad doesn't seem like he's actually run into this.) I can take it out for 1.5. |
Correct. I was just checking something in the runtime and noticed in chan.go: func makechan(t *chantype, size int64) *hchan { elem := t.elem // compiler checks this but be safe. if elem.size >= 1<<16 { gothrow("makechan: invalid channel element type") } And it just surprised me to see it in either place, much less both places. |
The buffer size might not be constant, so we can't check it during compilation. Do we still want to pull the element size check? |
Easy enough to remove the hchan.elemsize field and use hchan._type.size instead. One extra indirection, but not a big deal. |
It is dataqsiz that we don't know at compile time. The argument against changing this is that, right now, if your code compiles, then it won't panic during |
I don't understand. Currently you can get a panic during makechan. If you allocate 2^30 objects each of size 2^8, for example. Removing the elemsize restriction won't make that any worse (or better). |
Except that the property doesn't always hold even now
(even if everything is statically determined.)
http://play.golang.org/p/iAdl5HhNC_
|
Ah. Indeed, thanks. |
The 64 kB limit turns out to be central to a fix for a late GC bug in the Go 1.5 release. I'm going to take advantage of this 64 kB limit to fix that bug. We can try to remove the limit (with a different fix) in 1.6. |
Are we decided here that implementations should support channels with element sizes >=64KiB? I think we should, but want to double check that before implementing it. It seems like the easy way to handle it is that overly-large elements just get passed around indirectly, like how we handle map keys/elements >128 bytes. FWIW, it looks like gccgo allows compiling code with channels with element sizes >=64KiB, but This is relevant to generics, because it's an end user error we can't report until after instantiation. Getting rid of the error altogether would simplify compiler internals, and also better fulfill the generic design principle that any type arguments that satisfy the type parameter constraints is a valid instantiation. |
So the runtime has this comment:
Can we just have escape analysis move all variables |
The runtime also has this comment:
It's the same really weird wart, and would be solved by not allowing objects with GC progs on the stack. So maybe we should never allocate GCprog'd objects on the stack? Or maybe even all >64KB objects? |
Moving all GC-program types to the heap looks like it would be easily doable. |
Change https://go.dev/cl/410895 mentions this issue: |
The text was updated successfully, but these errors were encountered: