fix: issue with jit performance

This commit is contained in:
Vikram Rangnekar 2020-06-09 19:06:16 -04:00
parent 9f35f85857
commit 00cfa251a2
4 changed files with 8 additions and 25 deletions

View File

@ -85,7 +85,7 @@ type SuperGraph struct {
allowList *allow.List
encKey [32]byte
hashSeed maphash.Seed
queries map[uint64]query
queries map[uint64]*query
roles map[string]*Role
getRole *sql.Stmt
rmap map[uint64]resolvFn

View File

@ -172,14 +172,15 @@ func (c *scontext) resolvePreparedSQL() ([]byte, *stmt, error) {
h := maphash.Hash{}
h.SetSeed(c.sg.hashSeed)
id := queryID(&h, c.res.name, role)
q, ok := c.sg.queries[queryID(&h, c.res.name, role)]
q, ok := c.sg.queries[id]
if !ok {
return nil, nil, errNotFound
}
if q.sd == nil {
q.Do(func() { c.sg.prepare(&q, role) })
q.Do(func() { c.sg.prepare(q, role) })
if q.err != nil {
return nil, nil, err

View File

@ -494,24 +494,6 @@ func (p *Parser) parseField(f *Field) error {
return nil
}
// func (p *Parser) parseInlineFragmentFields(st *Stack, fields []Field) ([]Field, error) {
// var err error
// if p.peek(itemName) {
// p.ignore()
// // frag.On = p.vall(p.next())
// } else {
// return nil, errors.New("inline fragment: missing table name after 'on' keyword")
// }
// fields, err = p.parseNormalFields(st, fields)
// if err != nil {
// return nil, fmt.Errorf("inline fragment: %v", err)
// }
// return fields, nil
// }
func (p *Parser) parseOpParams(args []Arg) ([]Arg, error) {
for {
if len(args) >= maxArgs {

View File

@ -64,7 +64,7 @@ func (sg *SuperGraph) initPrepared() error {
return fmt.Errorf("role query: %w", err)
}
sg.queries = make(map[uint64]query)
sg.queries = make(map[uint64]*query)
list, err := sg.allowList.Load()
if err != nil {
@ -82,15 +82,15 @@ func (sg *SuperGraph) initPrepared() error {
switch qt {
case qcode.QTQuery:
sg.queries[queryID(&h, v.Name, "user")] = query{ai: v, qt: qt}
sg.queries[queryID(&h, v.Name, "user")] = &query{ai: v, qt: qt}
if sg.anonExists {
sg.queries[queryID(&h, v.Name, "anon")] = query{ai: v, qt: qt}
sg.queries[queryID(&h, v.Name, "anon")] = &query{ai: v, qt: qt}
}
case qcode.QTMutation:
for _, role := range sg.conf.Roles {
sg.queries[queryID(&h, v.Name, role.Name)] = query{ai: v, qt: qt}
sg.queries[queryID(&h, v.Name, role.Name)] = &query{ai: v, qt: qt}
}
}
}