Commit graph

292 commits

Author SHA1 Message Date
Johanna Amann
312713810f Merge remote-tracking branch 'origin/topic/jsiwek/force-idle-broker'
* origin/topic/jsiwek/force-idle-broker:
  Force the Broker IOSource to idle periodically
2019-05-08 09:04:25 -07:00
Jon Siwek
dbb49b17f4 Reduce data copying in Broker message processing 2019-05-07 20:15:31 -07:00
Jon Siwek
69eee058c1 Improve processing of broker data store responses
Now retrieves and processes all N available responses at once instead
of one-by-one-until-empty.  The later may be problematic from two
points: (1) hitting the shared queue/mailbox matching logic once per
response instead of once per Process() and (2) looping until empty is
not clearly bounded -- imagining a condition where there's a thread
trying to push a large influx of responses into the mailbox while at
the same time we're trying to take from it until it's empty.
2019-05-04 11:13:48 -07:00
Johanna Amann
29d9b5b554 Merge remote-tracking branch 'origin/topic/jsiwek/plist-and-event-cleanup'
* origin/topic/jsiwek/plist-and-event-cleanup:
  Add comments to QueueEvent() and ConnectionEvent()
  Add methods to queue events without handler existence check
  Cleanup/improve PList usage and Event API
2019-05-01 08:41:13 -07:00
Jon Siwek
32473b85b0 Force the Broker IOSource to idle periodically
Previously, if there was always input in each Process() call, then
the Broker IOSource would never go idle and could completely starve
out a packet IOSource since it would always report readiness with
a timestamp value of the last known network_time (which prevents
selecting a packet IOSource for processing, due to incoming packets
likely having timestamps that are later).
2019-04-30 20:53:38 -07:00
Seth Hall
8cefb9be42 Implement the zeek_init handler.
Implements the change and a test.
2019-04-14 08:37:35 -04:00
Jon Siwek
b6862c5c59 Add methods to queue events without handler existence check
Added ConnectionEventFast() and QueueEventFast() methods to avoid
redundant event handler existence checks.

It's common practice for caller to already check for event handler
existence before doing all the work of constructing the arguments, so
it's desirable to not have to check for existence again.

E.g. going through ConnectionEvent() means 3 existence checks:
one you do yourself before calling it, one in ConnectionEvent(), and then
another in QueueEvent().

The existence check itself can be more than a few operations sometimes
as it needs to check a few flags that determine if it's enabled, has
a local body, or has any remote receivers in the old comm. system or
has been flagged as something to publish in the new comm. system.
2019-04-11 20:30:25 -07:00
Jon Siwek
8bc65f09ec Cleanup/improve PList usage and Event API
Majority of PLists are now created as automatic/stack objects,
rather than on heap and initialized either with the known-capacity
reserved upfront or directly from an initializer_list (so there's no
wasted slack in the memory that gets allocated for lists containing
a fixed/known number of elements).

Added versions of the ConnectionEvent/QueueEvent methods that take
a val_list by value.

Added a move ctor/assign-operator to Plists to allow passing them
around without having to copy the underlying array of pointers.
2019-04-11 20:30:25 -07:00
Jon Siwek
ee00483ee6 Update now-broken Broker API usages
Related to the changes from https://github.com/zeek/broker/pull/38
2019-03-27 10:55:31 -07:00
Jon Siwek
018f687c33 Add validity checking/warnings for Broker messages 2019-02-06 13:19:00 -06:00
Johanna Amann
d4f7dae768 Merge remote-tracking branch 'origin/topic/jsiwek/val_mgr'
* origin/topic/jsiwek/val_mgr:
  Pre-allocate and re-use Vals for bool, int, count, enum and empty string
  Preallocate booleans and small counts

I added a tiny change to CompHash to make sure that nothing messes this
up in the future.
2019-01-18 15:17:34 -08:00
Jon Siwek
0d685efbf5 Add Broker::peer_counts_as_iosource option
Disabling this option allows one to read pcaps, but still initiate
Broker peerings and automatically exit when done processing the pcap
file.  The default behavior would normally cause Broker::peer() to
prevent shutting the process down even after done reading the pcap.
2019-01-16 19:03:35 -06:00
Jon Siwek
2982765128 Pre-allocate and re-use Vals for bool, int, count, enum and empty string 2019-01-09 18:29:23 -06:00
Jon Siwek
4bd6da7186 Update default Broker/CAF thread tuning 2018-09-07 17:50:28 -05:00
Jon Siwek
1dcead93bf Add Broker::forward() function
This enables explicit forwarding of events matching a given topic
prefix.  Even if a receiving node has an event handler, it will not
be raised if the event was sent along a topic that matches a previous
call to Broker::forward().
2018-08-28 19:42:22 -05:00
Jon Siwek
1a75ef2abd Remove "relay" family of Broker functions
Namely these are now removed:

    - Broker::relay
    - Broker::publish_and_relay
    - Cluster::relay_rr
    - Cluster::relay_hrw

