Skip to content

Commit

Permalink
[Fastboot] Delay PMON service for better fastboot performance (sonic-…
Browse files Browse the repository at this point in the history
…net#10567)

- Why I did it
Profiling the system state on init after fast-reboot during create_switch function execution, it is possible to see few python scripts running at the same time.
This parallel execution consume CPU time and the duration of create_switch is longer than it should be.
Following this finding, and the motivation to ensure these services will not interfere in the future, PMON is delayed in 90 seconds until the system finish the init flow after fastboot.

- How I did it
Add a timer for PMON service.
Exclude for MLNX platform the start trigger of PMON when SYNCD starts in case of fastboot.
Copy the timer file to the host bin image.

- How to verify it
Run fast-reboot on MLNX platform and observe faster create_switch execution time.
  • Loading branch information
shlomibitton authored and liushilongbuaa committed May 12, 2022
1 parent deb3822 commit a6d8da0
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 6 deletions.
1 change: 1 addition & 0 deletions files/build_templates/init_cfg.json.j2
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
{%- set features = [("bgp", "enabled", false, "enabled"),
("database", "always_enabled", false, "always_enabled"),
("lldp", "enabled", true, "enabled"),
("pmon", "enabled", true, "enabled"),
("pmon", "enabled", false, "enabled"),
("radv", "enabled", false, "enabled"),
("snmp", "enabled", true, "enabled"),
Expand Down
3 changes: 0 additions & 3 deletions files/build_templates/pmon.service.j2
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,3 @@ ExecStartPre=/usr/bin/{{docker_container_name}}.sh start
ExecStart=/usr/bin/{{docker_container_name}}.sh wait
ExecStop=/usr/bin/{{docker_container_name}}.sh stop
RestartSec=30

[Install]
WantedBy=sonic.target
12 changes: 12 additions & 0 deletions files/build_templates/pmon.timer
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Unit]
# This delay is for fast/warm reboot performance
Description=Delays pmon docker until SONiC has started
PartOf=pmon.service

[Timer]
OnUnitActiveSec=0 sec
OnBootSec=1min 30 sec
Unit=pmon.service

[Install]
WantedBy=timers.target sonic.target sonic-delayed.target
3 changes: 3 additions & 0 deletions files/build_templates/sonic_debian_extension.j2
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,9 @@ sudo cp $BUILD_TEMPLATES/mgmt-framework.timer $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_S
echo "mgmt-framework.timer" | sudo tee -a $GENERATED_SERVICE_FILE
{% endif %}

sudo cp $BUILD_TEMPLATES/pmon.timer $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM
echo "pmon.timer" | sudo tee -a $GENERATED_SERVICE_FILE

sudo cp $BUILD_TEMPLATES/sonic.target $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM
sudo LANG=C chroot $FILESYSTEM_ROOT systemctl enable sonic.target

Expand Down
11 changes: 8 additions & 3 deletions files/scripts/syncd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,15 @@ function startplatform() {

function waitplatform() {

BOOT_TYPE=`getBootType`
if [[ x"$sonic_asic_platform" == x"mellanox" ]]; then
debug "Starting pmon service..."
/bin/systemctl start pmon
debug "Started pmon service"
if [[ x"$BOOT_TYPE" = @(x"fast"|x"warm"|x"fastfast") ]]; then
debug "PMON service is delayed by a timer for better fast/warm boot performance"
else
debug "Starting pmon service..."
/bin/systemctl start pmon
debug "Started pmon service"
fi
fi
if [[ x"$BOOT_TYPE" = @(x"fast"|x"warm"|x"fastfast") ]]; then
debug "LLDP service is delayed by a timer for better fast/warm boot performance"
Expand Down

0 comments on commit a6d8da0

Please sign in to comment.