SlideShare une entreprise Scribd logo
1  sur  23
Télécharger pour lire hors ligne
An Algorithm
for Keyword Search
on an Execution Path
Toshihiro Kamiya

Future University Hakodate
kamiya@fun.ac.jp
Background #1: Code searching
Developers do search!
➤ To find reusable components for a function of a product
➤ To find similar code fragments before modifying a code
➤ To find code samples showing usage a given class or
component

CSMR-WCRE-2014 Era Track

2
Background #2: Emerging
fine-grained module technologies
More and more fine-grained modules are used.
●

Object/Closure
extract a data and its manipulation

●

Aspect
extract interests, a set of code invoked by a specific
condition or event

●

Dependency Injection
split code at each dependency

CSMR-WCRE-2014 Era Track

3
Problem: Searching on fine-grained
modules
Code search becomes difficult by
fine-grained modules
(Old days) the search result was
contained in a file
↓
(Now) is a set of several parts of several
files

Old days

This affects code-search methods in both
●
Algorithm
–
●

Now

“how to find”

Displaying/Visualizing
–

“how to show search results”

CSMR-WCRE-2014 Era Track

4
Solution: Keyword Search on an
Execution Path
●
●

Static analysis
Find the execution paths that include given keywords
●

●

●

From all possible execution paths of a target program

Idea: a compact data structure (And/Or/Call graph) of
execution paths + search algorithm on it
A prototype implementation
●

applied to up-to 183k lines of Java source code

Related work
●
●

Prospector[8]
PARSEWeb[9]

CSMR-WCRE-2014 Era Track

5
And/Or/Call Graph
●

●

A DAG contains all execution
paths in a compact form

Source code

Repetitive structure
➡ Selection among sequences
of 0-time repetition, 1-time
repetition,2-times repetition, ...
➡ Or node having And nodes as
children

s3

Selection structure ➡ Or node

–

s2

Sequence structure ➡ And node

–

–

Method call ➡ Call node
●

Tex
s1

s1;
s2;
s3;

is generated by the following
translation rules
–

Graphical form

if (...) {
st;
} else {
se;
}

st
se

interface I { m(); }
class
m()
}
class
m()
}

