Skip to content
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: add 24 byte malloc size class #17633

Closed
josharian opened this issue Oct 27, 2016 · 6 comments

Comments

Projects
None yet
7 participants
@josharian
Copy link
Contributor

commented Oct 27, 2016

We have a 16 and a 32 byte size class, but no 24. Slices escape a lot (io.Reader calls, sort.Sort calls, etc.). We should only allocate 24 bytes for them when they do.

Note sure how best to work this into our current size generation scheme.

@randall77 @bradfitz @aclements

Tentatively marking Go 1.8 since it's seems like a cheap, easy, safe win.

@josharian josharian added this to the Go1.8 milestone Oct 27, 2016

@dr2chase

This comment has been minimized.

Copy link
Contributor

commented Oct 27, 2016

Naively, it's a one-liner in msize.go:initSizes

        if size&(size-1) == 0 { // bump alignment once in a while
            if size >= 2048 {
                align = 256
            } else if size >= 128 {
                align = size / 8
            } else if size >= 16 { // <---- change goes here, s/16/32
                align = 16 // required for x86 SSE instructions, if we want to use them
            }
        }

but make.bash then crashes.
So, cheap and easy, I got 2 out of 3.
Rick made some very discouraging noises expecting this for 1.8, but I'll look a little harder.

@dr2chase dr2chase modified the milestones: Go1.9, Go1.8 Oct 27, 2016

@RLH

This comment has been minimized.

Copy link
Contributor

commented Oct 27, 2016

Time for 1.8 is now down to only a couple of more working days and while
the idea seems solid we don't have any performance numbers to indicate the
value of the change.

On Thu, Oct 27, 2016 at 3:10 PM, dr2chase notifications@github.com wrote:

Naively, it's a one-liner in msize.go:initSizes

    if size&(size-1) == 0 { // bump alignment once in a while
        if size >= 2048 {
            align = 256
        } else if size >= 128 {
            align = size / 8
        } else if size >= 16 { // <---- change goes here, s/16/32
            align = 16 // required for x86 SSE instructions, if we want to use them
        }
    }

but make.bash then crashes.
So, cheap and easy, I got 2 out of 3.
Rick made some very discouraging noises expecting this for 1.8, but I'll
look a little harder.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#17633 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AA7Wn97PbpG0m-U1ENpmNZ4rnVW5s321ks5q4Pc-gaJpZM4KikrA
.

@josharian

This comment has been minimized.

Copy link
Contributor Author

commented Oct 27, 2016

Fair enough. Here's one data point from the compiler for 1.9 about the prevalence of slice allocations: While compiling std+cmd, 3.42% of all allocations were []*gc.Node; 1.16% of allocations were []*gc.Field.

@aclements

This comment has been minimized.

Copy link
Member

commented Oct 28, 2016

but make.bash then crashes.

My hunch would be that this is violating some of the assumptions of heapBitsSetType, which is very optimized for the current alignment constraints of small size classes. It's probably not too hard to fix, but it does mean it doesn't necessarily work to just add a size class to the table.

@mvdan

This comment has been minimized.

Copy link
Member

commented Nov 19, 2016

Is this a dup of #8885?

@bradfitz

This comment has been minimized.

Copy link
Member

commented Nov 20, 2016

Yes. Closing this one, since #8885 predates it so much. (Normally we close the dup with the least conversation if the dates are roughly equal)

@bradfitz bradfitz closed this Nov 20, 2016

@golang golang locked and limited conversation to collaborators Nov 20, 2017

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.