Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: remove worker to test parallelism #1567

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions components/ledger/internal/engine/command/commander.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (

ledger "github.com/formancehq/ledger/internal"
"github.com/formancehq/ledger/internal/bus"
"github.com/formancehq/ledger/internal/engine/utils/batching"
"github.com/formancehq/ledger/internal/machine/vm"
"github.com/formancehq/stack/libs/go-libs/collectionutils"
"github.com/formancehq/stack/libs/go-libs/metadata"
Expand All @@ -28,7 +27,7 @@ type Parameters struct {
}

type Commander struct {
*batching.Batcher[*ledger.ChainedLog]
//*batching.Batcher[*ledger.ChainedLog]
store Store
locker Locker
compiler *Compiler
Expand All @@ -48,7 +47,7 @@ func New(store Store, locker Locker, compiler *Compiler, referencer *Referencer,
compiler: compiler,
lastTXID: big.NewInt(-1),
referencer: referencer,
Batcher: batching.NewBatcher(store.InsertLogs, 1, batchSize),
//Batcher: batching.NewBatcher(store.InsertLogs, 1, batchSize),
monitor: monitor,
}
}
Expand Down Expand Up @@ -149,7 +148,7 @@ func (commander *Commander) exec(ctx context.Context, parameters Parameters, scr
}

unlock, err := func() (Unlock, error) {
_, span := tracer.Start(ctx, "Lock")
ctx, span := tracer.Start(ctx, "Lock")
defer span.End()

unlock, err := commander.locker.Lock(ctx, lockAccounts)
Expand Down Expand Up @@ -311,7 +310,7 @@ func (commander *Commander) RevertTransaction(ctx context.Context, parameters Pa
}

func (commander *Commander) Close() {
commander.Batcher.Close()
//commander.Batcher.Close()
commander.running.Wait()
}

Expand Down
35 changes: 18 additions & 17 deletions components/ledger/internal/engine/command/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,31 +30,32 @@ func (e *executionContext) AppendLog(ctx context.Context, log *ledger.Log) (*led
return e.commander.chainLog(log)
}()

done := make(chan struct{})
func() {
_, span := tracer.Start(ctx, "AppendLogToQueue")
defer span.End()

e.commander.Append(chainedLog, func() {
close(done)
})
}()

//done := make(chan struct{})
err := func() error {
_, span := tracer.Start(ctx, "WaitLogAck")
ctx, span := tracer.Start(ctx, "InsertLog")
defer span.End()

select {
case <-ctx.Done():
return ctx.Err()
case <-done:
return nil
}
return e.commander.store.InsertLogs(ctx, chainedLog)
}()
if err != nil {
return nil, err
}

//err := func() error {
// _, span := tracer.Start(ctx, "WaitLogAck")
// defer span.End()
//
// select {
// case <-ctx.Done():
// return ctx.Err()
// case <-done:
// return nil
// }
//}()
//if err != nil {
// return nil, err
//}

return chainedLog, nil
}

Expand Down
2 changes: 1 addition & 1 deletion components/ledger/internal/engine/ledger.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (l *Ledger) Start(ctx context.Context) {
if err := l.commander.Init(ctx); err != nil {
panic(err)
}
go l.commander.Run(logging.ContextWithField(ctx, "component", "commander"))
//go l.commander.Run(logging.ContextWithField(ctx, "component", "commander"))
}

func (l *Ledger) Close(ctx context.Context) {
Expand Down
Loading