The idea being that Broker may eventually implement the necessary
routing (plus load balancing) functionality.  For now, code that used
these should "manually" handle and re-publish events as needed.
2018-08-27 16:49:35 -05:00
Jon Siwek
da9f91fc19 Add env. variables to override Broker listen/connect retry intervals
And use them to default retries to 1sec for all unit tests.
2018-08-16 12:16:03 -05:00
Jon Siwek
67524f26d5 Immediately apply broker subscriptions made during bro_init()
Otherwise that's begging for unit test failures due to races
2018-08-10 17:18:21 -05:00
Jon Siwek
083947af41 Update default broker threading configuration
Now defaults to a max of 4 threads typically indepedent of core
count (previously could go up to a hard cap of 8).  Also now allow
controlling this setting via BRO_BROKER_MAX_THREADS environment
variable.
2018-08-10 17:08:26 -05:00
Jon Siwek
385350a1f3 Make Broker congestion queue size tunable and increase default 2018-07-20 12:14:33 -05:00
Jon Siwek
9caad8a042 Port broker::data variant usages to use CAF API directly
Old code still all worked, but made use of Broker functions which
now just redirect to CAF ones.
2018-07-17 14:25:21 -05:00
Jon Siwek
06e7f18a32 Prevent double-wrapping Broker::Data in published event args
In the following example, the republication of "arg" would result in
literally sending it as a Broker::Data record instead of the broker data
that it was already wrapping.

Sender:

    Broker::publish("topic", my_event, "hello")

Receiver:

    event my_event(arg: any)
        {
        Broker::publish("topic", my_event, arg)
        }
2018-06-27 19:17:54 -05:00
Jon Siwek
ac495e729b Fix deprecated actor_system_config field usages 2018-06-26 15:05:53 -05:00
Jon Siwek
a33d2d13bf Reorganize private broker/Manager members 2018-06-25 16:41:55 -05:00
Jon Siwek
0200b5bd88 Move internal broker/Manager classes out of header 2018-06-25 16:35:25 -05:00
Jon Siwek
66ee376411 BIT-1938: fix crash in Broker manager shutdown 2018-06-21 11:48:10 -05:00
Jon Siwek
e578c1c231 Add Broker::max_threads and Broker::max_sleep tuning options
The former replaces the pcap vs. live versions of the same tuning
option.  If a user does not change these, Bro makes some internal
decisions that may help avoid performance problems on systems with high
core counts: the number of CAF threads is capped at 8 and the maximum
sleep duration for under-utilized threads is increased to 64ms (CAF's
default is 10ms).
2018-06-14 12:57:23 -05:00
Jon Siwek
197ea03f8f Minor optimization to bro_broker::Manager::FlushPendingQueries 2018-06-14 12:41:21 -05:00
Jon Siwek
c9fe9a943c Add Broker::max_live_threads and Broker::max_pcap_threads tunables
These may be used to change the number of scheduler threads that the
underlying CAF library creates.  In pcap mode, it's currently hardcoded
to the minimal 4 threads due to potentially significant overhead in CAF.
2018-06-12 13:54:43 -05:00
Jon Siwek
9822fc252d Improve Broker performance
Now manually keeps track of peer count instead of querying Broker for
that information (which would result in waiting upon a blocking request
to the core actor).
2018-06-06 16:25:30 -05:00
Jon Siwek
224ee790e2 Add Broker::publish_and_relay BIF
Like Broker::relay, except the relaying-node also calls event handlers.
2018-05-31 15:26:22 -05:00
Robin Sommer
fe7e1ee7f0 Merge topic/actor-system throug a squashed commit. 2018-05-18 22:39:23 +00:00
Jon Siwek
1e4964de77 Preallocate all possible PortVals.
The performance benefit is small (maybe ~1% at most), however, it's a
trivial change without downsides.
2017-12-11 15:29:28 -06:00
Robin Sommer
5cf7803e68 Fix some minor issues.
From Daniel, thanks!
2017-02-23 17:18:43 -08:00
Robin Sommer
a5e9a535a5 Changing semantics of Broker's remote logging to match old communication framework.
Broker had changed the semantics of remote logging: it sent over the
original Bro record containing the values to be logged, which on the
receiving side would then pass through the logging framework normally,
including triggering filters and events. The old communication system
however special-cases logs: it sends already processed log entries,
just as they go into the log files, and without any receiver-side
filtering etc. This more efficient as it short-cuts the processing
path, and also avoids the more expensive Val serialization. It also
lets the sender determine the specifics of what gets logged (and how).

This commit changes Broker over to now use the same semantics as the
old communication system.

TODOs:
     - The new Broker code doesn't have consistent #ifdefs yet.

     - Right now, when a new log receiver connects, all existing logs
     are broadcasted out again to all current clients. That doesn't so
     any harm, but is unncessary. Need to add a way to send the
     existing logs to just the new client.
2017-02-10 18:46:45 -08:00
Daniel Thayer
f46dfac63a Rename the BrokerStore namespace to Broker 2016-03-30 16:39:19 -05:00
Daniel Thayer
9f5c820c7b Rename the BrokerComm namespace to Broker 2016-03-30 14:31:25 -05:00
Jon Siwek
58ea1ff458 BIT-1408: improve I/O loop and Broker IOSource. 2015-06-03 08:25:49 -05:00
Jon Siwek
63ab936d8c Fix iterator invalidation in broker::Manager dtor. 2015-04-13 10:36:04 -05:00
Jon Siwek
cb5902d1ad Fix broker data stores in absence of --enable-debug.
Oops, put too much inside the assert() macro, so the registering of data
stores got preprocessed out of optimized builds.
2015-03-10 13:27:13 -05:00
Jon Siwek
2f626fa602 Fix build warnings, clarify broker requirements, update submodule. 2015-03-06 11:07:58 -06:00
Jon Siwek
9e53722b57 Rename comm/ directories to broker/ 2015-03-05 17:02:25 -06:00
Renamed from src/comm/Manager.cc (Browse further)