A Case for Static Analyzers in the Cloud Mehdi Bouaziz Ecole - - PowerPoint PPT Presentation

a case for static analyzers in the cloud
SMART_READER_LITE
LIVE PREVIEW

A Case for Static Analyzers in the Cloud Mehdi Bouaziz Ecole - - PowerPoint PPT Presentation

A Case for Static Analyzers in the Cloud Mehdi Bouaziz Ecole normale sup erieure, Paris, France joint work with Michael Barnett, Manuel F ahndrich, and Francesco Logozzo Microsoft Research, Redmond, WA, USA Eighth Workshop on


slide-1
SLIDE 1

A Case for Static Analyzers in the Cloud

Mehdi Bouaziz ´ Ecole normale sup´ erieure, Paris, France joint work with Michael Barnett, Manuel F¨ ahndrich, and Francesco Logozzo Microsoft Research, Redmond, WA, USA Eighth Workshop on Bytecode Semantics, Verification, Analysis, and Transformation March 23, 2013 – Rome, Italy

slide-2
SLIDE 2

This talk

Why and how to bring a static analyzer to the cloud?

Michael Barnett, Mehdi Bouaziz, Manuel F¨ ahndrich, Francesco Logozzo A Case for Static Analyzers in the Cloud 2/15

slide-3
SLIDE 3

This talk

Why and how to bring a static analyzer to the cloud?

Outline:

◮ Static analyzers today ◮ Why bringing them to the cloud ◮ Architecture of a cloud-based static analyzer ◮ Bonuses, issues

Examplified with our ongoing work on moving Clousot, the .Net Code Contracts static checker, to the cloud.

Michael Barnett, Mehdi Bouaziz, Manuel F¨ ahndrich, Francesco Logozzo A Case for Static Analyzers in the Cloud 2/15

slide-4
SLIDE 4

Code Contracts

Contracts (preconditions, postconditions, object invariants) for .Net languages.

Class PositiveArray { int[] arr; void ObjectInvariant() { Contract.Invariant(this.arr != null); Contract.Invariant(Contract.ForAll(this.arr, x => x > 0)); } int Max() { Contract.Requires(this.arr.Length > 0); Contract.Ensures(Contract.ForAll(this.arr, x => x <= Contract.Result<int>())); Contract.Ensures(Contract.Exists(this.arr, x => x == Contract.Result<int>())); ... } }

◮ Contracts can be dynamically checked at runtime ◮ or statically checked, with Clousot

Michael Barnett, Mehdi Bouaziz, Manuel F¨ ahndrich, Francesco Logozzo A Case for Static Analyzers in the Cloud 3/15

slide-5
SLIDE 5

Clousot today

Abstract interpretation-based static checker for Code Contracts.

Clousot

.Net assembly (bytecode) warnings bug fixes inferred contracts

Clousot runs on a single core of the developer machine. The bottom-up analysis of methods is sequential. Analyses start from scratch each time, but analyses are expensive.

Michael Barnett, Mehdi Bouaziz, Manuel F¨ ahndrich, Francesco Logozzo A Case for Static Analyzers in the Cloud 4/15

slide-6
SLIDE 6

How to share results between developers?

Use a common database to share analysis results.

Clousot

.Net assembly (bytecode) warnings bug fixes inferred contracts Shared Database

Michael Barnett, Mehdi Bouaziz, Manuel F¨ ahndrich, Francesco Logozzo A Case for Static Analyzers in the Cloud 5/15

slide-7
SLIDE 7

Analyses are still expensive

Use more CPUs and more memory!

Clousot Client

.Net assembly (bytecode) warnings bug fixes inferred contracts Database

Clousot Server

Michael Barnett, Mehdi Bouaziz, Manuel F¨ ahndrich, Francesco Logozzo A Case for Static Analyzers in the Cloud 6/15

slide-8
SLIDE 8

Analyses are still expensive

Use more CPUs and more memory, i.e., use a centralized server.

Clousot Client

.Net assembly (bytecode) warnings bug fixes inferred contracts Database

Clousot Server

Michael Barnett, Mehdi Bouaziz, Manuel F¨ ahndrich, Francesco Logozzo A Case for Static Analyzers in the Cloud 6/15

