0
0
Jenkinsdevops~5 mins

Why notifications matter in Jenkins - Performance Analysis

Choose your learning style9 modes available
Time Complexity: Why notifications matter
O(n)
Understanding Time Complexity

We want to understand how the time it takes to send notifications grows as we add more notifications in Jenkins.

How does the number of notifications affect the total time Jenkins spends sending them?

Scenario Under Consideration

Analyze the time complexity of the following code snippet.


pipeline {
  agent any
  stages {
    stage('Build') {
      steps {
        echo 'Building...'
      }
    }
  }
  post {
    always {
      script {
        def recipients = ['dev1@example.com', 'dev2@example.com', 'dev3@example.com']
        for (email in recipients) {
          mail to: email, subject: 'Build Notification', body: 'Build completed'
        }
      }
    }
  }
}
    

This pipeline sends an email notification to each recipient after the build stage finishes.

Identify Repeating Operations

Identify the loops, recursion, array traversals that repeat.

  • Primary operation: Sending an email notification inside a loop.
  • How many times: Once for each recipient in the list.
How Execution Grows With Input

As the number of recipients grows, the total time to send notifications grows proportionally.

Input Size (n)Approx. Operations
1010 emails sent
100100 emails sent
10001000 emails sent

Pattern observation: Doubling the number of recipients doubles the work of sending emails.

Final Time Complexity

Time Complexity: O(n)

This means the time to send notifications grows directly with the number of recipients.

Common Mistake

[X] Wrong: "Sending notifications happens instantly no matter how many recipients there are."

[OK] Correct: Each notification takes time, so more recipients mean more total time spent.

Interview Connect

Understanding how notification time grows helps you design pipelines that scale well and keep teams informed efficiently.

Self-Check

"What if we sent notifications in parallel instead of one by one? How would the time complexity change?"