mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-11-24 18:25:57 +03:00
move WASM compilation stage much later in server init to reduce memory usage during db migrations (#3242)
This commit is contained in:
parent
28d57d1f13
commit
f4d69db36a
1 changed files with 12 additions and 13 deletions
|
@ -31,7 +31,6 @@ import (
|
||||||
|
|
||||||
"github.com/KimMachineGun/automemlimit/memlimit"
|
"github.com/KimMachineGun/automemlimit/memlimit"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/ncruces/go-sqlite3"
|
|
||||||
"github.com/superseriousbusiness/gotosocial/cmd/gotosocial/action"
|
"github.com/superseriousbusiness/gotosocial/cmd/gotosocial/action"
|
||||||
"github.com/superseriousbusiness/gotosocial/internal/api"
|
"github.com/superseriousbusiness/gotosocial/internal/api"
|
||||||
apiutil "github.com/superseriousbusiness/gotosocial/internal/api/util"
|
apiutil "github.com/superseriousbusiness/gotosocial/internal/api/util"
|
||||||
|
@ -74,13 +73,6 @@ var Start action.GTSAction = func(ctx context.Context) error {
|
||||||
// to match container limits.
|
// to match container limits.
|
||||||
setLimits(ctx)
|
setLimits(ctx)
|
||||||
|
|
||||||
// Compile WASM modules ahead of first use
|
|
||||||
// to prevent unexpected initial slowdowns.
|
|
||||||
log.Info(ctx, "precompiling WebAssembly")
|
|
||||||
if err := precompileWASM(ctx); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// Define necessary core variables
|
// Define necessary core variables
|
||||||
// before anything so we can prepare
|
// before anything so we can prepare
|
||||||
|
@ -203,6 +195,17 @@ var Start action.GTSAction = func(ctx context.Context) error {
|
||||||
TLSInsecureSkipVerify: config.GetHTTPClientTLSInsecureSkipVerify(),
|
TLSInsecureSkipVerify: config.GetHTTPClientTLSInsecureSkipVerify(),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Compile WASM modules ahead of first use
|
||||||
|
// to prevent unexpected initial slowdowns.
|
||||||
|
//
|
||||||
|
// Note that this can take a bit of memory
|
||||||
|
// and processing so we perform this much
|
||||||
|
// later after any database migrations.
|
||||||
|
log.Info(ctx, "compiling WebAssembly")
|
||||||
|
if err := compileWASM(ctx); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// Build handlers used in later initializations.
|
// Build handlers used in later initializations.
|
||||||
mediaManager := media.NewManager(state)
|
mediaManager := media.NewManager(state)
|
||||||
oauthServer := oauth.New(ctx, dbService)
|
oauthServer := oauth.New(ctx, dbService)
|
||||||
|
@ -491,11 +494,7 @@ func setLimits(ctx context.Context) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func precompileWASM(ctx context.Context) error {
|
func compileWASM(ctx context.Context) error {
|
||||||
if err := sqlite3.Initialize(); err != nil {
|
|
||||||
return gtserror.Newf("error compiling sqlite3: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Use admin-set ffmpeg pool size, and fall
|
// Use admin-set ffmpeg pool size, and fall
|
||||||
// back to GOMAXPROCS if number 0 or less.
|
// back to GOMAXPROCS if number 0 or less.
|
||||||
ffPoolSize := config.GetMediaFfmpegPoolSize()
|
ffPoolSize := config.GetMediaFfmpegPoolSize()
|
||||||
|
|
Loading…
Reference in a new issue