Repository navigation
Conversation
Add SessionConfig::data_dictionary: Option<Arc<Dictionary>>, which takes precedence over data_dictionary_path. A dictionary can then be built or extended in memory (a standard dictionary plus a counterparty's custom fields) instead of being read from a file. Sessions given the same Arc and the same validation settings share one MessageBuilder, held weakly in a process-wide registry, so a process running many sessions with one dictionary pays for its parser once.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A custom data dictionary can only be supplied as a file path (
data_dictionary_path). Two situations make that awkward:MessageBuilderfor every session, each holding its own copy of the dictionary. A FIX 4.4 dictionary is close to 1 MB, so memory grows linearly with the number of sessions even when they all use the same dictionary.Change
SessionConfig::data_dictionary: Option<Arc<Dictionary>>,#[serde(skip)]so it is set in code only. When set, it takes precedence overdata_dictionary_pathand the built-in dictionary for the BeginString.Arc<Dictionary>and the samevalidate_user_defined_fieldssetting share oneMessageBuilder. The shared builders are held weakly in a small process-wide registry, so a builder is dropped with the last session using it and dead entries are pruned on the next lookup. Sessions configured without a dictionary value are unchanged and keep a builder each.SessionCtx::message_builderbecomesArc<MessageBuilder>.SessionConfigstruct literal in the workspace (unit tests, integration tests and the load-testing example) gainsdata_dictionary: None. This is a new public field, so downstream code that buildsSessionConfigwith a struct literal needs the same one-line addition.Tests
test_sessions_with_the_same_dictionary_value_share_a_message_builder: the sameArcand validation setting return the same builder; a different validation setting, or an equal dictionary in a differentArc, get their own.test_shared_message_builder_is_dropped_with_its_last_session: the registry does not keep a builder alive once its last holder is dropped.I could not build this workspace locally, so I am relying on CI for the compile, clippy and test run.
This contribution is offered under the project's MIT licence.