[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:
kim
2023-02-13 18:40:48 +00:00
committed by GitHub
parent 76d1b484d0
commit acc95923da
54 changed files with 1853 additions and 2680 deletions

29
vendor/codeberg.org/gruf/go-bitutil/abs.go generated vendored Normal file
View File

@@ -0,0 +1,29 @@
package bitutil
// Abs8 returns the absolute value of i (calculated without branching).
func Abs8(i int8) int8 {
const bits = 8
u := uint64(i >> (bits - 1))
return (i ^ int8(u)) + int8(u&1)
}
// Abs16 returns the absolute value of i (calculated without branching).
func Abs16(i int16) int16 {
const bits = 16
u := uint64(i >> (bits - 1))
return (i ^ int16(u)) + int16(u&1)
}
// Abs32 returns the absolute value of i (calculated without branching).
func Abs32(i int32) int32 {
const bits = 32
u := uint64(i >> (bits - 1))
return (i ^ int32(u)) + int32(u&1)
}
// Abs64 returns the absolute value of i (calculated without branching).
func Abs64(i int64) int64 {
const bits = 64
u := uint64(i >> (bits - 1))
return (i ^ int64(u)) + int64(u&1)
}

File diff suppressed because it is too large Load Diff

View File

@@ -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 }}