* Use monotonically increasing channel_id
Using a monotonically increasing channel_id (instead of a Uuid)
reduces memory use under load by ~3%
* Use replace unbounded channels with bounded
This also slightly reduces memory use
* Heap allocate Event
Wrapping the Event struct in an Arc avoids excessive copying and significantly reduces memory use.
* Implement more efficient unsubscribe strategy
* Fix various Clippy lints; bump version
* Update config defaults
This squashed commit rolls up a series of changes designed to improve
Flodgatt's public API/module boundary. Specifically, this limits the
number of Items that are exported outside the top-level modules (in some
cases because they were already not needed outside that module due to
the earlier code reorganization and in some cases by using public
re-exports to export particular Items from a private module).
Similarly, this commit moves the `Event` struct to the `response`
module (maintaining privacy for the `Event`'s implementation details)
while re-exporting the `Id` struct that `Event` uses internally at the
top level.
All of these changes are made with the goal of making Flodgatt's code
easier to reason about in isolation, which should both make it easier to
maintain and make it easier for new contributors to make changes without
understanding the entire codebase. Additionally, having fewer public
modules will make documenting Flodgatt more extensively much easier.
* Tweak release profile & micro optimizations
* Replace std HashMap with hashbrown::HashMap
The hashbrown::HashMap is faster than the std::collections::HashMap,
though it does not protect as well against malicious hash collisions
(e.g., in a DDoS). Since we don't expose the hashing externally,
we should switch to the faster implementation.
* Remove use of last_polled_time [WIP]
This commit stops removing subscriptions based on their last polled
time to test the impact of this change on CPU use. This is a WIP
because it does not yet remove subscriptions in any other way, which
(if deployed in production) would cause a memory leak – memory use
would grow with each new subscription and would never be reduced as
clients end their subscriptions.
* Fix bug with RedisConnection polling freqeuency
* Improve performance of EventStream
This commit changes the EventStream so no longer polls client
WebSocket connections to see if it should clean up the connection.
Instead, it cleans up the connection whenever it attempts to send a
ping or a message through the connection and receives an error
indicating that the client has disconnected. As a result, client
connections aren't cleaned up quite as quickly, but overall sys CPU
time should be dramatically improved.
* Remove empty entries from MsgQueues hashmap
Before this change, entries in the MsgQueue hashmap would remain once
added, even if their value fell to 0. This could lead to a very
slight memory leak/increase, because the hashmap would grow each time
a new user connected and would not decrease again. This is now fixed.
* Bump version and remove unused benchmark
* Initial work to support structured errors
* WIP error handling and RedisConn refactor
* WIP for error handling refactor
* Finish substantive work for Redis error handling
* Apply clippy lints
* Prevent Reciever from querying postgres
Before this commit, the Receiver would query Postgres for the name
associated with a hashtag when it encountered one not in its cache.
This ensured that the Receiver never encountered a (valid) hashtag id
that it couldn't handle, but caused a extra DB query and made
independent sections of the code more entangled than they need to be.
Now, we pass the relevant tag name to the Receiver when it first
starts managing a new subscription and it adds the tag name to its
cache then.
* Improve module boundary/privacy
* Reorganize Receiver to cut RedisStream
* Fix tests for code reorganization
Note that this change includes testing some private functionality by
exposing it publicly in tests via conditional compilation. This
doesn't expose that functionality for the benchmarks, so the benchmark
tests do not currently pass without adding a few `pub use`
statements. This might be worth changing later, but benchmark tests
aren't part of our CI and it's not hard to change when we want to test
performance.
This change also cuts the benchmark tests that were benchmarking old
ways Flodgatt functioned. Those were useful for comparison purposes,
but have served their purpose – we've firmly moved away from the
older/slower approach.
* Fix Receiver for tests
When the `WHITELIST_MODE` environmental variable is set, Flodgatt
requires users to authenticate with a valid access token before
subscribing to any timelines (even those that are typically public).
* Add type-safe wrapper types to deployement_cfg
* Before deleting redundnat macros
* Store error messages as data
* Significant progress on type safety
* Add type safety to RedisConfig
* Refactor configuration
* Fix bug with incorrect Host env variable
* Improve logging of REDIS_NAMESPACE
* Update test for Postgres configuration
* Conform Redis config to Postgres changes