Microsoft Scope
Microsoft Scope
Microsoft Scope
Microsoft Corp.
Large data centers (x1000 machines): storage and computation Key technology for search (Bing, Google, Yahoo) Web data analysis, user log analysis, relevance studies, etc.
Map-Reduce / GFS
GFS / Bigtable provide distributed storage
The Map-Reduce programming model Good abstraction of group-by-aggregation operations
sequence of map-reduce pairs Not completely transparent: users still have to use a parallel mindset Error-prone and suboptimal: writing map-reduce programs is equivalent to writing physical execution plans in DBMS
execution engine Pig Latin: a dataflow language using a nested data model
Imperative programming style Relational data manipulation primitives and plug-in
code to customize processing New syntax need to learn a new language Queries are mapped to map-reduce engine
SCOPE / Cosmos
Cosmos Storage System Append-only distributed file system for storing petabytes of data Optimized for sequential I/O Data is compressed and replicated Cosmos Execution Environment Flexible model: a job is a DAG (directed acyclic graph)
Vertices -> processes, edges -> data flows The job manager schedules and coordinates vertex execution
SCOPE
tructured omputations
simple transformations
Users focus on problem solving as if on a single machine System complexity and parallelism are hidden
An Example: QCount
Compute the popular queries that have been requested at least 1000 times
SELECT query, COUNT(*) AS count FROM search.log USING LogExtractor GROUP BY query HAVING count> 1000 ORDER BY count DESC; OUTPUT TO qcount.result e = EXTRACT query FROM search.log USING LogExtractor; s1 = SELECT query, COUNT(*) AS count FROM e GROUP BY query; s2 = SELECT query, count FROM s1 WHERE count> 1000; s3 = SELECT query, count FROM s2 ORDER BY count DESC; OUTPUT s3 TO qcount.result
SUM, AVG, STDEV, VAR, FIRST, LAST. No subqueries (but same functionality available because of outer join)
Process
PROCESS command takes a rowset as input, processes each row, and
Reduce
REDUCE command takes a grouped rowset, processes each group, and
Combine
COMBINE command takes two matching input rowsets, combines
public class MyCombiner : Combiner { public override Schema Produce(string[] requestedColumns, string[] args, Schema leftSchema, string leftTable, Schema rightSchema, string rightTable) {} public override IEnumerable<Row> Combine(RowSet left, RowSet right, Row outputRow, string[] args) {} }
Importing Scripts
IMPORT <script_file> [PARAMS <par_name> = <value> [,]]
Combines the benefits of virtual views and stored procedures in SQL Enables modularity and information hiding Improves reusability and allows parameterization Provides a security mechanism
Q1 = IMPORT MyView.script PARAMS logfile=Queries_Jan.log, limit=1000;
EXPORT R = SELECT query, COUNT() AS count FROM E GROUP BY query HAVING count > @@limit@@;
...
...
Optimization Rules
Transformation Engine
Optimal Query Plans
(Vertex DAG)
SCOPE optimizer Transformation-based optimizer Reasons about plan properties (partitioning, grouping, sorting, etc.) Chooses an optimal plan based on cost estimates
SCOPE Runtime Provides a rich class of composable physical operators Operators are implemented using the iterator model Executes a series of operators in a pipelined fashion
1. 2. 3. 4. 5. 6. 7. 8.
Extract the input cosmos file Partially aggregate at the rack level Partition on query Fully aggregate Apply filter on count Sort results in parallel Merge results Output as a cosmos file
TPC-H Query 2
// Extract region, nation, supplier, partsupp, part RNS_JOIN = SELECT s_suppkey, n_name FROM region, nation, supplier WHERE r_regionkey == n_regionkey AND n_nationkey == s_nationkey; RNSPS_JOIN = SELECT p_partkey, ps_supplycost, ps_suppkey, p_mfgr, n_name FROM part, partsupp, rns_join WHERE p_partkey == ps_partkey AND s_suppkey == ps_suppkey; SUBQ = SELECT p_partkey AS subq_partkey, MIN(ps_supplycost) AS min_cost FROM rnsps_join GROUP BY p_partkey; RESULT = SELECT s_acctbal, s_name, p_partkey, p_mfgr, s_address, s_phone, s_comment FROM rnsps_join AS lo, subq AS sq, supplier AS s WHERE lo.p_partkey == sq.subq_partkey AND lo.ps_supplycost == min_cost AND lo.ps_suppkey == s.s_suppkey ORDER BY acctbal DESC, n_name, s_name, partkey; OUTPUT RESULT TO "tpchQ2.tbl";
7. 8.
9.
Join on suppkey Partially aggregate at the rack level Partition on group-by column Fully aggregate Partition on partkey Merge corresponding partitions Partition on partkey Merge corresponding partitions Perform join
A Real Example
Conclusions
SCOPE: a new scripting language for large-scale analysis Strong resemblance to SQL: easy to learn and port existing applications Very extensible
Fully benefits from .NET library Supports built-in C# templates for customized operations Supports a rich class of physical operators Great reusability with views, user-defined operators Improves productivity Implementation details (including parallelism, system complexity) are transparent to users Allows sophisticated optimization Good foundation for performance study and improvement
Highly composable
Current/Future Work
Language enhancements Sharing, data mining, etc. Query optimization Auto tuning physical storage design Materialized view optimization Common subexpression exploitation Progressive query optimization Runtime optimization New execution strategies Self-adaptive dynamic query plans