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

Open
bradfitz opened this Issue Nov 17, 2014 · 13 comments

Comments

Projects
None yet
7 participants
@bradfitz
Member

bradfitz commented Nov 17, 2014

It appears that gc and the runtime currently disable channel elements to be over 64kB:

    http://play.golang.org/p/_aVWt-qiud

But I see nothing about this (allowed?) implementation restriction in the spec, despite
the spec calling out a number of other implementation-allowed restrictions.
@minux

This comment has been minimized.

Member

minux commented Nov 17, 2014

Comment 1:

ideally the spec should also set a minimum requirement on the item size limit.
@griesemer

This comment has been minimized.

Contributor

griesemer commented Nov 18, 2014

Comment 2:

What's the implementation issue requiring a limit in the first place (besides memory
availability)? (Array don't have a limit, for instance).
@rsc

This comment has been minimized.

Contributor

rsc commented Nov 18, 2014

Comment 3:

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.
@bradfitz

This comment has been minimized.

Member

bradfitz commented Nov 18, 2014

Comment 4:

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.
@robpike

This comment has been minimized.

Contributor

robpike commented Nov 18, 2014

Comment 5:

Let's just remove the restriction from the compiler and replace it with a
overall buffer size check.
-rob
@griesemer

This comment has been minimized.

Contributor

griesemer commented Nov 18, 2014

Comment 6:

Labels changed: removed documentation.

Owner changed to ---.

@bradfitz bradfitz modified the milestone: Go1.5 Dec 16, 2014

@bradfitz bradfitz removed the release-go1.5 label Dec 16, 2014

@rsc rsc removed accepted labels Apr 14, 2015

@josharian

This comment has been minimized.

Contributor

josharian commented May 5, 2015

Let's just remove the restriction from the compiler and replace it with a overall buffer size check.

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?

@randall77

This comment has been minimized.

Contributor

randall77 commented May 5, 2015

Easy enough to remove the hchan.elemsize field and use hchan._type.size instead. One extra indirection, but not a big deal.

@josharian

This comment has been minimized.

Contributor

josharian commented May 5, 2015

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 makechan. That seems like a property worth keeping.

@randall77

This comment has been minimized.

Contributor

randall77 commented May 5, 2015

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).

@minux

This comment has been minimized.

Member

minux commented May 5, 2015

@josharian

This comment has been minimized.

Contributor

josharian commented May 6, 2015

Ah. Indeed, thanks.

@rsc

This comment has been minimized.

Contributor

rsc commented Jun 8, 2015

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.

@rsc rsc changed the title from cmd/gc: remove implementation restriction on channel element size to runtime: remove implementation restriction on channel element size Jun 8, 2015

@rsc rsc modified the milestones: Unplanned, Go1.5 Jun 8, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment