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

parallelized lua script execution with serialized output #1613

Merged
merged 3 commits into from
Apr 15, 2024
Merged

Conversation

serprex
Copy link
Member

@serprex serprex commented Apr 13, 2024

No description provided.

@serprex
Copy link
Member Author

serprex commented Apr 13, 2024

This currently spawns a goroutine for each message. It could be optimized to only spawn 1 goroutine per lua.LState

(edit: optimized in commit removing puddle)

}

func LuaPoolJob(ctx context.Context, pool LPool, wait <-chan struct{}, f func(*lua.LState, <-chan struct{})) (chan struct{}, error) {
res, err := pool.Acquire(ctx)
func (pool *LPool[T]) Spawn() error {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While it'd be fine to spin up a constant N goroutines, the correct amount will depend on the script, making it better to specify that kind of knob on the mirror instead of environment

Instead Spawn is called when messages aren't being waited on, this way an environment can set parallelism to some good amount for the vcores available & fast scripts will only create as many goroutines as necessary to keep up with record ingestion

flow/connectors/utils/lua.go Outdated Show resolved Hide resolved
@serprex serprex force-pushed the lua-pool branch 3 times, most recently from 51e0b76 to 651060f Compare April 15, 2024 18:41
@serprex serprex marked this pull request as ready for review April 15, 2024 19:13
@serprex serprex changed the title testing parallelized lua script execution with serialized output parallelized lua script execution with serialized output Apr 15, 2024
@serprex serprex merged commit 60bcef9 into main Apr 15, 2024
6 checks passed
@serprex serprex deleted the lua-pool branch April 15, 2024 19:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants