comp2100 performance analysis & intellectual property › pages › courses › comp2100 ›...

40
Dongwoo Kim Comp2100 Performance Analysis & Intellectual Property 1

Upload: others

Post on 06-Jul-2020

5 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Comp2100 Performance Analysis & Intellectual Property › pages › courses › comp2100 › ... · Slides adopted from Felix Crux’s PyCon2016 presentation 18. Caveat •I’m not

Dongwoo Kim

Comp2100Performance Analysis & Intellectual Property

1

Page 2: Comp2100 Performance Analysis & Intellectual Property › pages › courses › comp2100 › ... · Slides adopted from Felix Crux’s PyCon2016 presentation 18. Caveat •I’m not

Administrative – Quiz 3 & Lab test 2

• Quiz 3 due is today• Lab test 2 starts tomorrow

– Must attend the enrolled lab– Same as the LT1 and final exam environment– Practice how to use CSIT lab computers

• IDE settings

2

Page 3: Comp2100 Performance Analysis & Intellectual Property › pages › courses › comp2100 › ... · Slides adopted from Felix Crux’s PyCon2016 presentation 18. Caveat •I’m not

Administrative – GP Demo

• Add me as a reporter by this Friday• Each group needs to sign up for the demo

presentation– One of the tutorial sessions– Each team has ~10 minutes– Go to StReaMS and register for demo session

• One member per group• Don’t sign up more than on session

• Don’t need to prepare power point3

Page 4: Comp2100 Performance Analysis & Intellectual Property › pages › courses › comp2100 › ... · Slides adopted from Felix Crux’s PyCon2016 presentation 18. Caveat •I’m not

Administrative – Final Exam

• November 15th

• 9:00am~12:15pm (3h15m)• No materials allowed• Previous exams

– https://cs.anu.edu.au/courses/comp2100/exams/campus_only/

4

Page 5: Comp2100 Performance Analysis & Intellectual Property › pages › courses › comp2100 › ... · Slides adopted from Felix Crux’s PyCon2016 presentation 18. Caveat •I’m not

Administrative – Final Exam

• No programming questions with– Android Studio / PHP / JML

• Multiple choice questions– Check the previous exams– Practice how to run in Terminal

• Programming questions– Learn how to configure your IDE– Prepare how to run JAVA/JAVAC in terminal– No help during exam

5

Page 6: Comp2100 Performance Analysis & Intellectual Property › pages › courses › comp2100 › ... · Slides adopted from Felix Crux’s PyCon2016 presentation 18. Caveat •I’m not

Performance analysisAmdahl’s law

6

Page 7: Comp2100 Performance Analysis & Intellectual Property › pages › courses › comp2100 › ... · Slides adopted from Felix Crux’s PyCon2016 presentation 18. Caveat •I’m not

7

• Question: • You have a program X with two component parts A and

B, each of which takes 10 minutes. What is the latency of X?

• Suppose that you can speedup part B by a factor of 5. What is the latency now? What is the overall speedup?

Motivating Question

Page 8: Comp2100 Performance Analysis & Intellectual Property › pages › courses › comp2100 › ... · Slides adopted from Felix Crux’s PyCon2016 presentation 18. Caveat •I’m not

8

• Question: • You have a program X with two component parts A and

B, each of which takes 10 minutes. What is the latency of X?

• Suppose that you can speedup part B by a factor of 5. What is the latency now? What is the overall speedup?

• Answer:• If A and B are sequential, then Amdahl’s Law provides

an answer

Motivating Question

Page 9: Comp2100 Performance Analysis & Intellectual Property › pages › courses › comp2100 › ... · Slides adopted from Felix Crux’s PyCon2016 presentation 18. Caveat •I’m not

9

• How much extra performance can you get if you speed up part of your program?

• Notations:• S is the overall performance gain• k is the speed-up factor• α is the portion of speed-up

• 𝑇"#$ = 1 − 𝛼 𝑇)*+ + 𝛼-./01= 𝑇)*+( 1 − 𝛼 + 3

1)

• 𝑆 = -./0-678

= 99:3 ;<=

Amdahl’s Law

Page 10: Comp2100 Performance Analysis & Intellectual Property › pages › courses › comp2100 › ... · Slides adopted from Felix Crux’s PyCon2016 presentation 18. Caveat •I’m not

