automatically extracting configuration constraints sarah nadi *, thorsten berger *, christian...

27
Automatically Extracting Configuration Constraints Sarah Nadi * , Thorsten Berger * , Christian Kästner + , and Krzysztof Czarnecki * Product Line Engineering Workshop, Univ. of Waterloo Dec. 9 th 2013 * +

Upload: alexandre-brick

Post on 01-Apr-2015

223 views

Category:

Documents


4 download

TRANSCRIPT

Page 1: Automatically Extracting Configuration Constraints Sarah Nadi *, Thorsten Berger *, Christian Kästner +, and Krzysztof Czarnecki * Product Line Engineering

Automatically Extracting Configuration ConstraintsSarah Nadi *, Thorsten Berger *, Christian Kästner +, and Krzysztof Czarnecki *

Product Line Engineering Workshop, Univ. of Waterloo

Dec. 9th 2013*

+

Page 2: Automatically Extracting Configuration Constraints Sarah Nadi *, Thorsten Berger *, Christian Kästner +, and Krzysztof Czarnecki * Product Line Engineering

2

Variability in real life

Sarah Nadi

• Integrated Garage Door Opener• Electronic Compass

Command navigation package

• Black Dacota Leather• Automatic Trunk

Premium Package

Comfort Seats, Front

Black Leatherette

Selection will result in:

+ Addition of premium package

- Removal of Black Leathertte

Page 3: Automatically Extracting Configuration Constraints Sarah Nadi *, Thorsten Berger *, Christian Kästner +, and Krzysztof Czarnecki * Product Line Engineering

Handling variability

Build Independently

Sarah Nadi 3

Clone & Own Share Assets

Slide credits: T. Berger

Software Product Lines (SPL)

Product configurationVariability modelingComponentsDSLsGeneratorsPreprocessorsDesign patterns…

[Dubinski et al., CSMR ‚13]

Page 4: Automatically Extracting Configuration Constraints Sarah Nadi *, Thorsten Berger *, Christian Kästner +, and Krzysztof Czarnecki * Product Line Engineering

4

But.. How can we build an SPL?

Sarah Nadi

XExpensive and not always possible

P1 P2 P3

Migrate

Build from scratch

Page 5: Automatically Extracting Configuration Constraints Sarah Nadi *, Thorsten Berger *, Christian Kästner +, and Krzysztof Czarnecki * Product Line Engineering

5

What is involved in migrating?

Sarah Nadi

Refactor Code

Create Variability Model

Detect Variation Points

Identify Configurable Features

Identify Feature Dependencies

Refactor Architecture

[She et al., ICSE‘11]

Page 6: Automatically Extracting Configuration Constraints Sarah Nadi *, Thorsten Berger *, Christian Kästner +, and Krzysztof Czarnecki * Product Line Engineering

6

Variability model constraints

Sarah Nadi

[Benavides et al., 2010]

Hierarchy Constraint:MP3 => Media

Cross-tree Constraint:Camera => High Res.

Page 7: Automatically Extracting Configuration Constraints Sarah Nadi *, Thorsten Berger *, Christian Kästner +, and Krzysztof Czarnecki * Product Line Engineering

7

Can we automatically extract constraints?

To what extent?

Sarah Nadi

Page 8: Automatically Extracting Configuration Constraints Sarah Nadi *, Thorsten Berger *, Christian Kästner +, and Krzysztof Czarnecki * Product Line Engineering

8

Scope• C based systems using conditional compilation• Focus on build-time variability

• Identify two sources of constraints

Sarah Nadi

Page 9: Automatically Extracting Configuration Constraints Sarah Nadi *, Thorsten Berger *, Christian Kästner +, and Krzysztof Czarnecki * Product Line Engineering

9

1. Conditional build-time errors

Sarah Nadi

Specification 1: Every valid configuration of the system must

not contain build-time errors.