B implements I {
{...}
C implements I {
{...}

I i;
...
i.m();

B//m
C//m

Dynamic dispatching

CSMR-WCRE-2014 Era Track

6
Example
12

Calendar//getIntance
split

10

getDay
8
列 1
2
列 3

Calendar//set

main
列

6

4

parseInt
parseInt
parseInt

getToday
getDayOfWeek

Calendar//getIntance
Calender//get

printf

2

0
行 1

行 2

行 3

行 4

CSMR-WCRE-2014 Era Track

7
Example
12

Calendar//getIntance
split

10

getDay
8
列 1
2
列 3

Calendar//set

main
列

6

4

parseInt
parseInt
parseInt

getToday
getDayOfWeek

Calendar//getIntance
Calender//get

printf

2

0
行 1

行 2

行 3

行 4

CSMR-WCRE-2014 Era Track

8
Example
12

Calendar//getIntance
split

10

getDay
8
列 1
2
列 3

Calendar//set

main
列

6

4

parseInt
parseInt
parseInt

getToday
getDayOfWeek

Calendar//getIntance
Calender//get

printf

2

0
行 1

行 2

行 3

行 4

CSMR-WCRE-2014 Era Track

9
Search Algorithm
●
●

Input: Keywords to identify nodes
Output: Connected sub-graphs including the
nodes identified with the keywords
“connected sub-graph” → continuous execution path

●

Heuristics
–

Find deepest nodes
← Assumption: small operation is easy to understand

–

Extract shallowest sub-graph(treecut)
← Assumption: deep method-invocation chain is difficult to
understand

CSMR-WCRE-2014 Era Track

10
Label and Summary
Label/Summary are “index” data of
search algorithm.
●
Label
–
–
●

Calendar//getIntance

A set of names put on a node
Keywords in a query

split

Summary
–

getDay

A node n’s summary S(n) is a set of
names of (child and) descendant
main
nodes of n.

Properties
–
–

For any node n and its any child node c
S(n) ⊇ S(c).
A root node has a summary of local
maximum.

parseInt
parseInt
parseInt
Calendar//set

getToday
getDayOfWeek

Calendar//getIntance
Calender//get

printf

CSMR-WCRE-2014 Era Track

11
Label and Summary
Label/Summary are “index” data of
search algorithm.
●
Label
–
–
●

Calendar//getIntance

A set of names put on a node
Keywords in a query

split

Summary
–

getDay

A node n’s summary S(n) is a set of
names of (child and) descendant
main
nodes of n.

Properties
–
–

For any node n and its any child node c
S(n) ⊇ S(c).
A root node has a summary of local
maximum.

parseInt
parseInt
parseInt
Calendar//set

getToday
getDayOfWeek

Calendar//getIntance
Calender//get

printf

summary

CSMR-WCRE-2014 Era Track

12
Label and Summary
Label/Summary are “index” data of
search algorithm.
●
Label
–
–
●

Calendar//getIntance

A set of names put on a node
Keywords in a query

split

Summary
–

A node n’s summary S(n) is a set of
names of (child and) descendant
main
nodes of n.

Properties
–
–

getDay

parseInt
parseInt
parseInt
Calendar//set

getToday

Calendar//getIntance

getDayOfWeek

For any node n and its any child node c
printf
S(n) ⊇ S(c).
summary
A root node has a summary of local
{ “Calendar//getInstance”,
maximum.

Calender//get

“Calendar//set”,“split”, “parseInt” }

CSMR-WCRE-2014 Era Track

13
Label and Summary
Label/Summary are “index” data of
search algorithm.
●
Label
–
–
●

Calendar//getIntance

A set of names put on a node
Keywords in a query

split

Summary
–

getDay

A node n’s summary S(n) is a set of
names of (child and) descendant
main
nodes of n.

Properties
–
–

For any node n and its any child node c
S(n) ⊇ S(c).
A root node has a summary of local
maximum.

parseInt
parseInt
parseInt
Calendar//set

getToday
getDayOfWeek

Calendar//getIntance
Calender//get

printf

summary

{ “Calendar//getInstance”, “Calendar//get”,
“Calendar//set”, “getDay”, “getDayOfWeek”,
“split”, “parseInt”, “printf” }

CSMR-WCRE-2014 Era Track

14
Steps of search algorithm
(S1) finds query-fulfilling sub-trees of the (local)
maximum depths
–

by comparing summary of each node with the query

(S2) makes the shallowest treecut
–

by removing deeper leaf nodes until the treecut
does not fulfill the query anymore.

(S3) removes uncontributing leaf nodes
–

Uncontributing = its label does not match any of the
query keywords

CSMR-WCRE-2014 Era Track

15
Example
(S1) finds query-fulfilling
sub-trees of the (local) maximum
depths

Query
{ “Calender//get”,“Calender//set” }
Calendar//getIntance

(S2) makes the shallowest
treecut

split
getDay

(S3) removes uncontributing leaf
nodes

parseInt
parseInt
parseInt
Calendar//set

main
getToday
getDayOfWeek

Calendar//getIntance
Calender//get

printf

CSMR-WCRE-2014 Era Track

16
Example
(S1) finds query-fulfilling
sub-trees of the (local) maximum
depths

Query
{ “Calender//get”,“Calender//set” }
Calendar//getIntance

(S2) makes the shallowest
treecut

split
getDay

(S3) removes uncontributing leaf
nodes

parseInt
parseInt
parseInt
Calendar//set

main
getToday
getDayOfWeek

Calendar//getIntance
Calender//get

printf

{ “Calendar//getInstance”, “Calendar//get”,
“Calendar//set”, “getDay”, “getDayOfWeek”,
“split”, “parseInt”, “printf” }
CSMR-WCRE-2014 Era Track

17
Example
(S1) finds query-fulfilling
sub-trees of the (local) maximum
depths

Query
{ “Calender//get”,“Calender//set” }
Calendar//getIntance

(S2) makes the shallowest
treecut

split
getDay

(S3) removes uncontributing leaf
nodes

parseInt
parseInt
parseInt
Calendar//set

main
getToday
getDayOfWeek

Calendar//getIntance
Calender//get

printf

CSMR-WCRE-2014 Era Track

18
Example
(S1) finds query-fulfilling
sub-trees of the (local) maximum
depths
(S2) makes the shallowest
treecut in each of the sub-trees

Query
{ “Calender//get”,“Calender//set” }
getDay
Calendar//set

main

(S3) removes uncontributing leaf
nodes

getDayOfWeek

Search result

CSMR-WCRE-2014 Era Track

Calender//get

main {
getDay {
Calendar//set
}
getDayOfWeek {
Calendar//get
}
}
19
Prototype tool
Implementation
●
Target: Java source
code
–

●

●

Limitations
●
Keywords
–

Analysis of Java's
dynamic dispatch

Written in 8k lines of
Python
Applied up-to 183kloc
product (jEdit)

–
●

Exception handling
–

●

Names of class or method
Text in string literal
Does not search in the
execution paths that throw

Entry points
–
–

main() and static initializers
Does not search for entry
points such as @Test

CSMR-WCRE-2014 Era Track

20
Java class files
(bytecode)

Dynamic-dispatch analysis
Type hierarchy

Method-body analysis
Method calls

Control flow

Indexing

Method signature
Dynamic-dispatch resolver

And/Or/Call graph
of method body
Node label

Whole-program graph building
Node summary building

And/Or/Call
graph

Node
summary

Line number
table

Query

Searching

Keyword-query search
Sub-graph /
Execution path

Formatting
Search result
CSMR-WCRE-2014 Era Track

21
Applied to jEdit
●

H/W
–
–

●

Indexing
–
–

●

CPU Xeon E5520 2.27GHz
32GiB mem.
48.8 sec. in elapsed time
644 MiB peak mem.

Searching
–
–

3.09 ∼ 72.2 (ave. 5.71)
sec. in elapsed time
up-to 1412 MiB peak mem.

CSMR-WCRE-2014 Era Track

22
Summary
●

Background
–
–

●
●

Problem: Searching on fine-grained modules
Solution: Keyword search on an execution Path
–
–

●

#1: Code searching
#2: Emerging of fine-grained module technologies

And/Or/Call graph, Label/summary
Search algorithm

Prototype implementation
Applied to jEdit

●

GitHub
–

https://github.com/tos-kamiya/agoat/

CSMR-WCRE-2014 Era Track

23

Contenu connexe

Similaire à An Algorithm for Keyword Search on an Execution Path

Similaire à An Algorithm for Keyword Search on an Execution Path (20)

Building a modern Application with DataFrames
Building a modern Application with DataFramesBuilding a modern Application with DataFrames
Building a modern Application with DataFrames
 
Building a modern Application with DataFrames
Building a modern Application with DataFramesBuilding a modern Application with DataFrames
Building a modern Application with DataFrames
 
Spark tutorial
Spark tutorialSpark tutorial
Spark tutorial
 
Oscon 2019 - Optimizing analytical queries on Cassandra by 100x
Oscon 2019 - Optimizing analytical queries on Cassandra by 100xOscon 2019 - Optimizing analytical queries on Cassandra by 100x
Oscon 2019 - Optimizing analytical queries on Cassandra by 100x
 
Spark Summit EU talk by Ross Lawley
Spark Summit EU talk by Ross LawleySpark Summit EU talk by Ross Lawley
Spark Summit EU talk by Ross Lawley
 
How To Connect Spark To Your Own Datasource
How To Connect Spark To Your Own DatasourceHow To Connect Spark To Your Own Datasource
How To Connect Spark To Your Own Datasource
 
Search Engine Building with Lucene and Solr (So Code Camp San Diego 2014)
Search Engine Building with Lucene and Solr (So Code Camp San Diego 2014)Search Engine Building with Lucene and Solr (So Code Camp San Diego 2014)
Search Engine Building with Lucene and Solr (So Code Camp San Diego 2014)
 
Apache Spark Performance Troubleshooting at Scale, Challenges, Tools, and Met...
Apache Spark Performance Troubleshooting at Scale, Challenges, Tools, and Met...Apache Spark Performance Troubleshooting at Scale, Challenges, Tools, and Met...
Apache Spark Performance Troubleshooting at Scale, Challenges, Tools, and Met...
 
Spline 0.3 and Plans for 0.4
Spline 0.3 and Plans for 0.4 Spline 0.3 and Plans for 0.4
Spline 0.3 and Plans for 0.4
 
Dense Retrieval with Apache Solr Neural Search.pdf
Dense Retrieval with Apache Solr Neural Search.pdfDense Retrieval with Apache Solr Neural Search.pdf
Dense Retrieval with Apache Solr Neural Search.pdf
 
Beyond the Query: A Cassandra + Solr + Spark Love Triangle Using Datastax Ent...
Beyond the Query: A Cassandra + Solr + Spark Love Triangle Using Datastax Ent...Beyond the Query: A Cassandra + Solr + Spark Love Triangle Using Datastax Ent...
Beyond the Query: A Cassandra + Solr + Spark Love Triangle Using Datastax Ent...
 
A Cassandra + Solr + Spark Love Triangle Using DataStax Enterprise
A Cassandra + Solr + Spark Love Triangle Using DataStax EnterpriseA Cassandra + Solr + Spark Love Triangle Using DataStax Enterprise
A Cassandra + Solr + Spark Love Triangle Using DataStax Enterprise
 
Spark streaming , Spark SQL
Spark streaming , Spark SQLSpark streaming , Spark SQL
Spark streaming , Spark SQL
 
Adios hadoop, Hola Spark! T3chfest 2015
Adios hadoop, Hola Spark! T3chfest 2015Adios hadoop, Hola Spark! T3chfest 2015
Adios hadoop, Hola Spark! T3chfest 2015
 
Neural Search Comes to Apache Solr_ Approximate Nearest Neighbor, BERT and Mo...
Neural Search Comes to Apache Solr_ Approximate Nearest Neighbor, BERT and Mo...Neural Search Comes to Apache Solr_ Approximate Nearest Neighbor, BERT and Mo...
Neural Search Comes to Apache Solr_ Approximate Nearest Neighbor, BERT and Mo...
 
Strata NYC 2015 - What's coming for the Spark community
Strata NYC 2015 - What's coming for the Spark communityStrata NYC 2015 - What's coming for the Spark community
Strata NYC 2015 - What's coming for the Spark community
 
Beyond the Query – Bringing Complex Access Patterns to NoSQL with DataStax - ...
Beyond the Query – Bringing Complex Access Patterns to NoSQL with DataStax - ...Beyond the Query – Bringing Complex Access Patterns to NoSQL with DataStax - ...
Beyond the Query – Bringing Complex Access Patterns to NoSQL with DataStax - ...
 
Spark Kafka summit 2017
Spark Kafka summit 2017Spark Kafka summit 2017
Spark Kafka summit 2017
 
Scylla Summit 2016: Analytics Show Time - Spark and Presto Powered by Scylla
Scylla Summit 2016: Analytics Show Time - Spark and Presto Powered by ScyllaScylla Summit 2016: Analytics Show Time - Spark and Presto Powered by Scylla
Scylla Summit 2016: Analytics Show Time - Spark and Presto Powered by Scylla
 
What's new in Redis v3.2
What's new in Redis v3.2What's new in Redis v3.2
What's new in Redis v3.2
 

Plus de Kamiya Toshihiro

PBLへのアジャイル開発手法導入の試み
PBLへのアジャイル開発手法導入の試みPBLへのアジャイル開発手法導入の試み
PBLへのアジャイル開発手法導入の試み
Kamiya Toshihiro
 

Plus de Kamiya Toshihiro (15)

ソースコード推薦あるいは修正の情報源としての質問掲示板とソースコードレポジトリの比較
ソースコード推薦あるいは修正の情報源としての質問掲示板とソースコードレポジトリの比較ソースコード推薦あるいは修正の情報源としての質問掲示板とソースコードレポジトリの比較
ソースコード推薦あるいは修正の情報源としての質問掲示板とソースコードレポジトリの比較
 
Code Difference Visualization by a Call Tree
Code Difference Visualization by a Call TreeCode Difference Visualization by a Call Tree
Code Difference Visualization by a Call Tree
 
実行トレース間のデータの差異に基づくデータフロー解析手法の提案
実行トレース間のデータの差異に基づくデータフロー解析手法の提案実行トレース間のデータの差異に基づくデータフロー解析手法の提案
実行トレース間のデータの差異に基づくデータフロー解析手法の提案
 
コードクローン研究 ふりかえり ~ストロング・スタイルで行こう~
コードクローン研究 ふりかえり ~ストロング・スタイルで行こう~コードクローン研究 ふりかえり ~ストロング・スタイルで行こう~
コードクローン研究 ふりかえり ~ストロング・スタイルで行こう~
 
逆戻りデバッグ補助のための嵌入的スパイの試作
逆戻りデバッグ補助のための嵌入的スパイの試作逆戻りデバッグ補助のための嵌入的スパイの試作
逆戻りデバッグ補助のための嵌入的スパイの試作
 
Introducing Parameter Sensitivity to Dynamic Code-Clone Analysis Methods
Introducing Parameter Sensitivity to Dynamic Code-Clone Analysis MethodsIntroducing Parameter Sensitivity to Dynamic Code-Clone Analysis Methods
Introducing Parameter Sensitivity to Dynamic Code-Clone Analysis Methods
 
任意粒度機能モデルコードクローン検出手法のリファクタリング理解への適用の試み
任意粒度機能モデルコードクローン検出手法のリファクタリング理解への適用の試み任意粒度機能モデルコードクローン検出手法のリファクタリング理解への適用の試み
任意粒度機能モデルコードクローン検出手法のリファクタリング理解への適用の試み
 
An Execution-Semantic and Content-and-Context-Based Code-Clone Detection and ...
An Execution-Semantic and Content-and-Context-Based Code-Clone Detection and ...An Execution-Semantic and Content-and-Context-Based Code-Clone Detection and ...
An Execution-Semantic and Content-and-Context-Based Code-Clone Detection and ...
 
任意粒度機能モデルに基づく動的型付けプログラミング言語向けソースコード検索手法の提案
任意粒度機能モデルに基づく動的型付けプログラミング言語向けソースコード検索手法の提案任意粒度機能モデルに基づく動的型付けプログラミング言語向けソースコード検索手法の提案
任意粒度機能モデルに基づく動的型付けプログラミング言語向けソースコード検索手法の提案
 
Web アプリケーションの UI 機能テストの ための HTML 構造パターンの抽出手法
Web アプリケーションの UI 機能テストの ための HTML 構造パターンの抽出手法Web アプリケーションの UI 機能テストの ための HTML 構造パターンの抽出手法
Web アプリケーションの UI 機能テストの ための HTML 構造パターンの抽出手法
 
WebアプリケーションのUI機能テストのためのHTML構造パターンの提案
WebアプリケーションのUI機能テストのためのHTML構造パターンの提案WebアプリケーションのUI機能テストのためのHTML構造パターンの提案
WebアプリケーションのUI機能テストのためのHTML構造パターンの提案
 
And/Or/Callグラフの提案とソースコード検索への応用
And/Or/Callグラフの提案とソースコード検索への応用And/Or/Callグラフの提案とソースコード検索への応用
And/Or/Callグラフの提案とソースコード検索への応用
 
PBLへのアジャイル開発手法導入の試み
PBLへのアジャイル開発手法導入の試みPBLへのアジャイル開発手法導入の試み
PBLへのアジャイル開発手法導入の試み
 
任意粒度機能モデルに基づくコードクローン検出手法の大規模プログラムの適用に向けた改善
任意粒度機能モデルに基づくコードクローン検出手法の大規模プログラムの適用に向けた改善任意粒度機能モデルに基づくコードクローン検出手法の大規模プログラムの適用に向けた改善
任意粒度機能モデルに基づくコードクローン検出手法の大規模プログラムの適用に向けた改善
 
任意粒度機能モデルに基づくバイトコードからのコードクローン検出手法
任意粒度機能モデルに基づくバイトコードからのコードクローン検出手法任意粒度機能モデルに基づくバイトコードからのコードクローン検出手法
任意粒度機能モデルに基づくバイトコードからのコードクローン検出手法
 

Dernier

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Dernier (20)

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 

An Algorithm for Keyword Search on an Execution Path

  • 1. An Algorithm for Keyword Search on an Execution Path Toshihiro Kamiya Future University Hakodate kamiya@fun.ac.jp
  • 2. Background #1: Code searching Developers do search! ➤ To find reusable components for a function of a product ➤ To find similar code fragments before modifying a code ➤ To find code samples showing usage a given class or component CSMR-WCRE-2014 Era Track 2
  • 3. Background #2: Emerging fine-grained module technologies More and more fine-grained modules are used. ● Object/Closure extract a data and its manipulation ● Aspect extract interests, a set of code invoked by a specific condition or event ● Dependency Injection split code at each dependency CSMR-WCRE-2014 Era Track 3
  • 4. Problem: Searching on fine-grained modules Code search becomes difficult by fine-grained modules (Old days) the search result was contained in a file ↓ (Now) is a set of several parts of several files Old days This affects code-search methods in both ● Algorithm – ● Now “how to find” Displaying/Visualizing – “how to show search results” CSMR-WCRE-2014 Era Track 4
  • 5. Solution: Keyword Search on an Execution Path ● ● Static analysis Find the execution paths that include given keywords ● ● ● From all possible execution paths of a target program Idea: a compact data structure (And/Or/Call graph) of execution paths + search algorithm on it A prototype implementation ● applied to up-to 183k lines of Java source code Related work ● ● Prospector[8] PARSEWeb[9] CSMR-WCRE-2014 Era Track 5
  • 6. And/Or/Call Graph ● ● A DAG contains all execution paths in a compact form Source code Repetitive structure ➡ Selection among sequences of 0-time repetition, 1-time repetition,2-times repetition, ... ➡ Or node having And nodes as children s3 Selection structure ➡ Or node – s2 Sequence structure ➡ And node – – Method call ➡ Call node ● Tex s1 s1; s2; s3; is generated by the following translation rules – Graphical form if (...) { st; } else { se; } st se interface I { m(); } class m() } class m() } B implements I { {...} C implements I { {...} I i; ... i.m(); B//m C//m Dynamic dispatching CSMR-WCRE-2014 Era Track 6
  • 10. Search Algorithm ● ● Input: Keywords to identify nodes Output: Connected sub-graphs including the nodes identified with the keywords “connected sub-graph” → continuous execution path ● Heuristics – Find deepest nodes ← Assumption: small operation is easy to understand – Extract shallowest sub-graph(treecut) ← Assumption: deep method-invocation chain is difficult to understand CSMR-WCRE-2014 Era Track 10
  • 11. Label and Summary Label/Summary are “index” data of search algorithm. ● Label – – ● Calendar//getIntance A set of names put on a node Keywords in a query split Summary – getDay A node n’s summary S(n) is a set of names of (child and) descendant main nodes of n. Properties – – For any node n and its any child node c S(n) ⊇ S(c). A root node has a summary of local maximum. parseInt parseInt parseInt Calendar//set getToday getDayOfWeek Calendar//getIntance Calender//get printf CSMR-WCRE-2014 Era Track 11
  • 12. Label and Summary Label/Summary are “index” data of search algorithm. ● Label – – ● Calendar//getIntance A set of names put on a node Keywords in a query split Summary – getDay A node n’s summary S(n) is a set of names of (child and) descendant main nodes of n. Properties – – For any node n and its any child node c S(n) ⊇ S(c). A root node has a summary of local maximum. parseInt parseInt parseInt Calendar//set getToday getDayOfWeek Calendar//getIntance Calender//get printf summary CSMR-WCRE-2014 Era Track 12
  • 13. Label and Summary Label/Summary are “index” data of search algorithm. ● Label – – ● Calendar//getIntance A set of names put on a node Keywords in a query split Summary – A node n’s summary S(n) is a set of names of (child and) descendant main nodes of n. Properties – – getDay parseInt parseInt parseInt Calendar//set getToday Calendar//getIntance getDayOfWeek For any node n and its any child node c printf S(n) ⊇ S(c). summary A root node has a summary of local { “Calendar//getInstance”, maximum. Calender//get “Calendar//set”,“split”, “parseInt” } CSMR-WCRE-2014 Era Track 13
  • 14. Label and Summary Label/Summary are “index” data of search algorithm. ● Label – – ● Calendar//getIntance A set of names put on a node Keywords in a query split Summary – getDay A node n’s summary S(n) is a set of names of (child and) descendant main nodes of n. Properties – – For any node n and its any child node c S(n) ⊇ S(c). A root node has a summary of local maximum. parseInt parseInt parseInt Calendar//set getToday getDayOfWeek Calendar//getIntance Calender//get printf summary { “Calendar//getInstance”, “Calendar//get”, “Calendar//set”, “getDay”, “getDayOfWeek”, “split”, “parseInt”, “printf” } CSMR-WCRE-2014 Era Track 14
  • 15. Steps of search algorithm (S1) finds query-fulfilling sub-trees of the (local) maximum depths – by comparing summary of each node with the query (S2) makes the shallowest treecut – by removing deeper leaf nodes until the treecut does not fulfill the query anymore. (S3) removes uncontributing leaf nodes – Uncontributing = its label does not match any of the query keywords CSMR-WCRE-2014 Era Track 15
  • 16. Example (S1) finds query-fulfilling sub-trees of the (local) maximum depths Query { “Calender//get”,“Calender//set” } Calendar//getIntance (S2) makes the shallowest treecut split getDay (S3) removes uncontributing leaf nodes parseInt parseInt parseInt Calendar//set main getToday getDayOfWeek Calendar//getIntance Calender//get printf CSMR-WCRE-2014 Era Track 16
  • 17. Example (S1) finds query-fulfilling sub-trees of the (local) maximum depths Query { “Calender//get”,“Calender//set” } Calendar//getIntance (S2) makes the shallowest treecut split getDay (S3) removes uncontributing leaf nodes parseInt parseInt parseInt Calendar//set main getToday getDayOfWeek Calendar//getIntance Calender//get printf { “Calendar//getInstance”, “Calendar//get”, “Calendar//set”, “getDay”, “getDayOfWeek”, “split”, “parseInt”, “printf” } CSMR-WCRE-2014 Era Track 17
  • 18. Example (S1) finds query-fulfilling sub-trees of the (local) maximum depths Query { “Calender//get”,“Calender//set” } Calendar//getIntance (S2) makes the shallowest treecut split getDay (S3) removes uncontributing leaf nodes parseInt parseInt parseInt Calendar//set main getToday getDayOfWeek Calendar//getIntance Calender//get printf CSMR-WCRE-2014 Era Track 18
  • 19. Example (S1) finds query-fulfilling sub-trees of the (local) maximum depths (S2) makes the shallowest treecut in each of the sub-trees Query { “Calender//get”,“Calender//set” } getDay Calendar//set main (S3) removes uncontributing leaf nodes getDayOfWeek Search result CSMR-WCRE-2014 Era Track Calender//get main { getDay { Calendar//set } getDayOfWeek { Calendar//get } } 19
  • 20. Prototype tool Implementation ● Target: Java source code – ● ● Limitations ● Keywords – Analysis of Java's dynamic dispatch Written in 8k lines of Python Applied up-to 183kloc product (jEdit) – ● Exception handling – ● Names of class or method Text in string literal Does not search in the execution paths that throw Entry points – – main() and static initializers Does not search for entry points such as @Test CSMR-WCRE-2014 Era Track 20
  • 21. Java class files (bytecode) Dynamic-dispatch analysis Type hierarchy Method-body analysis Method calls Control flow Indexing Method signature Dynamic-dispatch resolver And/Or/Call graph of method body Node label Whole-program graph building Node summary building And/Or/Call graph Node summary Line number table Query Searching Keyword-query search Sub-graph / Execution path Formatting Search result CSMR-WCRE-2014 Era Track 21
  • 22. Applied to jEdit ● H/W – – ● Indexing – – ● CPU Xeon E5520 2.27GHz 32GiB mem. 48.8 sec. in elapsed time 644 MiB peak mem. Searching – – 3.09 ∼ 72.2 (ave. 5.71) sec. in elapsed time up-to 1412 MiB peak mem. CSMR-WCRE-2014 Era Track 22
  • 23. Summary ● Background – – ● ● Problem: Searching on fine-grained modules Solution: Keyword search on an execution Path – – ● #1: Code searching #2: Emerging of fine-grained module technologies And/Or/Call graph, Label/summary Search algorithm Prototype implementation Applied to jEdit ● GitHub – https://github.com/tos-kamiya/agoat/ CSMR-WCRE-2014 Era Track 23