Amdahl’s Law - Example• Your program has one very slow procedure that

consumes 70% of the time. Next, you improve it by a factor of 2. What is the performance gain in the overall latency?

• 𝑆 = -./0-678

= 99:3 ;<=

= 99:>.@ ;A.BC

= 1.538

10

Page 11: Comp2100 Performance Analysis & Intellectual Property › pages › courses › comp2100 › ... · Slides adopted from Felix Crux’s PyCon2016 presentation 18. Caveat •I’m not

Amdahl’s Law - Example• Your program has one very slow procedure that

consumes 70% of the time. Next, you improve it by a factor of 2. What is the performance gain in the overall latency?

• 𝑆 = -./0-678

= 99:3 ;<=

= 99:>.@ ;A.BC

= 1.538

• Floating point instructions could be improved by 2X. Only 15% of instructions are floating point

• 𝑆 = -./0-678

= 99:3 ;<=

= 99:>.9D ;A.EFC

= 1.081

11

Page 12: Comp2100 Performance Analysis & Intellectual Property › pages › courses › comp2100 › ... · Slides adopted from Felix Crux’s PyCon2016 presentation 18. Caveat •I’m not

Application to Parallel Processing

• Now, let’s divide the program into sequential part, 1-P, and parallel part, P.

• Assume there are N processors then the improvement of the parallelizable part is N.

• Based on Amdahl’s law, the performance gain from N processors is

𝑆 =1

1 − 𝑃 + 𝑃𝑁

12

Page 13: Comp2100 Performance Analysis & Intellectual Property › pages › courses › comp2100 › ... · Slides adopted from Felix Crux’s PyCon2016 presentation 18. Caveat •I’m not

Limit as 𝑁 → ∞

limN→O

1

1 − 𝑃 + 𝑃𝑁=

11 − 𝑃

• Fundamental limitation of performance gain from parallelization

• Neglects other potential bottlenecks such as memory bandwidth and I/O bandwidth

13

Page 14: Comp2100 Performance Analysis & Intellectual Property › pages › courses › comp2100 › ... · Slides adopted from Felix Crux’s PyCon2016 presentation 18. Caveat •I’m not

14

Diminishing Returns

Page 15: Comp2100 Performance Analysis & Intellectual Property › pages › courses › comp2100 › ... · Slides adopted from Felix Crux’s PyCon2016 presentation 18. Caveat •I’m not

15

• Does your software perform as what you expect?• Does it complete fast?• Does it work well with more inputs• Does it break?

• Metrics of performance:• Latency• Throughput• Memory size• Network bandwidth• Concurrency

• Performance analysis• Best case• Average case• Worst case

Various aspects of performance analysis

Page 16: Comp2100 Performance Analysis & Intellectual Property › pages › courses › comp2100 › ... · Slides adopted from Felix Crux’s PyCon2016 presentation 18. Caveat •I’m not

Performance Profiling• Tools that provide a visual interface for detailed information

about the runtime operations of a program• Understand how your program utilizes different computing

resources (e.g. memory, CPU, GPU, harddisk, network)• Identify the bottleneck of your program• Optimize program implementation• Locate potential bugs in your program• Examples:

• JConsole• VisualVM• Eclipse Trace Compass

16

Page 17: Comp2100 Performance Analysis & Intellectual Property › pages › courses › comp2100 › ... · Slides adopted from Felix Crux’s PyCon2016 presentation 18. Caveat •I’m not

Trace Compass

17

Page 18: Comp2100 Performance Analysis & Intellectual Property › pages › courses › comp2100 › ... · Slides adopted from Felix Crux’s PyCon2016 presentation 18. Caveat •I’m not

Intellectual PropertyIn the context of software development

Slides adopted from Felix Crux’s PyCon2016 presentation

18

Page 19: Comp2100 Performance Analysis & Intellectual Property › pages › courses › comp2100 › ... · Slides adopted from Felix Crux’s PyCon2016 presentation 18. Caveat •I’m not

Caveat

• I’m not a lawyer!

19

Page 20: Comp2100 Performance Analysis & Intellectual Property › pages › courses › comp2100 › ... · Slides adopted from Felix Crux’s PyCon2016 presentation 18. Caveat •I’m not

Overview

• What is intellectual property?• Why do we need licenses?• Permissive licenses• Copyleft licenses• No license?

20

Page 21: Comp2100 Performance Analysis & Intellectual Property › pages › courses › comp2100 › ... · Slides adopted from Felix Crux’s PyCon2016 presentation 18. Caveat •I’m not

What is Intellectual Property?

• Intangible “creations of the mind” that the law lets you monopolize– Books, paintings, songs, movies, and

computer programs• The categories we will look at today:

– Copyrights– Patents– Trademarks

21

Page 22: Comp2100 Performance Analysis & Intellectual Property › pages › courses › comp2100 › ... · Slides adopted from Felix Crux’s PyCon2016 presentation 18. Caveat •I’m not

Copyright

• Rights to copy, distribute, modify the work• Protects creative, expressive work

– expressions of ideas• Meant to encourage people to make more• Given automatically to the creator

24

Page 23: Comp2100 Performance Analysis & Intellectual Property › pages › courses › comp2100 › ... · Slides adopted from Felix Crux’s PyCon2016 presentation 18. Caveat •I’m not

Patents

• For protecting functional inventions• The idea: tell us how it works, and you get

exclusivity for a while– processes, machines, manufactures,

compositions of matter• Beware of sneaky trolls and ambushes!

– Some licenses protect you

25

Page 24: Comp2100 Performance Analysis & Intellectual Property › pages › courses › comp2100 › ... · Slides adopted from Felix Crux’s PyCon2016 presentation 18. Caveat •I’m not

Trademarks

• Protect consumers from fakes and imitators

• Sort of automatic, but registration has power

• Covers names, logos and identifiers like that

• Still relevant to software projects– i.e. Project “Firefox”

26

Page 25: Comp2100 Performance Analysis & Intellectual Property › pages › courses › comp2100 › ... · Slides adopted from Felix Crux’s PyCon2016 presentation 18. Caveat •I’m not

27

Copyright Patent Trademark

MeaningProtection of original ideas and works

IP right granted by government

Sign, logo that distinguishes a product, service

Rights of Owner

Exclusive rights of reproduction and distribution

Legal rights to exclude unauthorized uses

Legal rights to exclude unauthorized uses

How to obtain No need to register Apply to specific

country (20yrs)Apply to specific country (10yrs)

Common Example

Books, music, movies

Jet engine design, medicine

Pepsi, McDonald’s logo

Tech Example Java API MPEG, 5G, Wifi Facebook, Facebook

like logo

Copyright, Patent, and Trademark

Page 26: Comp2100 Performance Analysis & Intellectual Property › pages › courses › comp2100 › ... · Slides adopted from Felix Crux’s PyCon2016 presentation 18. Caveat •I’m not

Licenses

• Grant rights people wouldn’t usually have:– To use– To modify– To share

• Create obligations:– Attribution– Share-alike (copyleft)– Whatever shows up in a proprietary license

28

Page 27: Comp2100 Performance Analysis & Intellectual Property › pages › courses › comp2100 › ... · Slides adopted from Felix Crux’s PyCon2016 presentation 18. Caveat •I’m not

Permissive Licenses

• Let developers do a lot– Including making things proprietary

• Usually just require attribution– and a warranty disclaimer

• Developer friendly / Related to open source– Not free software– Working more efficiently

29

Page 28: Comp2100 Performance Analysis & Intellectual Property › pages › courses › comp2100 › ... · Slides adopted from Felix Crux’s PyCon2016 presentation 18. Caveat •I’m not

Examples

• MIT/Expat/X11, ISC/n-clause BSD• Apache 2.0

30

Page 29: Comp2100 Performance Analysis & Intellectual Property › pages › courses › comp2100 › ... · Slides adopted from Felix Crux’s PyCon2016 presentation 18. Caveat •I’m not

• 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.

31

Page 30: Comp2100 Performance Analysis & Intellectual Property › pages › courses › comp2100 › ... · Slides adopted from Felix Crux’s PyCon2016 presentation 18. Caveat •I’m not

Grant of Patent License

• … each Contributor grants You a perpetual, no-charge, irrevocable patent license to use the Work