slide-9
SLIDE 9

A centralized server, does it scale up?

Clousot Client

.Net assembly (bytecode) warnings bug fixes inferred contracts

Clousot in the Cloud

Michael Barnett, Mehdi Bouaziz, Manuel F¨ ahndrich, Francesco Logozzo A Case for Static Analyzers in the Cloud 7/15

slide-10
SLIDE 10

A centralized server, does it scale up?

◮ No elasticity in resource allocation ◮ Hardware/software maintenance issues

Clousot Client

.Net assembly (bytecode) warnings bug fixes inferred contracts

Clousot in the Cloud

Michael Barnett, Mehdi Bouaziz, Manuel F¨ ahndrich, Francesco Logozzo A Case for Static Analyzers in the Cloud 7/15

slide-11
SLIDE 11

A centralized server, does it scale up?

◮ No elasticity in resource allocation ◮ Hardware/software maintenance issues

Use the cloud!

Clousot Client

.Net assembly (bytecode) warnings bug fixes inferred contracts

Clousot in the Cloud

Michael Barnett, Mehdi Bouaziz, Manuel F¨ ahndrich, Francesco Logozzo A Case for Static Analyzers in the Cloud 7/15

slide-12
SLIDE 12

Static analyzer as a Cloud service

◮ Same as a centralized server but on a Cloud infrastructure ◮ Remote maintenance: one version for everybody

◮ Clients do not need to update the tool ◮ Faster deployment of bug fixes

◮ Results shared by everybody using the tool

Michael Barnett, Mehdi Bouaziz, Manuel F¨ ahndrich, Francesco Logozzo A Case for Static Analyzers in the Cloud 8/15

slide-13
SLIDE 13

Static analyzer as a Cloud service

◮ Same as a centralized server but on a Cloud infrastructure ◮ Remote maintenance: one version for everybody

◮ Clients do not need to update the tool ◮ Faster deployment of bug fixes

◮ Results shared by everybody using the tool ◮ Faster, more precise analyses ◮ Data collections on the usage of the tool enable:

◮ Better understanding of how the tool is used ◮ Identify the weaknesses, refine or design new domains ◮ Reduction of false alarms ◮ Semantics-guided warning suppression ◮ Version-based metrics Michael Barnett, Mehdi Bouaziz, Manuel F¨ ahndrich, Francesco Logozzo A Case for Static Analyzers in the Cloud 8/15

slide-14
SLIDE 14

The client part

◮ very small (call the service, show the results)

◮ used anywhere: smartphone, tablet [TouchDevelop] Michael Barnett, Mehdi Bouaziz, Manuel F¨ ahndrich, Francesco Logozzo A Case for Static Analyzers in the Cloud 9/15

slide-15
SLIDE 15

The client part

◮ very small (call the service, show the results)

◮ used anywhere: smartphone, tablet [TouchDevelop]

◮ can issue parallel analyses on the same program, faster less

precise results will come first, more precise ones later

Michael Barnett, Mehdi Bouaziz, Manuel F¨ ahndrich, Francesco Logozzo A Case for Static Analyzers in the Cloud 9/15

slide-16
SLIDE 16

The client part

◮ very small (call the service, show the results)

◮ used anywhere: smartphone, tablet [TouchDevelop]

◮ can issue parallel analyses on the same program, faster less

precise results will come first, more precise ones later Or a hybrid client:

◮ analyze “visible” code the developer machine for fast results ◮ analyze the rest on the Cloud and load results as the

developer scrolls

Michael Barnett, Mehdi Bouaziz, Manuel F¨ ahndrich, Francesco Logozzo A Case for Static Analyzers in the Cloud 9/15

slide-17
SLIDE 17

What is in the cloud?

Dispatcher Slicer Database Scheduler Queue Unit analyzer Unit analyzer

Michael Barnett, Mehdi Bouaziz, Manuel F¨ ahndrich, Francesco Logozzo A Case for Static Analyzers in the Cloud 10/15

slide-18
SLIDE 18

Parallelization

◮ Past experience: no gain in performance when parallelizing

the analysis of a single method. Too much time lost in synchronization, . . .

◮ Atomic computation: analysis of a method