Page 10: Automatically Extracting Configuration Constraints Sarah Nadi *, Thorsten Berger *, Christian Kästner +, and Krzysztof Czarnecki * Product Line Engineering

10

Pre-processor Error if ASH && NOMMU

Parser Error if ASH && EDITING && !MAX_LEN

Type Error if ASH && EDITING_VI && MAX_LEN && !

EDITING

Invalid Configuration

Constraint: ASH => !NOMMU

Sarah Nadi

Page 11: Automatically Extracting Configuration Constraints Sarah Nadi *, Thorsten Berger *, Christian Kästner +, and Krzysztof Czarnecki * Product Line Engineering

11

2. Feature effect• Avoid meaningless configurations which do not

add/remove parts of the code• If we add/remove a feature, we want to get different

functionality• Determine under which configurations, a feature has an

effect on the code

Sarah Nadi

Specification 2: Every valid configuration should yield a lexically different program

Page 12: Automatically Extracting Configuration Constraints Sarah Nadi *, Thorsten Berger *, Christian Kästner +, and Krzysztof Czarnecki * Product Line Engineering

12

Feature effect

Sarah Nadi

MAX_LEN && EDITING && ASH

MAX_LEN && EDITING_VI && ASH

MAX_LEN => ASH && (EDITING || EDITING_VI)

Page 13: Automatically Extracting Configuration Constraints Sarah Nadi *, Thorsten Berger *, Christian Kästner +, and Krzysztof Czarnecki * Product Line Engineering

13

Extract constraints by brute force

Sarah Nadi

PnP3P2P1…

Build Individually

If every configuration with feature X compiles except when Y is also selected

X => !Y

Not scalable--- 2n combinations

If every configuration with feature Z does not change the selected code except if W is also selected

Z => W

Page 14: Automatically Extracting Configuration Constraints Sarah Nadi *, Thorsten Berger *, Christian Kästner +, and Krzysztof Czarnecki * Product Line Engineering

14

Extracting constraints in a single pass• Make use of variability-aware parsing & type checking to

mimic build-time behaviour.

Sarah Nadi

[Kästner et al., OOPSLA ‘11]

Page 15: Automatically Extracting Configuration Constraints Sarah Nadi *, Thorsten Berger *, Christian Kästner +, and Krzysztof Czarnecki * Product Line Engineering

15

Infrastructure• Developed tool

• FarCE – Feature Constraints Extraction https://bitbucket.org/tberger/farce

• Rely on previous work:• TypeChef – Type-Checking Ifdef Variability https://

github.com/ckaestne/TypeChef• KBuildMiner http://

code.google.com/p/variability/wiki/PresenceConditionsExtraction• To analyze variability models:

• LVAT https://code.google.com/p/linux-variability-analysis-tools• CDLTools https://bitbucket.org/tberger/cdltools

Sarah Nadi

Page 16: Automatically Extracting Configuration Constraints Sarah Nadi *, Thorsten Berger *, Christian Kästner +, and Krzysztof Czarnecki * Product Line Engineering

16

Empirical study• Objectives:

• O1: Evaluate accuracy and scalability of extraction• O2: Quantitatively and qualitatively study kinds of (extractable)

constraints in real-world systems

• Used four systems with existing variability models

• Compare extracted constraints to existing hierarchy & crosstree edges in the model

Sarah Nadi

Linux Kernel7,691 C files

6,559 Features

BusyBox535 C files

844 Features

eCos579 C files

1,254 features

uClibc 1,628 C files367 features

Page 17: Automatically Extracting Configuration Constraints Sarah Nadi *, Thorsten Berger *, Christian Kästner +, and Krzysztof Czarnecki * Product Line Engineering

17

Is the extraction accurate?

Sarah Nadi

Specification 1 is 95% accurate

Specification 2 is 76% accurate

Page 18: Automatically Extracting Configuration Constraints Sarah Nadi *, Thorsten Berger *, Christian Kästner +, and Krzysztof Czarnecki * Product Line Engineering

