Skip to content
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

Syn decode in publisher #6

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

DaemonSnake
Copy link
Collaborator

@DaemonSnake DaemonSnake commented Feb 7, 2025

move decoding of raw binary messages out of the hot-path
might help reduce walex lag

@@ -1,6 +1,7 @@
defmodule WalEx.Event.Dsl do
defmacro process_events_async(events, functions) do
module = hd(__CALLER__.context_modules)
[_ | _] = __CALLER__.context_modules
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this line useful?

Copy link
Collaborator Author

@DaemonSnake DaemonSnake Feb 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, context_modules can be an empty list according to its type
if so this macro should crash
List.first returns a nil value in that case

@DaemonSnake DaemonSnake force-pushed the syn-decode-in-publisher branch from 7c286f0 to 964578e Compare February 10, 2025 09:16
Experiment to check if moving decoding in Publisher and outside the main
connection server allows to increase its throughput
error:

    warning: incompatible types given to Kernel.hd/1:

        hd(__CALLER__.context_modules)

    given types:

        list(atom())

    but expected one of:

        non_empty_list(term(), term())

    typing violation found at:
    │
  3 │     module = hd(__CALLER__.context_modules)
    │              ~
    │
    └─ lib/walex/event/dsl.ex:3:14: WalEx.Event.Dsl.process_events_async/2
@DaemonSnake DaemonSnake force-pushed the syn-decode-in-publisher branch from 964578e to c748033 Compare February 10, 2025 09:20
…an receive many messages

following erlang doc:

> If the process may potentially accumulate a large number of messages in its queue it is recommended to set the flag value to off_heap.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants