karelklic / canal

Abstract interpreter for real-world application programs
https://github.com/karelklic/canal/wiki
Other
32 stars 2 forks source link

Lazy copies of domains #90

Closed xbrukner closed 11 years ago

xbrukner commented 11 years ago

It is usual, that when copy of some object is created, the copy might not be modified during its lifetime. In that case it would be great if the copy of object was only created if needed, otherwise call method of original instance (or return an attribute).

karelklic commented 11 years ago

The Qt library uses copy-on-write for their classes. It's described in http://doc.qt.digia.com/qt/implicit-sharing.html.

Here is their copy-on-write pointer: http://doc.qt.digia.com/qt/qshareddatapointer.html

karelklic commented 11 years ago

Current performance of master branch (no copy on write), super_ptr branch (cow limited to some domains?), and shared_data_pointer branch:

/usr/bin/time -v tool/canal tests/wc.s -e run -e quit

master
        User time (seconds): 88.92
        System time (seconds): 1.33
        Elapsed (wall clock) time (h:mm:ss or m:ss): 1:30.38
        Maximum resident set size: 1 287 MB
super_ptr
        User time (seconds): 32.50
        System time (seconds): 0.13
        Elapsed (wall clock) time (h:mm:ss or m:ss): 0:32.70
        Maximum resident set size (kbytes): 60,3 MB
shared_data_pointer
        User time (seconds): 30.01
        System time (seconds): 0.03
        Elapsed (wall clock) time (h:mm:ss or m:ss): 0:30.06
        Maximum resident set size (kbytes): 31,1 MB
karelklic commented 11 years ago

Hehe, optimization on domain comparison operators, shared_data_pointer branch:

Before:

/usr/bin/time -v tool/canal tests/wc.s -e run -e quit
Elapsed (wall clock) time (h:mm:ss or m:ss): 0:30.06

After:

/usr/bin/time -v tool/canal tests/wc.s -e run -e quit
Elapsed (wall clock) time (h:mm:ss or m:ss): 0:03.82
xbrukner commented 11 years ago

Oh crap, mine is slower :D 5.76s and 60MB on wc.

sutamatej commented 11 years ago

:thumbsup:

karelklic commented 11 years ago

Fixed in e7adf61f45ff0d2d47532e1e0b1013df151e6aa4.