• … applies only to those patent claims that are infringed by their Contribution

• … if You institute patent litigation alleging that the Work constitutes patent infringement, then patent licenses granted to You shall terminate

32

Page 31: Comp2100 Performance Analysis & Intellectual Property › pages › courses › comp2100 › ... · Slides adopted from Felix Crux’s PyCon2016 presentation 18. Caveat •I’m not

Copyleft Licenses

• Guarantee user freedom• Prevent developers from restricting or

locking-in users• Require sharing derivatives the same way• Prevent building proprietary software• GPL (GNU general public license)• GPLv3

33

Page 32: Comp2100 Performance Analysis & Intellectual Property › pages › courses › comp2100 › ... · Slides adopted from Felix Crux’s PyCon2016 presentation 18. Caveat •I’m not

Examples

• GPL– does not allow you to add any additional

restriction– cannot combine the code that has more

restrictions (not compatible w. Apache 2.0)• GPLv3

– Add patent grant clause• LGPL (Lesser)

– allows you to use and integrate a software component released under the LGPL into their own software

34

Page 33: Comp2100 Performance Analysis & Intellectual Property › pages › courses › comp2100 › ... · Slides adopted from Felix Crux’s PyCon2016 presentation 18. Caveat •I’m not

I don’t care: No License!

• When you make a creative work, the work is under exclusive copyright by default.

• Nobody else can copy, distribute, or modify your work without any risk

• Visible software != Free/Open Source• Once the work has other contributors

(each a copyright holder), “nobody” starts including you.

36

Page 34: Comp2100 Performance Analysis & Intellectual Property › pages › courses › comp2100 › ... · Slides adopted from Felix Crux’s PyCon2016 presentation 18. Caveat •I’m not

https://choosealicense.com/

37Creative Commons Attribution 3.0 Unported License.

Page 35: Comp2100 Performance Analysis & Intellectual Property › pages › courses › comp2100 › ... · Slides adopted from Felix Crux’s PyCon2016 presentation 18. Caveat •I’m not

• https://en.wikipedia.org/wiki/Comparison_of_free_and_open-source_software_licenses

38

Page 36: Comp2100 Performance Analysis & Intellectual Property › pages › courses › comp2100 › ... · Slides adopted from Felix Crux’s PyCon2016 presentation 18. Caveat •I’m not

39

• A popular type of public copyright licenses that an author wants to give other people the right to share, use, and build upon a work that the author has created

• All CC licenses require that others who use your work in any way must give you credit the way you request, but not in a way that suggests you endorse them or their use

• If they want to use your work without giving you credit or for endorsement purposes, they must get your permission first

What is Creative Commons license

Page 37: Comp2100 Performance Analysis & Intellectual Property › pages › courses › comp2100 › ... · Slides adopted from Felix Crux’s PyCon2016 presentation 18. Caveat •I’m not

40

What is Creative Commons license

Page 38: Comp2100 Performance Analysis & Intellectual Property › pages › courses › comp2100 › ... · Slides adopted from Felix Crux’s PyCon2016 presentation 18. Caveat •I’m not

Wrap-upWhat we have learned so far…

41

Page 39: Comp2100 Performance Analysis & Intellectual Property › pages › courses › comp2100 › ... · Slides adopted from Felix Crux’s PyCon2016 presentation 18. Caveat •I’m not

• Design– Algorithm: better complexity

• Data structure: Trees– OOP: Design patterns / UML– Data: json, xml

• Testing– Verification: Unit testing– Performance: Amdahl’s law

• Internals– Tokenizer / Parser

• Tools– Git, SSH, Makefile

42

Android App Dev.

Software construction

Page 40: Comp2100 Performance Analysis & Intellectual Property › pages › courses › comp2100 › ... · Slides adopted from Felix Crux’s PyCon2016 presentation 18. Caveat •I’m not

• Design– Algorithm: better complexity

• Data structure: Trees– OOP: Design patterns / UML– Data: json, xml

• Testing– Verification: Unit testing– Performance: Amdahl’s law

• Internals– Tokenizer / Parser

• Tools– Git, SSH, Makefile

43

Android App Dev.

Wanna more?

Comp3600

Comp2120

Comp2400

Comp3600

Comp2300 Comp3320

Comp2120