MethodProxies: A Safe and Fast Message-Passing Control Library

esug 80 views 39 slides Oct 08, 2024
Slide 1
Slide 1 of 39
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31
Slide 32
32
Slide 33
33
Slide 34
34
Slide 35
35
Slide 36
36
Slide 37
37
Slide 38
38
Slide 39
39

About This Presentation

Talk from iwst2024:
"MethodProxies: A Safe and Fast Message-Passing Control Library"

PDF: http://archive.esug.org/ESUG2024/iwst-day1/05-sebas-method-proxies.pdf


Slide Content

IWST ’24, July 2024, Lille, France
MethodProxies: A Safe and Fast
Message-Passing Control Library
Sebastian JORDAN MONTAÑO (1), Juan Pablo SANDOVAL ALCOCER (2), Guillermo
POLITO (1), Stéphane DUCASSE (1), Pablo TESONE (1,3)
1. Inria, Univ. Lille, CNRS, Centrale Lille, UMR 9189 - CRIStAL
Evref
fervE
[email protected]
2. Department of Computer Science, School of Engineering, Pontificia Universidad Católica de Chile, Santiago, Chile
3. Pharo Consortium

Objects communicate through messages
aReceiver method: args
1. The message #method:
is sent to aReceiver
Pharo’s VM
2. Executes #method:
into the object
aReceiver
2
Message-
passing

Message-passing control
aReceiver method: args
1. The message #method:
is sent to aReceiver
Pharo’s VM
3. Executes #method:
into the object
aReceiver
The message is captured
#beforeAction
#afterAction
2. A user-defined
action is executed
before the method’s
execution
4. An action is
executed after the
execution
3

Safe Message-Passing Control
•Meta-safe recursion
•Thread safety
•Safe handling of exceptions and non-local returns
•Uninstrumentation
4

Meta-safe recursion
The library should provide a meta-safe recursion prevention to manage
recursions originating from within the instrumented code.
5

Thread safety
It manage meta-executions in a thread-specific manner. It should ensure that
meta-executions are marked uniquely for each thread.
6

Handling of exceptions and non-local returns
It must ensure that the afterMethod executes under all circumstances,
whether an exception or a non-local return occurs.
7

Uninstrumentation
It must uninstrument all the methods that were instrumented, restoring them
to their original state.
8

Current Message-Passing Control Techniques
•Source code modification
•run:with:in method hook
9

Source Code Modification
10

Source Code Modification
11

Source Code Modification
12
Meta checking +
before action

Source Code Modification
13
Original code

Source Code Modification
14
Meta checking
+ After action

run:with:in
15
•During the lookup, if the VM does not find an instance of a CompiledMethod,
it sends the message #run:with:in to the located method object.
•The run:with:in: technique replaces a compiled method instance with a
ProxyObject understanding a run:with:in: message

run:with:in
16
Meta checking +
before action

run:with:in
17
Original code

run:with:in
18
Meta checking
+ After action

MethodProxies
19

MethodProxies
20

Trap Method
21

Trap Method
22

Trap Method
23

Trap Method
24

Experimental Setup
•RQ1 - Instrumentation and uninstrumentation overhead
•RQ2 - Execution overhead
25

•We define as a benchmark the execution of a project’s test suites.
Projects under analysis
Project’s name Description # methods # tests
Compression
It provides compression and
decompressing utilities.
387 29
File System
Manager
Pharo’s file system manager. 1426 450
Microdown
A markup language based on
Markdown.
1041 472
AST
Pharo’s abstract syntax tree (AST)
representation.
1591 641
26

Analysis Tools Under Study
•Method call graph
•Method coverage
•No-action instrumentation
27

Techniques Under Analysis
•MethodProxies
•#run:with:in
•Source code modification
28

Benchmark Metrics
•Overhead time

•Instrumentation overhead

•Uninstrumentation overhead
Overhead=I/NI
InstrumentationOverhead=insTime/lowInsTime
UninstrumentationOverhead=uninsTime/lowUninsTime
29

RQ1 Instrumentation Overhead
30
Best time for
all cases

RQ1 Instrumentation Overhead
31
Worst time for
all cases

RQ1 Instrumentation Overhead
32
Close to
#run:with:in

RQ1 Uninstrumentation Overhead
33

RQ1 Conclusion
•Instrumentation
•MethodProxies incurs an instrumentation overhead ranging from 1.16 to
2.38 × compared to the fastest time of run:with:in:
•It is significantly faster than the source code modification technique.
•Uninstrumentation
•There are no big differences among all the techniques
34

RQ2 Execution Overhead
35
Fastest in all
cases

RQ2 Execution Overhead
36

RQ2 Conclusion
•Among all benchmarks and analysis tools, MethodProxies has the lowest
execution overhead
37

More in the paper!
•More implementation details
•Detailed research questions
•Discussion and threats to
validity
38

MethodProxies: a Safe and Fast Library
•MethodProxies is safe and fast
•MethodProxies has the lowest execution overhead
•It allows to instrument any method on the system
•We use it on several tools and applications to make the instrumentation
github.com/pharo-contributions/MethodProxies
[email protected]
Sebastian JORDAN MONTAÑO