-
Notifications
You must be signed in to change notification settings - Fork 4k
Reduce memory by multiple GBs with many classic queues #6684
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
Merged
Conversation
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
6ad153c to
838c9ef
Compare
lhoguin
reviewed
Dec 16, 2022
Contributor
|
The approach seems sensible, but I'll echo what JP said, careful about Windows and weird file names. Let's test this thoroughly. |
Store directory names as binary instead of string. This commit saves >1GB of memory per 100,000 classic queues v2. With longish node names, the memory savings are even much higher. This commit is especially a prerequisite for scalalbe MQTT where every subscribing MQTT connection creates its own classic queue. So, with 3 million MQTT subscribers, this commit saves >30 GB of memory. This commits stores file names as binaries and converts back to file:filename() when passed to file API functions. This is to reduce risk of breaking behaviour for path names containing unicode chars on certain platforms. Alternatives to the implementation in this commit: 1. Store common directory list prefix only once (e.g. put it into persistent_term) and store per queue directory names in ETS. 2. Use file:filename_all() instead of file:filename() and pass binaries to the file module functions. However this might be brittle on some platforms since these binaries are interpreted as "raw filenames". Using raw filenames requires more changes to classic queues which we want to avoid to reduce risk. The downside of the implemenation in this commit is that the binary gets converted to a list sometimes. This happens whenever a file is flushed or a new file gets created for example. Following perf tests did not show any regression in performance: ``` java -jar target/perf-test.jar -s 10 -x 1 -y 0 -u q -f persistent -z 30 java -jar target/perf-test.jar -s 10000 -x 1 -y 0 -u q -f persistent -z 30 java -jar target/perf-test.jar -s 10 -x 100 -qp q%d -qpf 1 -qpt 100 -y 0 -f persistent -z 60 -c 1000 ``` Furthermore `rabbit_file` did not show up in the CPU flame graphs either.
acef343 to
b0d0308
Compare
Collaborator
|
Test process for Windows:
|
lukebakken
approved these changes
Jan 4, 2023
michaelklishin
added a commit
that referenced
this pull request
Jan 4, 2023
Reduce memory by multiple GBs with many classic queues (backport #6684)
Merged
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.
Store directory names as binary instead of string.
This commit saves >1GB of memory per 100,000 classic queues v2. With longish node names, the memory savings are even much higher.
This commit is especially a prerequisite for scalable MQTT where every subscribing MQTT connection creates its own classic queue.
So, with 3 million MQTT subscribers, this commit saves >30GB of memory.
This commits stores file names as binaries and converts back to
file:filename()when passed to file API functions. This is to reduce risk of breaking behaviour for path names containing unicode chars on certain platforms.Prior to this commit, a classic queue process state contained many lists:
Alternatives to the implementation in this commit:
file:filename_all()instead offile:filename()and pass binaries to the file module functions. However this might be brittle on some platforms since these binaries are interpreted as "raw filenames". Using raw filenames requires more changes to classic queues which we want to avoid to reduce risk.The downside of the implemenation in this commit is that the binary gets converted to a list sometimes.
This happens whenever a file is flushed or a new file gets created for example.
Following perf tests did not show any regression in performance:
Furthermore
rabbit_filedid not show up in the CPU flame graphs either.It showed up only once with
0.1%in a page fault flame graph.