Comments (8)
There are performance implications for allowing event loops to be closed separately. Gaps in the array of event loops would be created which needs to be accounted for when assigning async commands to event loops. This implies at least one extra volatile reference.
Most applications initialize all event loops at startup and close all event loops at shutdown. What is
your use-case for closing an event loop at any time?
from aerospike-client-c.
OK I see your point in implicitly used event loops, so it may involve significant changes.
My use case is like, our app is in two parts, which originally runs as separate processes. And now we want to merge them in a same process, but running on different threads, so that we have lighter message passing between them. What's different is that, one part of it runs as several instances, starting and stopping on demand, and of course we want a graceful shutdown. Well, mostly an all-isolated environment, except for address space.
So, given that all attached loops are managed as a whole, maybe I am looking for an "aerospike_context" or the like, instead of the static variables now in use.
from aerospike-client-c.
We will research dynamic event loop sizing as a possible future enhancement. No concrete decision has been made.
from aerospike-client-c.
We have decided not to implement dynamic event loop closing for a number of reasons.
-
as_event_loop_get()
round-robin event loop assignment would require a lock. This would incur a performance penalty for all async users. -
Handling simultaneous event loop open/close/assignment is a complex process, especially when the close operation lock must transcend multiple iterations (lock, queue event loop close, process event loop close, unlock).
-
Each
as_node
instance maintains a pool of sockets for each event loop. If an event loop is closed, the sockets associated with the event loop would need to be assigned to other event loops or just closed. The problem is event loops have no current knowledge of clusters or nodes. This would require the client to maintain a thread-safe list of all opened clusters. The client could then iterate on all nodes in all clusters and close or reassign the associated sockets. This extra overhead is not currently necessary because all clusters/nodes must be closed before closing event loops.
Note that external event loops can be opened (but not closed) dynamically with the current client. First, define a fixed capacity limit with as_event_set_external_loop_capacity()
. Then, add external event loops with as_event_set_external_loop()
at any time until the capacity is reached.
from aerospike-client-c.
What about creating random event loops on the heap without adding to the global as_event_loops
? So that external loops are not considered in the round-robin choosing, and is completely external.
from aerospike-client-c.
The main obstacle is that there is a socket pool for every node/event loop combination. It was done that way so each socket get/put does not have to be thread-safe. #3 is still a problem in your scenario.
It may be possible to add a configuration variable that instructs nodes to provide a connection pool per node only and then use thread-safe (slower) socket get/put. This would mean #3 is not a problem, because event loops could be disassociated from socket pools. We will do some more research to see if that is feasible.
from aerospike-client-c.
Supporting two fundamentally different types of async socket pools complicates the code too much. I'm afraid our original decision stands.
from aerospike-client-c.
Okay I give up, close at your will. Maybe we resort to a single thread for AS access.
from aerospike-client-c.
Related Issues (20)
- warning: 'MSG_NOSIGNAL' macro redefined (on macOS) HOT 1
- Deleting bins by setting values to null or empty string HOT 1
- Undefined symbols in static library HOT 2
- cmake support HOT 4
- Is this project still under maintenance HOT 1
- Unable to found benchmarks in aerospike-client-c HOT 2
- Logstash Pipeline Error
- Crash in as_node_ensure_login_shm when remote servers are restarted HOT 16
- Compile failed with "the clang compiler does not support '-march=nocona'" HOT 2
- crash inside as_cluster_tend on arm64 HOT 4
- Give a name to worker threads HOT 3
- apple silicon / arm support HOT 9
- Release tagged 4.6.24 refers to missing .gitmodules HOT 1
- On batch reads only AS_POLICY_REPLICA_SEQUENCE will actually find new nodes for requests, AS_POLICY_REPLICA_ANY will try the same node and fail again. HOT 6
- aerospike-client-c link error with extra compiler flags -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer HOT 1
- can not build without lua HOT 1
- Missing as_buffer.h in installed includes HOT 1
- scan callback failing with memory fault issue HOT 1
- Build fails for 6.4.1 with luajit HOT 1
- crash on exit in as_cluster_tender (after libuv event loop is stopped) HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aerospike-client-c.