prefetch handle info instead of waiting for load

This commit is contained in:
Ted Unangst 2019-08-18 18:32:44 -04:00
parent 877b0e043b
commit 27b5bc5f5f
2 changed files with 13 additions and 0 deletions

View File

@ -252,6 +252,8 @@ func savexonk(user *WhatAbout, x *Honk) {
if strings.Contains(aud, user.URL) { if strings.Contains(aud, user.URL) {
whofore = 1 whofore = 1
} }
go prehandle(x.Honker)
go prehandle(x.Oonker)
res, err := stmtSaveHonk.Exec(x.UserID, x.What, x.Honker, x.XID, x.RID, dt, x.URL, aud, res, err := stmtSaveHonk.Exec(x.UserID, x.What, x.Honker, x.XID, x.RID, dt, x.URL, aud,
x.Noise, x.Convoy, whofore, "html", x.Precis, x.Oonker, 0) x.Noise, x.Convoy, whofore, "html", x.Precis, x.Oonker, 0)
if err != nil { if err != nil {

11
fun.go
View File

@ -376,6 +376,9 @@ var handlelock sync.Mutex
// handle, handle@host // handle, handle@host
func handles(xid string) (string, string) { func handles(xid string) (string, string) {
if xid == "" {
return "", ""
}
handlelock.Lock() handlelock.Lock()
handle := allhandles[xid] handle := allhandles[xid]
handlelock.Unlock() handlelock.Unlock()
@ -415,6 +418,14 @@ func findhandle(xid string) string {
return handle return handle
} }
var handleprelock sync.Mutex
func prehandle(xid string) {
handleprelock.Lock()
defer handleprelock.Unlock()
handles(xid)
}
func prepend(s string, x []string) []string { func prepend(s string, x []string) []string {
return append([]string{s}, x...) return append([]string{s}, x...)
} }