Skip to content

x/net/http2/hpack: Write customer-header into HPACK byName Map rather than byNameValue #20574

Description

@Zeymo

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go1.8

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Applications/workspace/code/MWCS"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/8r/y0x9w5g51k91thk9tk0xzgsc0000gn/T/go-build587864376=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"
PKG_CONFIG="pkg-config"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"

What did you do?

we use http2 as gateway platform protocol and extension header like mw-xxx to do some gateway sub-protocl as request and response.
as some resposne header, "mw-server-time" or "mw-rt", which has static name and dynamic value per request ,accordding to HPACK,these entry will add dynamic table like below

        t.byName[f.Name] = id
	t.byNameValue[pairNameValue{f.Name, f.Value}] = id

and which take 23% alloc_objects and much map hash grow in pprof

What did you expect to see?

we want only use byName map to index name rather than indexing name-value
and never indexing

seperate addEntry such as blew

func (t *headerFieldTable) addEntryByName(f HeaderField) {
        id := uint64(t.len()) + t.evictCount + 1
	t.byName[f.Name] = id
	t.ents = append(t.ents, f)
}

func (t *headerFieldTable) addEntryByNameVlaue(f HeaderField) {
        id := uint64(t.len()) + t.evictCount + 1
	t.byNameValue[pairNameValue{f.Name, f.Value}] = id
	t.ents = append(t.ents, f)
}

and also table.search

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    FeatureRequestIssues asking for a new feature that does not need a proposal.NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions