Skip to main content
Pixel art: Ellen Spertus strides energetically on the left in a Kotlin t-shirt and jeans, surrounded by swirling panels for Performance (speedometer), Safety (Swiss cheese), and Sustainability (circuit-board tree), with a palm tree behind her. Jonathan Bell stands calmly on the right in a dark blazer beside a retro monitor displaying 'Cheese Module' with pixel-art cheese, at a wooden podium with a laptop. A sign between them reads 'Same Topics. Different Speeds.' Banner: Performance, Safety & Sustainability.

CS 3100: Program Design and Implementation II

Lecture 37: Performance, Safety, and Sustainability

©2026 Jonathan Bell & Ellen Spertus, CC-BY-SA

Looking Ahead

  • Today
    • Lecture: Highlights of skipped lectures Performance, Safety, and Sustainability
    • Practice final distributed
    • TRACE
  • Tuesday
    • Lab 14: The Future of Programming
  • Wednesday
    • Lecture: MapReduce and the Future of Programming
  • Thursday
    • Lecture: Review
    • Course Survey
    • Due date: Feature Buffet
  • Next Monday, 4/20
    • Due date: Final Project Report
  • Next Tuesday, 4/21
    • Final exam, 10:30-12:30

L34: Performance

Pixel art: SceneItAll hub with a speedometer. LEFT side shows slug-slow sequential device chain in orange. RIGHT side shows fast parallel processing in teal with green checkmarks. A magnifying glass labeled PROFILE hovers over the hub. Tagline: Measure, Don't Guess.

Learning Objectives

After this lecture, you will be able to:

  1. Reason about algorithmic growth using Big-O notation
  2. Identify* performance bottlenecks: measure, don't guess
  3. Analyze the performance impact of architectural decisions
  4. Apply common patterns to improve performance


  • You will know that tools exist to find performance bottlenecks.

Big-O Describes How Code Scales, Not How Fast It Is

Colored graph showing O(log n) [dark green, excellent];
O(1) [light green, good];
O(n) [yellow, fair];
O(n log n) [orange, bad];
O(n^2), O(2^n), and O(n!) [red, horrible]

CC-BY-2.0 Dunk

Poll: Rank operations by increasing time complexity

A. Comparing every pair of items in a list

B. Performing binary search

C. Retrieving a value from a key in a HashMap

D. Searching for an item by iterating over a list

E. Sorting a list

Poll Everywhere QR Code or Logo

Text espertus to 22333 if the
URL isn't working for you.

https://pollev.com/espertus

Assume all data structures have n items.

Big-O in SceneItAll

NotationNameSceneItAll example
O(1)ConstantHashMap lookup by device id
O(log n)LogarithmicBinary search sorted devices
O(n)LinearIterate all devices by name
O(n log n)LinearithmicSort 1,000 devices
O(n²)QuadraticCompare every device pair

Linear search can be faster than binary search — when n is small.
Big-O is about what happens for large inputs.

Flame Graphs Show Where Time Goes

Simplified flame graph: computeOptimal() is a red bar (40% CPU, the bottleneck) while getById() is a tiny blue bar (2% CPU, negligible despite high call count)

Tools (know they exist, not details): JFR (Java Flight Recorder, built into JDK), flame graphs, heap dumps

Performance Has Several Dimensions That Trade Off

MetricWhat it measuresExample
LatencyTime for a single operation"How long until the user sees their grade?"
ThroughputOperations per unit time"How many submissions per minute?"
MemoryHeap/stack consumption"How much RAM for 1,000 devices?"
CPUProcessor time consumed"CPU-bound or I/O-bound?" (recall L32)

Optimizing one can worsen another: caching reduces latency but increases memory.

Bonus Slide

Pixel art: five Swiss cheese slices as defense layers. Left side has holes aligned with a red danger beam passing through. Right side has offset holes blocking all light. Labels on slices: Tests, Reviews, Rollout, Override, Monitoring. Tagline: Every Layer Has Holes.

Learning Objectives

After this lecture, you will be able to:

  1. Distinguish safety from reliability
  2. Apply the Swiss cheese model to analyze layered defenses
  3. Analyze blast radius and fail-safe design
  4. Recognize prior course concepts as safety mechanisms
  5. Evaluate safety trade-offs against cost, complexity, and performance, and explain why professional judgment is currently the primary safety mechanism in most software

Reliable, Available, and Safe Are Three Different Things

Reliable

Does what it's supposed to do, consistently.

Measure: error rates, MTBF

SceneItAll: activates scenes correctly 99.99% of the time

Available

Accessible when users need it.

Measure: "nines" — 99.9% = 8.7 hrs downtime/yr

GitHub: multiple major outages Feb–Mar 2026 (auth DB overload, Actions failover failures)

Safe

Avoids harm, even when it fails.

Measure: incident severity — did anyone get hurt?

Key: a property of the failure mode, not the happy path

  • Reliable and unsafe: A medical device delivers correct doses 99.99% of the time — but its failure mode is lethal. Reliable? Extremely. Safe? Not if one failure kills a patient.
  • Safe but unreliable: Hub crashes frequently but preserves device state.

Poll: How does the cost of fixing safety issues grow?

As a product moves from design through implementation, launch, and widespread use, how does the cost of addressing safety issues grow?

A. It stays about the same

B. It increases linearly

C. It increases exponentially

Poll Everywhere QR Code or Logo

Text espertus to 22333 if the
URL isn't working for you.

https://pollev.com/espertus

A firmware update on day one is moderate effort. After a bricking incident, it's a migration plus legal costs, customer replacements, and reputational damage.

The Swiss Cheese Model: Harm Requires Aligned Holes

Swiss cheese model: four defense layers as cheese slices. Top: holes align and a hazard arrow passes through to cause harm. Bottom: holes don't align and the hazard is blocked. Labels: Contracts, Testing, Architecture, Monitoring.

A single layer with holes is not necessarily dangerous on its own. The problem is when someone removes a layer entirely, or when holes grow larger without anyone noticing.

Poll: What would it take to convince you that software is bug-free?

A. 100% coverage (branch and line) by tests

B. expert human code review

C. AI review

D. all of the above

E. none of the above

Poll Everywhere QR Code or Logo

Text espertus to 22333 if the
URL isn't working for you.

https://pollev.com/espertus

Three Disasters, One Pattern: Removing Layers Is Removing Safety

AspectTherac-25Boeing 737 MAXCrowdStrike Falcon
What was replaced?Hardware interlocksAirframe redesign + pilot trainingManual security review
Replaced with?Software safety checksMCAS software automationAutomated content update pipeline
Why?Cheaper, lighterCheaper, faster certificationSpeed — security threats need rapid response
Layer removed?Hardware interlock layerSensor redundancy + trainingStaged rollout for content updates
Critical flaw?Race conditionsSingle point of failureNo rollback path when kernel crashes
Consequences?People received lethal radiationPlanes crashed8.5M machines soft-bricked

Three questions to ask when replacing hardware/human judgment with software:

  1. What failure modes does software introduce that the original didn't have?
  2. Is there redundancy? What happens when the single sensor/input fails?
  3. Can humans override the automation when it's wrong?

Bonus Slide

Dilbert cartoon with 3 panels, including Alice and the Pointy-Haired Boss (PHB).
Panel 1: Alice is giving a presentation and says: 'Our disaster plan goes something like this...'
Panel 2: Alice points at a slice of a panicked person yelling 'Help! Help!'
Panel 3: Alice offstage says 'Someday we hope to have a budget' as PHB glares.
Dilbert cartoon dated 1/29/97 where Dilbert talks with the Pointy-Haired Boss (PHB), who is seated at a desk.
Dilbert: 'As you requested, here is a schedule of all future unplanned network outages...I took the initiative to include a schedule of all future sick days, volcanic eruptions, earthquakes, and hurricanes...This is the point when you realize how stupid your request was and we have a good laugh.'
PHB (looking at piece of paper, eyes wide open in alarm): 'Does CNN know about this?'

Sustainability

Pixel art timeline: LEFT a small seedling on a circuit board, CENTER a thriving tree with diverse people around it, RIGHT the same tree with underground roots visible as glowing interconnected circuits — some roots fraying in orange/red. Tagline: The Integral of Programming Over Time.

Learning Objectives

After this lecture, you will be able to:

  1. Define software sustainability as a meta-quality attribute
  2. Apply the four dimensions of sustainability to evaluate design trade-offs
  3. Recognize how efficiency gains can increase total resource consumption
  4. Evaluate who benefits and who bears risk in design trade-offs

From Safety to Sustainability: Generalizing "Who Profits, Who Bears Risk?"

In L35, we saw Boeing sell sensor redundancy as an optional upgrade. Budget airlines saved money. Passengers bore the risk — without knowing it.

That distributional question — who benefits, who pays, over what time horizon — is the core question of sustainability.

L1 callback: "Software engineering is the integral of programming over time." Every lecture since has been about what that integral measures. Today we name it.

SceneItAll's Success Disaster

SceneItAll launches. 50 beta homes. Everything works. Fast, reliable, safe. Great reviews.

