1
0
forked from ALHP/ALHP.GO

faster SRCINFO parsing + memory-based building

Switched to parsing srcinfo with channels on all available cpus, speeding
up srcinfo-parsing and queue generation by a lot.

New memory-limit based building will max out the available memory while
not building the same packages at the same time for different marchs,
fixing some long-standing bugs like firefox not building at the same time
because the same ports are used for profile-based optimization. This
also drops the artificial delay on build-start, speeding up things even
more. This also means there is no hard-coded limit on how many packages
can be build at once anymore. As long as there is RAM available, builds will be
started.
This commit is contained in:
2023-03-14 00:39:15 +01:00
parent 9baa7b2bcb
commit ece8c4c7d9
26 changed files with 1157 additions and 1114 deletions

View File

@@ -8,12 +8,12 @@ import (
"fmt"
"log"
"git.harting.dev/ALHP/ALHP.GO/ent/migrate"
"git.harting.dev/ALHP/ALHP.GO/ent/dbpackage"
"somegit.dev/ALHP/ALHP.GO/ent/migrate"
"entgo.io/ent"
"entgo.io/ent/dialect"
"entgo.io/ent/dialect/sql"
"somegit.dev/ALHP/ALHP.GO/ent/dbpackage"
)
// Client is the client that holds all ent builders.
@@ -39,6 +39,55 @@ func (c *Client) init() {
c.DbPackage = NewDbPackageClient(c.config)
}
type (
// config is the configuration for the client and its builder.
config struct {
// driver used for executing database requests.
driver dialect.Driver
// debug enable a debug logging.
debug bool
// log used for logging on debug mode.
log func(...any)
// hooks to execute on mutations.
hooks *hooks
// interceptors to execute on queries.
inters *inters
}
// Option function to configure the client.
Option func(*config)
)
// options applies the options on the config object.
func (c *config) options(opts ...Option) {
for _, opt := range opts {
opt(c)
}
if c.debug {
c.driver = dialect.Debug(c.driver, c.log)
}
}
// Debug enables debug logging on the ent.Driver.
func Debug() Option {
return func(c *config) {
c.debug = true
}
}
// Log sets the logging function for debug mode.
func Log(fn func(...any)) Option {
return func(c *config) {
c.log = fn
}
}
// Driver configures the client driver.
func Driver(driver dialect.Driver) Option {
return func(c *config) {
c.driver = driver
}
}
// Open opens a database/sql.DB specified by the driver name and
// the data source name, and returns a new client attached to it.
// Optional parameters can be added for configuring the client.
@@ -154,7 +203,7 @@ func (c *DbPackageClient) Use(hooks ...Hook) {
c.hooks.DbPackage = append(c.hooks.DbPackage, hooks...)
}
// Use adds a list of query interceptors to the interceptors stack.
// Intercept adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `dbpackage.Intercept(f(g(h())))`.
func (c *DbPackageClient) Intercept(interceptors ...Interceptor) {
c.inters.DbPackage = append(c.inters.DbPackage, interceptors...)
@@ -255,3 +304,13 @@ func (c *DbPackageClient) mutate(ctx context.Context, m *DbPackageMutation) (Val
return nil, fmt.Errorf("ent: unknown DbPackage mutation op: %q", m.Op())
}
}
// hooks and interceptors per client, for fast access.
type (
hooks struct {
DbPackage []ent.Hook
}
inters struct {
DbPackage []ent.Interceptor
}
)