Michael Barnett, Mehdi Bouaziz, Manuel F¨ ahndrich, Francesco Logozzo A Case for Static Analyzers in the Cloud 11/15

slide-19
SLIDE 19

Slicing

◮ Past experience: no gain in performance when parallelizing

the analysis of a single method. Too much time lost in synchronization, . . .

◮ Atomic computation: analysis of a method ◮ Goal: do not ship a big dll file to analyze just a part of it ◮ Given a .Net assembly and a set of methods M, generate a

minimal analyzable unit (MAU) containing:

◮ the methods M ◮ fake versions of types/methods/properties/fields visible from M ◮ their contracts, object invariants, contract classes ◮ debugging information (pdb file) Michael Barnett, Mehdi Bouaziz, Manuel F¨ ahndrich, Francesco Logozzo A Case for Static Analyzers in the Cloud 11/15

slide-20
SLIDE 20

Going further

◮ Goal: compute a global fixpoint over the analyses of all the

methods

◮ Methods are not ordered anymore ◮ Method analyses are chaotic and asynchronous ◮ Asynchronous iterations [Cousot 77] converge to the greatest

fixpoint with no synchronization!

Michael Barnett, Mehdi Bouaziz, Manuel F¨ ahndrich, Francesco Logozzo A Case for Static Analyzers in the Cloud 12/15

slide-21
SLIDE 21

Going further

◮ Goal: compute a global fixpoint over the analyses of all the

methods

◮ Methods are not ordered anymore ◮ Method analyses are chaotic and asynchronous ◮ Asynchronous iterations [Cousot 77] converge to the greatest

fixpoint with no synchronization!

◮ In the case of monotone operators, only! ◮ We do not have monotonicity

◮ widenings, absence of best abstraction

◮ Problem can be remediated by forcing monotonicity

Michael Barnett, Mehdi Bouaziz, Manuel F¨ ahndrich, Francesco Logozzo A Case for Static Analyzers in the Cloud 12/15

slide-22
SLIDE 22

Summary: from desktop to the cloud

◮ make it parallelizable on a single machine (get rid of static

variables, etc.)

◮ make it a service, even if the interface is very simple, i.e., an

everlasting process waiting for queries

◮ optionally, use a centralized database for results and caching ◮ build the cloud service machinery: service workers, waiting

queues, job schedulers

◮ find an axis of parallelization, with a medium granularity, e.g.,

some kind of slicing, or independent analyses

◮ depending on the analysis, global iterations may be needed to

compute fixpoints

Michael Barnett, Mehdi Bouaziz, Manuel F¨ ahndrich, Francesco Logozzo A Case for Static Analyzers in the Cloud 13/15

slide-23
SLIDE 23

Issues?

◮ Trust

Michael Barnett, Mehdi Bouaziz, Manuel F¨ ahndrich, Francesco Logozzo A Case for Static Analyzers in the Cloud 14/15

slide-24
SLIDE 24

Issues?

◮ Trust

Not so important since we analyze bytecode

Michael Barnett, Mehdi Bouaziz, Manuel F¨ ahndrich, Francesco Logozzo A Case for Static Analyzers in the Cloud 14/15

slide-25
SLIDE 25

Issues?

◮ Trust

Not so important since we analyze bytecode

◮ Hardly predictable cost

Michael Barnett, Mehdi Bouaziz, Manuel F¨ ahndrich, Francesco Logozzo A Case for Static Analyzers in the Cloud 14/15

slide-26
SLIDE 26

Conclusion

◮ We (they) are working on Cloudot: a cloud-based version of

Clousot, the static analyzer for .Net Code Contracts.

◮ The cloud enables:

◮ fast and precise analyses of large programs thanks to the

elasticity of the resources

◮ sharing of computation and results ◮ easier feedback on the usage of the tool ◮ easier deployment of new versions of the tool and contracts for

standard libraries

Try Clousot online: http://rise4fun.com/CodeContracts Or download it (90,000+ downloads): http://research.microsoft.com/contracts

Michael Barnett, Mehdi Bouaziz, Manuel F¨ ahndrich, Francesco Logozzo A Case for Static Analyzers in the Cloud 15/15