-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Documentation on skip_grains #53603
Documentation on skip_grains #53603
Conversation
Nice! I'm not familiar with the implications here, but it certainly seems like a reasonable improvement! 👍 |
@dwoz, I would kindly ask for guidance how to write tests for this PR. I think testing must show that all current tests of RunnerClient and MasterMinion, as long as they do not use grains, continue to pass when the proposed options are set to False. I assume the My understanding is that runners are tested in https://github.com/saltstack/salt/blob/develop/tests/integration/client/test_runner.py Can the
The test of EventReturn must be accordingly modified, because it invokes MasterMinion, too. |
…s an integration test
…on_omit_grains_on_master
@markuskramerIgitt I'm not sure this change makes sense to add Yet Another Config Item (or two) for a special case. What you can do instead to effectively mitigate this change is something like:
|
Good point! What bothers me most is that nobody knows what else will break when the grains are disabled. Existing unit tests can't uncover potential problems because they do not use these options. Someone WILL attempt to run other code paths in this mode, and it will lead to more stale issues, and more complains that Salt is complex and buggy. This performance problem is important, but the resulting complexity and combinatorial explosion of possible code paths are worse and much harder to fix. It is not the first time when a grain-related optimization hack is submitted: #49481 UPD: recently I spent hours debugging the grains caching issue #53536 |
Hi @mattp, I have to admit, I too dislike the addition of these 2 new config items. You introduced LazyLoading for functions in PR #53553, which I noticed a few days ago, only realizing now, you are the author. If grains could be lazy loaded, it could deliver the performance improvements we need, while those who use grains should not notice a difference, without the addition of config items. Regarding grains_cache: In our setup, the only grain we need is the id of the minion, which comes with the event. So essentially we don’t use grains. Therefore, I would not profit from the content of a Therefore I would like to continue with “lazy loaded grains”. |
Hi @max-arnold, thank you for pointing to the existing grains performance discussions! I completely agree with you that config items complicate testing (“combinatorial explosion of possible code”). I now realize my proposed new config items are very naïve. Please allow me to replace them with a better solution - what do you think of “lazy loaded” grains? |
@markuskramerIgitt
I do not know the codebase well enough, but at first glance it looks like a good idea that could be explored. Do you want to lazy-load grains on a minion? How this could affect accessing grains on a master (for example in a pillar file)? Another option is to achieve your goal in a different way:
And (out of curiosity), how did you make this nice profiling graph on a master? |
@markuskramerIgitt thats an interesting an idea! but let me revisit your response to the grain cache first: |
@markuskramerIgitt also echoing @max-arnold im curious what you used to create that profiling output, seems very useful/nice on the eyes 🙂 |
Hi @max-arnold,
My focus is to enhance performance of the master, but I guess lazy-loading (if feasible) should not differentiate between master and minion.
My understanding is, that “lazy loading“ grains would happen “as late as possible”, in confront with “as soon as possible” as of now, but otherwise it must be completely transparent. I am not familiar with pillars, but the entity loading grains should also not matter.
If the runner that reacts on the minion_ping finds no Redis flag
I actually mean Python modules of this type (runners).
I must restrict access to Redis (or maybe memcache, which seems to be installed with Salt) to the master.
Thank you, I need to assess these concepts and will come back to you.
I would not know. I don’t intentionally call them, the RunnerClient does. I only observe them in the profile output.
Thank you, but I made them on Windows. See How to create master profiling graphs on Windows I guess the same tools could run on a master (I only have tty access to the master) |
Hi @mattp
I will try that later. The short circuit is only effective on a repetition within
I start to understand that “deferring” and “lazy loading” are separate effects. I fail to access the grains that the MasterMinion in the RunnerClient load. |
@waynew, I removed the test cases and turned this PR into pure documentation - could you please review? |
re-run all |
@markuskramerIgitt Could you please rebase it to |
Hi @DmitryKuzmenko |
@markuskramerIgitt thank you! |
Introduction
Our master overloaded when we deployed a new minion configuration, in which minions regularly “ping” the salt-master and the salt-master reacts to the minion_ping event (with a runner).
The load exceeded 0.5, after approx. 10% of the Minions were pinging.
The salt-master receives a minion_ping every 2 seconds from different minions.
Therefore we stopped the deployment and profiled the salt-master.
Profiling showed that
grains
(green) create 33.61% load, called byMasterMinion
(yellow), called byRunnerClient
(orange).We found this description of MasterMinion in salt/minion.py:
A RunnerClient creates a MasterMinion but also omits states and renderer
In salt/client/mixins.py:
Our RunnerClients don’t need grains. Therefore, we omitted them with the undocumented
skip_grains
setting.We set
skip_grains: True
at 06-18 15:45 and observed an significant (16-fold) and necessary load drop:We later also observed a significant improvement when restarting the master:
skip_grains: False
skip_grains: False
skip_grains: True
Content
Created documentation on
skip_grains
History
This PR first contained new config items to omit grains in the MasterMinion, along the lines of:
Adding new config items received constructive negative feedback, see below.
As we found the existing config item
skip_grains
, which serves our purpose when set toTrue
on the master, we removed the new config items from this PR.