saltstack / saltstack/salt

Performance problem in ini_manage module

Open
#38,152 7 comments 3 reactions 1 assignee View on GitHub

@MKLeb is already working on this.

Since Sep 8, 2023.

bug Performance Platform severity-medium State-Module
Dominant language
Python
Stars
15.7k
Forks
5.6k
Avg merge
2d 44m
Merged PRs (30d)
80

Description

Try to edit default php.ini in CentOS 7 and see strange delay in test mode - 37 seconds with 99% CPU consumption by salt-minion. In real work mode job finishes fast enough - just 7 seconds. But, as for me, 7 seconds is too much too. Tried to remove all empty lines and comments (1626 lines were deleted) - result became 176.434 ms in test mode. Is there any possibility to improve ini_manage module performance ?
I use the latest version - 2016.11.0 (both master and minion).

P.S. In previous release (2016.3.4) test mode lasted 158 seconds, it was awesome.

php-ini.sls:

php-ini:
  ini.options_present:
    - name: /etc/php.ini
    - sections:
        PHP:
          short_open_tag:                      On
          expose_php:                          Off
          max_execution_time:                  30
          memory_limit:                        700M
          error_reporting:                     E_ALL & ~E_DEPRECATED & ~E_STRICT & ~E_NOTICE
          display_errors:                      Off
          log_errors:                          On
          post_max_size:                       8M
          cgi.fix_pathinfo:                    0
          fastcgi.logging:                     1
          upload_max_filesize:                 2M
          allow_url_fopen:                     On
          allow_url_include:                   Off
        Date:
          date.timezone:                       Europe/Kiev
        mail function:
          mail.add_x_header:                   Off
        Session:
          session.use_strict_mode:             1
          session.gc_probability:              1
          session.gc_divisor:                  100
        opcache:
          opcache.enable:                      0
          opcache.enable_cli:                  0

Test mode command:

# time salt --state-verbose=true --state-output=full 'minion' state.sls php-ini test=true
minion:
----------
          ID: php-ini
    Function: ini.options_present
        Name: /etc/php.ini
      Result: None
     Comment: Key short_open_tag in section PHP unchanged.
              Key expose_php in section PHP unchanged.
              Key max_execution_time in section PHP unchanged.
              Key memory_limit in section PHP unchanged.
              Key error_reporting in section PHP unchanged.
              Key display_errors in section PHP unchanged.
              Key log_errors in section PHP unchanged.
              Key post_max_size in section PHP unchanged.
              Key cgi.fix_pathinfo in section PHP unchanged.
              Key fastcgi.logging in section PHP unchanged.
              Key upload_max_filesize in section PHP unchanged.
              Key allow_url_fopen in section PHP unchanged.
              Key allow_url_include in section PHP unchanged.
              Changed key date.timezone in section Date.
              Key mail.add_x_header in section mail function unchanged.
              Key session.use_strict_mode in section Session unchanged.
              Key session.gc_probability in section Session unchanged.
              Key session.gc_divisor in section Session unchanged.
              Key opcache.enable in section opcache unchanged.
              Key opcache.enable_cli in section opcache unchanged.
     Started: 13:41:24.908048
    Duration: 36837.488 ms
     Changes:   

Summary for minion
------------
Succeeded: 1 (unchanged=1)
Failed:    0
------------
Total states run:     1
Total run time:  36.837 s

real    0m40.082s
user    0m1.341s
sys     0m0.201s

Editing mode:

# time salt --state-verbose=true --state-output=full 'minion' state.sls php-ini
minion:
----------
          ID: php-ini
    Function: ini.options_present
        Name: /etc/php.ini
      Result: True
     Comment: Changes take effect
     Started: 13:51:26.311462
    Duration: 7648.754 ms
     Changes:   
              ----------
              Date:
                  ----------
                  date.timezone:
                      ----------
                      after:
                          Europe/Kiev
                      before:
                          None

Summary for minion
------------
Succeeded: 1 (changed=1)
Failed:    0
------------
Total states run:     1
Total run time:   7.649 s

real    0m11.664s
user    0m0.922s
sys     0m0.150s

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.