18

Which constraints are recovered?

Sarah Nadi

Can automatically recover 23% of variability model constraints!5% by Specification 1

17% by Specification 2

Hierarchy edges

reflected in code

nesting

Crosstree edges prevent

build-time errors

Page 19: Automatically Extracting Configuration Constraints Sarah Nadi *, Thorsten Berger *, Christian Kästner +, and Krzysztof Czarnecki * Product Line Engineering

19

• Qualitative analysis of 144 unrecovered constraints

What about constraints not found?

Sarah Nadi

21% additional analyses 19% limitation in comparison

19% configurator-related

29% unknown

9% domain knowledge 3% limitation in extraction

Manual analysis of constraints is hard!

Some constraints are non-technical & need expert knowledge

Qualitative analysis is subjective

Page 20: Automatically Extracting Configuration Constraints Sarah Nadi *, Thorsten Berger *, Christian Kästner +, and Krzysztof Czarnecki * Product Line Engineering

20

Challenges• Presence conditions and constraints explode

• Limit complexity of constraints used• Use non-SAT based constraint combination techniques

• Different ways to compare constraints• Our comparison is limited to binary constraints• Other techniques which may be used?

• Understand the intent of different constraints without interviewing developers

Sarah Nadi

Page 21: Automatically Extracting Configuration Constraints Sarah Nadi *, Thorsten Berger *, Christian Kästner +, and Krzysztof Czarnecki * Product Line Engineering

21Sarah Nadi

Automatically Done

Accurate

Extracts substantial parts of VM An expert may still be needed

Sarah Nadi (finishing soon … interested in a post doc)

[email protected] http://swag.uwaterloo.ca/~snadi

Extracting configuration constraints from code

(95% & 76% respectively)

Conditional Build-time errors & Feature Effect

(Avg. 23% & up to 65%)

Questions?

Page 22: Automatically Extracting Configuration Constraints Sarah Nadi *, Thorsten Berger *, Christian Kästner +, and Krzysztof Czarnecki * Product Line Engineering

22

Pre-processor Error if ASH && NOMMU

Parser Error if ASH && EDITING && !MAX_LEN

Type Error if ASH && EDITING_VI && MAX_LEN && !

EDITING

Invalid Configuration

Constraint: ASH => !NOMMU

Sarah Nadi

Linker Error if ASH && EDITING && !INIT

Page 23: Automatically Extracting Configuration Constraints Sarah Nadi *, Thorsten Berger *, Christian Kästner +, and Krzysztof Czarnecki * Product Line Engineering

Constraint formulas

Preprocessor, parser, and type-checking constraints

Linker constraints

Feature effect

23

conditional symbol table

Sarah Nadi

Page 24: Automatically Extracting Configuration Constraints Sarah Nadi *, Thorsten Berger *, Christian Kästner +, and Krzysztof Czarnecki * Product Line Engineering

24

How are constraints used?• Hierarchy edges are mainly reflected in how features are

used/nested in the code (Spec 2: feature effect analysis)

• Cross tree edges are often used to prevent build-time errors (Spec 1: conditional build-time errors)

Sarah Nadi

Page 25: Automatically Extracting Configuration Constraints Sarah Nadi *, Thorsten Berger *, Christian Kästner +, and Krzysztof Czarnecki * Product Line Engineering

Partial pre-processor (lexer)

25

slide credits: C. KästnerSarah Nadi

Page 26: Automatically Extracting Configuration Constraints Sarah Nadi *, Thorsten Berger *, Christian Kästner +, and Krzysztof Czarnecki * Product Line Engineering

parser

26

slide credits: C. Kästner

Sarah Nadi

Page 27: Automatically Extracting Configuration Constraints Sarah Nadi *, Thorsten Berger *, Christian Kästner +, and Krzysztof Czarnecki * Product Line Engineering

27

Is the analysis scalable?

Sarah Nadi

Can analyze Linux files in 12hr with parallelization