遇见数据集

Watts This Smell: A Comprehensive Taxonomy of Software Energy Smells

收藏
Zenodo2026-03-07 更新2026-05-26 收录
官方服务:

资源简介:

Energy-Smells Taxonomy and Classification Abstract As software proliferates across domains, its aggregate energy footprint has become a major concern. To reduce software's growing environmental footprint, developers need to identify and refactor energy smells: source code implementations, design choices, or programming practices that lead to inefficient use of computing resources. Existing catalogs of such smells are either domain-specific, limited to performance anti-patterns, lack fine-grained root cause classification, or remain unvalidated against measured energy data. In this paper, we present a comprehensive, language-agnostic, taxonomy of software energy smells. Through a systematic literature review of 60 papers and exhaustive snowballing, we coded 320 inefficiency patterns into 12 primary energy smells and 65 root causes mapped to the primary smells. To empirically validate this taxonomy, we profile over 21,000 functionally equivalent Python code pairs for energy, time, and memory, and classified the top 3,000 pairs by energy difference using a multi-step LLM pipeline, mapping 55 of the 65 root causes to real code. The analysis reveals that 71% of samples exhibit multiple co-occurring smells, memory-related smells yield the highest per-fix energy savings, while power draw variation across patterns confirms that energy optimization cannot be reduced to performance optimization alone. Along with the taxonomy, we release the labeled dataset, including energy profiles and reasoning traces, to the community. Together, they provide a shared vocabulary, actionable refactoring guidelines, and an empirical foundation for energy smell detection, energy-efficient code generation, and green software engineering at large. This repository contains the dataset, methodology, and pipeline used for our research to define a comprehensive, language-agnostic taxonomy of software energy smells. It tracks energy inefficiencies from the root cause (sub-category) to a broader energy smell (category) and validates this using execution energy profiling and LLM-based classification. Taxonomy reference: The full taxonomy — all 12 categories and 65 subcategories with descriptions and examples — is documented in taxonomy.md. Directory Structure Energy-Smells ├── codenet/ # Test cases for Python programs ├── energy_smell_classifier/ # LLM classification pipeline │ ├── classify_smells.py # Main script to classify energy smells via DeepSeek LLM │ ├── organize_classified_smells.py # Script for post-processing classification output │ ├── prompts.py # Prompt templates for the 3-step LLM classification │ ├── simulate_prompts.py # Utility to test and simulate prompt iterations │ └── utils.py # Helper functions for the LLM pipeline ├── literature_review_results/ # Stages of the systematic literature review │ ├── v1_literature_review_collection.xls │ ├── v2_literature_review_filtering.xls │ ├── v3_literature_review_annotator1_relevant_check.xls │ ├── v3_literature_review_annotator2_relevant_check.xls │ ├── v4_discussion_literature_review.xlsx │ ├── v5_relevant_kept_only_concatenated.xlsx │ ├── v6_annotator1_opencoding.xlsx │ ├── v6_annotator2_opencoding.xlsx │ ├── v7_energy_smells_taxonomy.xlsx │ └── v7_energy_smells_taxonomy_python_desc.xlsx ├── dataset/ # Prepared public dataset ready for sharing │ ├── public_classified_smells.jsonl # Public version of the classified dataset │ ├── public_significant_energy_diff.jsonl # Public version of significant energy diffs │ └── public_validated_energy_results.jsonl # Public version of energy measurements ├── energy_results.jsonl # Intermediate dataset with energy measurements ├── taxonomy.md # Full taxonomy: all 12 categories and 65 subcategories with descriptions ├── energy_smells_taxonomy.xlsx # Final defined taxonomy ├── filter_significant_energy.py # Script to isolate pairs with high energy divergence ├── measure_energy.py # Script to run perf tools and record energy/memory/time ├── requirements.txt # Python dependencies ├── significant_energy_diff.jsonl # Filtered dataset containing significant top pairs ├── test_runner.py # Wrapper script to execute tests iteratively ├── train.jsonl # Input list of problem pairs from Pie-Perf dataset ├── validate_correctness.py # Script to ensure functional equivalence of code pairs ├── validated_train.jsonl # Validation outputs ├── warmup.py # Helper script to busy-wait the CPU before profiling └── analysis/ # Replication package: analysis script + dataset + generated results ├── analysis.py # Full quantitative analysis and plot generation └── result/ # Auto-generated: plots (.png/.pdf) + analysis_results.txt ├── classification_both_annotators_validation.xlsx # Validation of pipeline classification by both annotators └── classification_both_annotators_validations.xlsx Methodology Overview The primary objective of this project is to categorize inefficiencies into a two-level hierarchy mapping: Energy Smell (Category): High-level observable patterns of resource waste that occur without altering the program's correctness. Root Cause (Sub-category): The specific technical misstep triggering the waste. Systematic Literature Review The literature_review_results/ folder captures the rigorous 5-phase systematic mapping study used to extract and classify patterns: Phase 1 & 2 (v1, v2): Primary text query on Scopus and recursive snowballing of 400+ papers, resulting in an initial extraction of performance/energy anti-patterns. Phase 3 (v3_1, v3_2, v4, v5): Dual-annotator assessment using inclusion/exclusion criteria to verify cross-language generalizability and relevance to Python. Phase 4 (v6_1, v6_2): Qualitative coding to distill 320 remaining patterns down to their fundamental root causes via open and axial coding. Phase 5 (v7): Taxonomy conflict resolution. The final result is a taxonomy comprising 12 top-level Energy Smells and 65 underlying Root Causes. Pipeline Usage & Replication Follow these steps sequentially to replicate the dataset validation, measurement, and classification mechanisms: 0. Setup Virtual Environment It is highly recommended to use a virtual environment to manage dependencies: python -m venv venv source venv/bin/activate pip install -r requirements.txt 1. Validate Correctness Evaluate the dataset pairs (efficient vs. inefficient Python versions) using predefined tests from train.jsonl to ensure identical behavior. python validate_correctness.py What this does: It reads code snippets from the dataset, runs 5 random tests per problem natively using Python subprocess, and verifies both snippets return identically correct outputs. Non-matching pairs or timeouts are discarded. Outputs are saved to validated_train.jsonl. 2. Measure Energy Consumption Profile the validated code snippets to gather actual energy usage metrics. python measure_energy.py What this does: Reads the functionally validated pairs. For each program, it performs a CPU warm-up (using warmup.py), and executes the snippets iteratively (via test_runner.py) wrapping them within the Linux perf stat (extracting energy-pkg and energy-ram Joules) and /usr/bin/time -v (extracting Maximum Resident Set Size). Results are appended to energy_results.jsonl. (Note: Depending on your system configuration, utilizing perf stat for hardware energy events might require administrative privileges or kernel parameter adjustments). Dataset Fields Added: result_energy_v0 / result_energy_v1: Total Energy Joules. result_time_v0 / result_time_v1: Elapsed time in seconds. result_memory_v0 / result_memory_v1: Peak Memory (RSS) in KB. 3. Filter Significant Energy Differences Locate instances that yield a high gap between efficient and inefficient code performance to ensure meaningful LLM classification. python filter_significant_energy.py What this does: Reads energy_results.jsonl into a Pandas DataFrame, calculates the absolute energy difference (ΔEnergyΔEnergy), and retains the top 3,000 thresholded pairs. This process guarantees extreme deviations are highlighted, writing the trimmed rows into significant_energy_diff.jsonl. Dataset Fields Added: unique_index: A persistent ID mapping back to the row index of energy_results.jsonl. 4. Classify Energy Smells via LLM Execute the multi-step DeepSeek pipeline to label the fundamental root causes of the 3,000 selected instances. # Ensure API_KEY and other parameters are supplied via .env cd energy_smell_classifier python classify_smells.py What this does: Parses significant_energy_diff.jsonl and performs a sequential three-prompt analysis per instance using a highly threaded executor: Root Cause Analysis: Extracts the technical reason the inefficiency exists, combining problem descriptions, code diffs, energy, time, and memory metrics. Category Triage: Maps the determined root cause to the most applicable of the 12 primary Energy Smell labels. Subcategory Classification: Identifies the most precise Subcategory tags within the selected parent smell. Classification responses and AI rationale strings stream directly into .jsonl outputs located in the energy_smell_classifier folder. Dataset Fields Added: energy_diff: The absolute energy difference between efficient and inefficient code. llm_step1_root_cause, llm_step2_candidates, llm_step3_final: Raw structured JSON output from the model. llm_step1_reasoning, llm_step2_reasoning, llm_step3_reasoning: The DeepSeek Chain-of-Thought (CoT) reasoning traces. final_classification: The conclusive list of predicted Root Cause subcategories (e.g., ["C1.S2", "C3.S1"]). You can inspect the details of expected fields generated by LLMs in energy_smell_classifier/prompts.py. 5. Run Analysis & Generate Plots Reproduce all quantitative findings and figures from the manuscript. cd analysis python analysis.py What this does: Loads classified_smells_final.jsonl, computes all statistics reported in the manuscript, and saves results to result/analysis_results.txt along with publication-ready plots (PNG + PDF) in result/. Dataset Availability The dataset is provided in three ascending tiers of refinement: public_validated_energy_results.jsonl: Contains all 21,428 problem pairs that successfully passed our functional equivalence test and were successfully profiled for energy, time, and memory consumption. public_significant_energy_diff.jsonl: A filtered subset containing the top 3,000 pairs from the previous step that exhibited the highest absolute difference in energy consumption. public_classified_smells.jsonl: The final 3,000 pairs from the significant difference tier, fully annotated with multi-step DeepSeek LLM reasoning, root causes, and final taxonomy subcategory classifications. Note: Any field except user_id, problem_id, language, submission_id_v0, submission_id_v1, code_v0_no_empty_lines, code_v1_no_empty_lines is generated by our pipeline. Credits Our dataset extends the Pie-Perf dataset---the python split train.jsonl, which provides a rich collection of paired efficient and inefficient algorithmic implementations. While we retained their original paired snippet representations and problem descriptions, we expanded upon the dataset by profiling execution on hardware to measure and append our newly extracted energy, time, and memory metrics, alongside rigorous LLM-generated taxonomy classifications.

提供机构:
Zenodo
创建时间:
2026-03-07
二维码
社区交流群
二维码
科研交流群
商业服务