What went rightWhat happened next
Fast firmware updatesTeam pushes 10x more often; total traffic doubles
Reliable occupancy sensingInsurance companies want the data; users never consented
Accessible on modern phones100,000 homes; users with screen readers can't configure scenes
Free cloud tier covers costsGrowth past the free tier; locked into vendor pricing
Small team ships fastOriginal devs leave; no one understands the Zigbee adapter code

Nothing broke. The system succeeded — and the success created problems the original design never anticipated.

Sustainability: What Happens When This Succeeds?

Definition (Patricia Lago et al.): "Preservation of long-term beneficial use of software, and its appropriate evolution, in a context that continuously changes."

The key word is "beneficial." SceneItAll's occupancy data is useful — for the homeowner. It's harmful — for the homeowner whose data is sold. Same feature, different stakeholders, different time horizon.

Sustainability is not another quality attribute to add to the list. It is the meta-quality attribute — it asks whether all the other quality attributes (performance, safety, accessibility, changeability) hold up over time, and for whom.

Lago distinguishes two directions: sustainable software (inward — is the artifact itself maintainable, efficient, evolvable?) and software for sustainability (outward — does the software support sustainable processes in the world?). Both matter.

Safety vs. Sustainability: Two Different Questions

Safety (L35)

"What happens when this fails?"

  • Therac-25 race condition
  • Boeing single sensor
  • CrowdStrike boot loop

Focus: failure modes. Who gets hurt when things go wrong?

Sustainability (today)

"What happens when this succeeds?"

  • SceneItAll occupancy data sold
  • Pawtograder narrows curriculum
  • LLM subsidy reshapes labor market

Focus: success modes. Who bears the cost when things go right?

Technical Sustainability: Can the System Be Maintained and Evolved?

Four overlapping circles: Technical (blue, highlighted), Economic (green), Environmental (orange), Social (purple). Overlaps show tension between dimensions.

The dimension you know best. Low coupling, testability, readable code, clear contracts.

SceneItAll: Hexagonal architecture (L16) lets the team swap the Zigbee adapter for a Matter adapter without rewriting scene activation logic.

The test: Can a new developer join and make changes? Can you replace a dependency without a rewrite?

Economic Sustainability: Is the Total Cost of Ownership Viable?

Beyond hosting costs: developer time, dependency cost, lock-in risk, support burden, opportunity cost.

Pawtograder: GitHub Actions free tier covers current grading volume — but growth past the free tier means GitHub's pricing, not yours. And if GitHub changes their API? Every autograder integration breaks.

License changes are an economic hazard: MongoDB (AGPL to SSPL), HashiCorp (MPL to BSL) — your dependency's license can change under you.

L23 Recall: OpenSSL secured most of the internet — maintained by a handful of volunteers until Heartbleed exposed how underfunded critical infrastructure can be. Economically unsustainable open source is a supply chain risk for everyone who depends on it.

Environmental Sustainability: What Resources Does the System Consume?

Direct compute costs (energy, hardware, cooling) plus indirect effects (does the system enable behaviors that consume more resources?).

L20 callback: "Every network request requires CPU cycles, network interface power, router power, server CPU, data center cooling." Batching saves energy, not just latency.

Social Sustainability: Who Does the System Serve?

Accessibility (L28), inclusivity, fairness, privacy. Indirect stakeholders emerge over time.

SceneItAll usage analytics:

  • At 50 beta homes — occupancy data is a debugging tool
  • At 100,000 homes — the same data is a burglary-risk or insurance-discrimination vector

The system didn't change. The stakeholder population did.

The Dimensions Interact — and Conflict

DecisionTechnicalEconomicEnvironmentalSocial
Monolith to microservicesBetter: independent deploymentWorse: operational complexityWorse: network overhead, container sprawl (L20)Neutral
Add WCAG accessibilityModerate effortHigher dev costNeutralBetter: inclusive (L28)
Switch to serverlessModerate: vendor-specific APIsBetter: pay-per-use (L21)Mixed: no idle waste but cold start overheadWorse: vendor lock-in limits self-hosting
Keep all telemetry foreverSimpler: no retention policyWorse: storage costs grow linearlyWorse: ~98% of data center data is "dark data" — never used (Lago)Worse: privacy risk grows with data volume

No decision optimizes all four. Sustainability analysis makes trade-offs visible — not resolved.

Discussion

In the 1860s, improvements in coal engines led to greater efficiency (less coal required for the same amount of work).

Do you think this led to less or more coal usage?

Jevons' Paradox: Efficiency Is Not Sustainability

1865: More efficient coal engines led to more total coal consumption. Efficiency made it cheaper, expanding use faster than per-unit savings.

TechnologyPer-unit gainTotal consumption
Cloud computingCheaper per hourTotal energy skyrocketed
Web + CDNsFaster per bytePages: 100KB → 4MB
CI/CDCheaper per buildVastly more builds
LLM inferenceCheaper per tokenAI compute exploding
Chart showing Jevons paradox: per-unit cost trends down (blue) while total consumption trends sharply up (red), crossing to show that efficiency increases total usage

Making software faster/cheaper does not automatically make it more sustainable.

The Jevons Cycle: Why Efficiency Feeds Itself

The loop is self-reinforcing. Each efficiency gain makes the next round of expansion cheaper.

You're Living Inside Jevons' Paradox: Pawtograder

Efficient automated grading enables unlimited submissions. Students submit 3,000-12,000 times per day across the course.

Before: submit once, human grades. The system is more efficient; the total resource consumption is higher.

LLMs: Jevons' Paradox as a Business Strategy

Per-token API prices have dropped across model generations even as power and usage have surged.

Cost layerWho paysWho benefits
GPU hardware + energyCloud providers (passed to AI companies)Developers using the tools
Training data creationOriginal authors (often unconsented)AI companies + users
Subsidy gap (~$200 vs ~$5,000 estimate)AI company investors (for now)Individual developers
Environmental externalityEveryone (carbon emissions)Direct users of the service
Labor displacement riskWorkers in affected rolesCompanies reducing headcount

"Who profits, who bears risk?" applied to the tools you use every day.

Digital Sufficiency: Should We Build This at All?

Jevons asks whether efficiency reduces total consumption. Sufficiency asks a more radical question: is this technology needed in the first place?

Efficiency questionSufficiency question
How do we make this drone software more energy-efficient?Efficient medical drones get cheap enough to become toys — negating all the efficiency gains at scale
How do we optimize data center storage?Should we be storing 98% "dark data" that no one will ever read?
How do we make LLM inference cheaper per token?Should you be using an LLM for this task, or would grep do?
How do we make SceneItAll updates faster?Does every light bulb need a WiFi chip and cloud connection?

First, Second, and Third-Order Effects

1st-order (direct)2nd-order (behavioral)3rd-order (systemic)
SceneItAllHub uses power to runConvenience increases total energy use; usage data reveals when you're homeInsurance pricing and surveillance reshape around smart-home data
PawtograderEach submission uses computeUnlimited submissions change study habits — autograder becomes the debuggerIf every course auto-grades, assignments gravitate toward what's auto-gradeable, narrowing what students learn
LLM AgentsGPU inference per promptDevelopers write more code, explore more approaches, iterate fasterLabor market restructures; codebases grow faster than teams can understand them

"If this system is wildly successful, what behaviors does it enable, and who is affected?"

Real Decision: The Azure Outage

October 2025. Azure goes down. GitHub Actions stops running. Pawtograder can't grade submissions. Two options:

Option A: Self-hosted fallbackOption B: Stay GitHub-dependent
TechnicalComplex failover logic; two systems to maintainSimpler architecture; single system
EconomicDuplicate infrastructure costsLeverage free tier; lower total cost
EnvironmentalIdle fallback resources most of the timeShared infrastructure, higher utilization
SocialResilient — students don't lose access during outagesEqual access for all institutions (no self-hosting expertise needed)

No right answer. The four-dimensional analysis makes the trade-offs visible.

System Design Is Never Value-Neutral

The Karlskrona Manifesto on Sustainability Design (2015): foundational consensus document from ~30 software engineering researchers.

Core principle: every architecture, API, and default setting reflects assumptions about who matters and what matters.

Sustainability is the practice of making those assumptions explicit and revisiting them as the system and its context evolve.

Every Design Decision Encodes a Value Judgment

Pawtograder's choices encode values — whether we thought about them or not:

  • Unlimited submissions values learning-by-iteration over compute efficiency
  • Requiring GitHub values standardization over universal access
  • Auto-grading values scale over human nuance

The question is not whether your design encodes values. It's whether you chose them deliberately.

The Integral of Programming Over Time

L1: "Software engineering is the integral of programming over time."

Sustainability is what that integral computes.

Go build software that provides value over time, to the people who need it, without imposing unacceptable costs on the people who don't.

The State of CS 3100

This class has been challenging. We want to improve it.

Plans:

  • Administration will carefully review TRACE feedback.
  • We will offer another survey (with credit).

In the remaining time, please:

  • Complete TRACE
  • Suggest/upvote/downvote questions for the survey