-
Notifications
You must be signed in to change notification settings - Fork 117
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
Improve throughput of blocking writes to the same bucket #352
Comments
As Flush and Write* can occur in different go-routines, there must be a synchronization. |
vlastahajek
added a commit
to bonitoo-io/influxdb-client-go
that referenced
this issue
Sep 9, 2022
5 tasks
vlastahajek
added a commit
to bonitoo-io/influxdb-client-go
that referenced
this issue
Sep 9, 2022
vlastahajek
added a commit
to bonitoo-io/influxdb-client-go
that referenced
this issue
Sep 12, 2022
vlastahajek
added a commit
to bonitoo-io/influxdb-client-go
that referenced
this issue
Sep 13, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Proposal:
High-level: The throughput of blocking writes to the same bucket is limited by a broad-scoped mutex.
Lower-level: Remove the mutex from
WriteAPIBlocking
implementation entirely, or at least reduce its scope to only exactly where it's needed.Current behavior:
The method
writeAPIBlocking.write
locks a mutex at the start and doesn't unlock it until done (see source). The mutex seems necessary to guardw.batching
andw.batch
but notw.service
norw.writeOptions
which can't be changed after creation.Desired behavior:
Here's a possible solution for option 2:
This reduces the lock time to only long enough to check
w.batching
(if batching is disabled) or to modify/extract the current batch (if batching is enabled).Double-checked locking could also be used in tandem with
"sync/atomic".Bool
(from Go 1.19) which would avoid the lock entirely if batching is disabled.Alternatives considered:
api.NewWriteAPIBlocking
instead ofClient.WriteAPIBlocking
to purposely create multiplewriteAPIBlocking
instances, one per goroutine: this seems to go against the grain of the API and also creates many redundantService
s as wellUse case:
The text was updated successfully, but these errors were encountered: