mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-10-29 17:02:25 -05:00
[performance] processing media and scheduled jobs improvements (#1482)
* replace media workers with just runners.WorkerPool, move to state structure, use go-sched for global task scheduling
* improved code comment
* fix worker tryUntil function, update go-runners/go-sched
* make preprocess functions package public, use these where possible to stop doubled up processing
* remove separate emoji worker pool
* limit calls to time.Now() during media preprocessing
* use Processor{} to manage singular runtime of processing media
* ensure workers get started when media manager is used
* improved error setting in processing media, fix media test
* port changes from processingmedia to processing emoji
* finish code commenting
* finish code commenting and comment-out client API + federator worker pools until concurrency worker pools replaced
* linterrrrrrrrrrrrrrrr
---------
Signed-off-by: kim <grufwub@gmail.com>
This commit is contained in:
parent
76d1b484d0
commit
acc95923da
54 changed files with 1853 additions and 2680 deletions
57
vendor/codeberg.org/gruf/go-bitutil/flag.tpl
generated
vendored
57
vendor/codeberg.org/gruf/go-bitutil/flag.tpl
generated
vendored
|
|
@ -2,14 +2,13 @@ package bitutil
|
|||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"codeberg.org/gruf/go-byteutil"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
{{ range $idx, $size := . }}
|
||||
|
||||
// Flags{{ $size.Size }} is a type-casted unsigned integer with helper
|
||||
// methods for easily managing up to {{ $size.Size }} bit flags.
|
||||
// methods for easily managing up to {{ $size.Size }} bit-flags.
|
||||
type Flags{{ $size.Size }} uint{{ $size.Size }}
|
||||
|
||||
// Get will fetch the flag bit value at index 'bit'.
|
||||
|
|
@ -54,34 +53,58 @@ func (f Flags{{ $size.Size }}) Unset{{ $idx }}() Flags{{ $size.Size }} {
|
|||
|
||||
// String returns a human readable representation of Flags{{ $size.Size }}.
|
||||
func (f Flags{{ $size.Size }}) String() string {
|
||||
var val bool
|
||||
var buf byteutil.Buffer
|
||||
var (
|
||||
i int
|
||||
val bool
|
||||
buf []byte
|
||||
)
|
||||
|
||||
// Make a prealloc est. based on longest-possible value
|
||||
const prealloc = 1+(len("false ")*{{ $size.Size }})-1+1
|
||||
buf = make([]byte, prealloc)
|
||||
|
||||
buf[i] = '{'
|
||||
i++
|
||||
|
||||
buf.WriteByte('{')
|
||||
{{ range $idx := .Bits }}
|
||||
val = f.Get{{ $idx }}()
|
||||
buf.WriteString(bool2str(val) + " ")
|
||||
i += copy(buf[i:], bool2str(val))
|
||||
buf[i] = ' '
|
||||
i++
|
||||
{{ end }}
|
||||
buf.Truncate(1)
|
||||
buf.WriteByte('}')
|
||||
|
||||
return buf.String()
|
||||
buf[i-1] = '}'
|
||||
buf = buf[:i]
|
||||
|
||||
return *(*string)(unsafe.Pointer(&buf))
|
||||
}
|
||||
|
||||
// GoString returns a more verbose human readable representation of Flags{{ $size.Size }}.
|
||||
func (f Flags{{ $size.Size }})GoString() string {
|
||||
var val bool
|
||||
var buf byteutil.Buffer
|
||||
var (
|
||||
i int
|
||||
val bool
|
||||
buf []byte
|
||||
)
|
||||
|
||||
// Make a prealloc est. based on longest-possible value
|
||||
const prealloc = len("bitutil.Flags{{ $size.Size }}{")+(len("{{ sub $size.Size 1 }}=false ")*{{ $size.Size }})-1+1
|
||||
buf = make([]byte, prealloc)
|
||||
|
||||
i += copy(buf[i:], "bitutil.Flags{{ $size.Size }}{")
|
||||
|
||||
buf.WriteString("bitutil.Flags{{ $size.Size }}{")
|
||||
{{ range $idx := .Bits }}
|
||||
val = f.Get{{ $idx }}()
|
||||
buf.WriteString("{{ $idx }}="+bool2str(val)+" ")
|
||||
i += copy(buf[i:], "{{ $idx }}=")
|
||||
i += copy(buf[i:], bool2str(val))
|
||||
buf[i] = ' '
|
||||
i++
|
||||
{{ end }}
|
||||
buf.Truncate(1)
|
||||
buf.WriteByte('}')
|
||||
|
||||
buf[i-1] = '}'
|
||||
buf = buf[:i]
|
||||
|
||||
return buf.String()
|
||||
return *(*string)(unsafe.Pointer(&buf))
|
||||
}
|
||||
|
||||
{{ end }}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue