Size: 1169
Comment:
|
Size: 8701
Comment: slides guis
|
Deletions are marked like this. | Additions are marked like this. |
Line 1: | Line 1: |
= Willkommen zum Wiki des Seminars '''Java vs. C++''' im Wintersemester 2010 / 2011 = | = Welcome to the Wiki of the seminar '''Java vs. C++''' in the winter semester 2010 / 2011 = |
Line 3: | Line 3: |
Das Seminar wird gehalten von [[http://ad.informatik.uni-freiburg.de/staff/bast|Prof. Dr. Hannah Bast]]. Es findet statt jeden Mittwoch von 14:15 bis ca. 15:45 Uhr, im Seminarraum 01-018 in Gebäude 101. Der erste Termin ist am Mittwoch, den 20. Oktober 2010. Der letzte Termin ist am Mittwoch, den 9. Februar 2011. Am Mittwoch, 29. Dezember 2010 und am Mittwoch, 5. Januar 2011 ist Weihnachtspause. Das sind insgesamt 15 Seminartermine. | This seminar is given by [[http://ad.informatik.uni-freiburg.de/staff/bast|Prof. Dr. Hannah Bast]], assisted by [[http://ad.informatik.uni-freiburg.de/staff/buchholb|Björn Buchhold]](buchholb@informatik.....). The seminar takes place every Wednesday, 2:15 pm - 3:45 pm, in the seminar room 01-018 in building 101. Our first session is on Wednesday, October 20, 2010. The last session is on Wednesday, February 9, 2011. On Wednesday December 29, 2010 and on Wednesday January 5, 2011 there is no session due to the christmas break. That's 15 sessions altogether. All sessions are recorded (video + audio). |
Line 5: | Line 5: |
An ersten Termin (Mittwoch, 20. Oktober) gibt es einen Überblick über die Veranstaltung und die Vorträge werden vergeben. Am zweiten Termin (Mittwoch, 27. Oktober) hält Hannah Bast den ersten Vortrag. An jedem der folgenden Terminen gibt es einen oder maximal zwei Vorträge von den Teilnehmern, mit anschließender Diskussion. Alle Vorträge werden aufgezeichnet. | The seminar is about the ''performance'' differences between Java and C++, in particular, running time and space consumption. It's NOT about the differences in syntax, language features, ease of programming, etc. The sessions will be recorded, and the slides as well the recordings will be put online after each presentation: see the links below. |
Line 7: | Line 7: |
Die Veranstaltung wird mitbetreut von Björn Buchhold. | Hier ist der [[attachment:evaluation-java-vs-cplusplus-ws1011.pdf|Evaluationsbogen]] für die Veranstaltung. Sie können den ausgefüllten Bogen entweder hier auf diese Wikiseite hochladen (vorher ausloggen, sonst nicht anonym!), oder persönlich bei [[http://ad.informatik.uni-freiburg.de/staff/bast|Hannah Bast]] oder [[http://ad.informatik.uni-freiburg.de/staff/buchholb|Björn Buchhold]] abgeben. |
Line 9: | Line 9: |
== Informationen und Materialien zu den einzelnen Terminen == * Mittwoch, 20. Oktober 2010: Einführung und Überblick [[xxx|Folien]]. * Mittwoch, 27. Oktober 2010: |
== Information and materials for each session == |
Line 13: | Line 11: |
== Aufzeichnungen == [kommt noch] |
1. Wednesday October 20, 2010: '''Introduction and Overview''', Hannah Bast, [[attachment:session-1.pdf|slides]], [[attachment:session-1.avi|recording as AVI (not cut)]]. 1. Wednesday October 27, 2010: '''Machine code generation in C++''', Hannah Bast,[[attachment:session-2.pdf|slides]], [[attachment:session-2.avi|recording as AVI (not cut)]]. * '''Topics:''' x86 Assembler (history, registers, instructions, stack, function calls, some simple programs, MXX 128-bit streaming registers). * '''Remember 1:''' Write an array of 256 million ints = 1 GB. C++ unoptimized (gcc -O 0): 1.1s, Java: 0.8s, Hand-written assembler code: 0.6s, C++ optimized (gcc -O 3): 0.4s. * '''Remember 2:''' C++ unoptimized (gcc -O 0) translates the code line by line to machine code (just like Java without JIT). * '''Remember 3:''' Almost all PCs / notebooks / servers today use x86. Mobile phones etc. use RISC. 1. Wednesday November 3, 2010: The Java Virtual Machine (Robin Schirrmeister),[[attachment:jvm.pdf|slides as pdf]], [[attachment:jvm.odp|slides as odp]][[attachment:session-3.wmv|recording as WMV]],[[attachment:JasminFaculty.j|faculty function written in jasmin]]. * '''Topics:''' Introduction to the Java Virtual Machine and Problems with benchmarking Java. * The JVM is a virtual machine that can be used to run programs from any language that has a compiler to Java Bytecode. * The JVM was designed with a focus on portability and security of the programs running on it. * Due to the complex features of modern JVM implementations and their optimization techniques, correctly benchmarking a '''long-running''' Java program is difficult. * When Benchmarking you need to run the benchmarked program many times to avoid measuring JVM startup time, JIT compile time, etc. One Benchmark Framework taking care of this can be found at http://www.ibm.com/developerworks/library/j-benchmark2/index.html 1. Wednesday November 10, 2010: Compiler optimization in C++ (Jens Hoffmann), [[attachment:cpp_compiler_opt.pdf|slides as pdf]] [[attachment:session-4.wmv|recording as WMV]]. 1. Wednesday November 17, 2010: NO SESSION. 1. Wednesday November 24, 2010: Java Just-in-Time Compilation (Jan Kelch), [[attachment:JavaJITC.pdf|slides as pdf]] [[attachment:session-5.wmv|recording as WMV]]. 1. Wednesday December 1, 2010: Memory management in C++ (Simon Rettberg), [[attachment:memory_management_c++.pdf|slides as pdf]][[attachment:session-6.wmv|recording as WMV]]. 1. Wednesday December 8, 2010: Memory management in Java (Arda Akcay), [[attachment:session-7.wmv|recording as WMV]]. 1. Wednesday December 15, 2010: GCJ (Thomas Liebetraut), [[attachment:GCJ|slides as pdf]] [[attachment:session-8.wmv|recording as WMV]]. * '''Topics:''' Building blocks of a Java runtime environment, history if different Java implementations, GCJ's mode of operation, comparison Hotspot/GIJ/GCJ * GCJ (GNU Compiler for Java) bytecode and Oracle's javac bytecode are very similar, so no performance differenz when using the same VM * GIJ (GNU Interpreter for Java) is a LOT slower than Hotspot, especially when it comes to memory de-allocation * GCJ to native code is somewhat faster than JITting (even with Hotspot), but has the same major problems with de-allocation as GIJ * C++ with all optimizations still faster 1. Wednesday December 22, 2010: RTL optimization (Alexander Nutz) [[attachment:session9-RTL-pres.pdf|slides as pdf]] [[attachment:session-9.wmv|recording as WMV]]. * '''Topics:''' RTL in GCC: compiler internal representations: AST, CFG ; RTL as GCC's intermediate representation ; optimizations done in RTL * AST (abstract syntax tree) is the representation a compiler works on, CFG (control flow graph) is for some (quite common) analyses * For hardware-independent optimizations RTL is gradually replaced by Tree-SSA but it is still necessary for hardware-dependent optimizations like register allocation and still many optimizations are done in it * When trying to read RTL (all passes can be output by -fdump-rtl-all) the sixth argument of each (insn ...) is the interesting one (LISP-like syntax) 1. Wednesday January 12, 2010: Arrays Java vs. C++ (Simon Skilevis, Ammar Qaseem) [[attachment:Array in C++.pptx|c++ slides as powerpoint]] [[attachment:Array in c++.pdf|c++ slides as pdf]] [[attachment:javaArray.ppt|java slides as powerpoint]] . * '''Topics ( C++ ): '''1D Array Representation and Space Overhead of 1D Array . * 2D Array Representation ( Row-mapping representation,Column-mapping representation,and Array-of-array representation) and Space Overhead of each way. * Buffer Overflow ( no Bounds Checking ): C and C++ provide no built-in protection against accessing or overwriting data in any part of memory and solution for this problem. * Dynamic memory allocation( new and delete operator). * STL-Vector as dynamic array and advantages of Vectors. * '''Topics ( Java ): ''' 1. Wednesday January 19, 2010: Strings Java vs. C++ (Michael Pereira, Christoph Hofmann) [[attachment:c++ slides as pdf|c++ slides as pdf]] [[attachment:Strings in Java - Annotated|Java slides as pdf]] [[attachment:session-11.wmv|recording as WMV]]. * '''Topics ( C++ ): ''' String Implementations (STL, CString), Sting Optimizations (Small String, Reserve, Copy-On-Write, Call-By-Reference), String Functions (find, Multibyte) * '''Remember 1:''' The STL brings many optimizations and functions to String and should be prefered over the old cstring * '''Remember 2:''' String Optimizations really can increase performance. Some are already implemented by Libraries (small string opt. by boost, copy on write by qt) or can be implemented by yourself. * '''Remember 3:''' Use reserve when working with large strings or concatenation and call-by-reference when passing strings to functions to really improve performance. * '''Topics ( Java ): ''' 1. Wednesday January 26, 2010: NO SESSION. 1. Wednesday February 2, 2010: Threads Java vs. C++ (Niklas Meinzer). * '''Topics: ''' Basics of Multithreading: Properties of Processes and Threads * Threads in Java: Thread creation, Mutual exclusion and wait-notify thread coordination * pthreads: C-style thread library: properties and usage * boost::threads: C++ style thread library: properties and usage * Performance tests: Thread creation and Locking 1. Wednesday February 9, 2010: Graphical User Interfaces Java cs. C++ (Daniel Brand, Franz Dietrich). [[attachment:slides-Java-vs-c++.pdf|slides]] * Performance completely depends on hardware acceleration * Native look and feel vs. emulation ( AWT, SWT, Gtk <-> Swing) * Complex vs. simple layouting (SWT, Gtk <-> Swing) * Avoid Swing under Linux when performance matters (might get better in future with accelerated backend) * Layers on Linux: Gtk -> Cairo -> xlib -> Driver * You can't tell for sure which of them is better (depends on the needs and system you want to run it on) Interesting additional topics: smart pointers / auto pointers / scoped pointers in C++. |
Welcome to the Wiki of the seminar '''Java vs. C++''' in the winter semester 2010 / 2011
This seminar is given by Prof. Dr. Hannah Bast, assisted by Björn Buchhold(buchholb@informatik.....). The seminar takes place every Wednesday, 2:15 pm - 3:45 pm, in the seminar room 01-018 in building 101. Our first session is on Wednesday, October 20, 2010. The last session is on Wednesday, February 9, 2011. On Wednesday December 29, 2010 and on Wednesday January 5, 2011 there is no session due to the christmas break. That's 15 sessions altogether. All sessions are recorded (video + audio).
The seminar is about the performance differences between Java and C++, in particular, running time and space consumption. It's NOT about the differences in syntax, language features, ease of programming, etc. The sessions will be recorded, and the slides as well the recordings will be put online after each presentation: see the links below.
Hier ist der Evaluationsbogen für die Veranstaltung. Sie können den ausgefüllten Bogen entweder hier auf diese Wikiseite hochladen (vorher ausloggen, sonst nicht anonym!), oder persönlich bei Hannah Bast oder Björn Buchhold abgeben.
Information and materials for each session
Wednesday October 20, 2010: Introduction and Overview, Hannah Bast, slides, recording as AVI (not cut).
Wednesday October 27, 2010: Machine code generation in C++, Hannah Bast,slides, recording as AVI (not cut).
Topics: x86 Assembler (history, registers, instructions, stack, function calls, some simple programs, MXX 128-bit streaming registers).
Remember 1: Write an array of 256 million ints = 1 GB. C++ unoptimized (gcc -O 0): 1.1s, Java: 0.8s, Hand-written assembler code: 0.6s, C++ optimized (gcc -O 3): 0.4s.
Remember 2: C++ unoptimized (gcc -O 0) translates the code line by line to machine code (just like Java without JIT).
Remember 3: Almost all PCs / notebooks / servers today use x86. Mobile phones etc. use RISC.
Wednesday November 3, 2010: The Java Virtual Machine (Robin Schirrmeister),slides as pdf, slides as odprecording as WMV,faculty function written in jasmin.
Topics: Introduction to the Java Virtual Machine and Problems with benchmarking Java.
- The JVM is a virtual machine that can be used to run programs from any language that has a compiler to Java Bytecode.
- The JVM was designed with a focus on portability and security of the programs running on it.
Due to the complex features of modern JVM implementations and their optimization techniques, correctly benchmarking a long-running Java program is difficult.
When Benchmarking you need to run the benchmarked program many times to avoid measuring JVM startup time, JIT compile time, etc. One Benchmark Framework taking care of this can be found at http://www.ibm.com/developerworks/library/j-benchmark2/index.html
Wednesday November 10, 2010: Compiler optimization in C++ (Jens Hoffmann), slides as pdf recording as WMV.
- Wednesday November 17, 2010: NO SESSION.
Wednesday November 24, 2010: Java Just-in-Time Compilation (Jan Kelch), slides as pdf recording as WMV.
Wednesday December 1, 2010: Memory management in C++ (Simon Rettberg), slides as pdfrecording as WMV.
Wednesday December 8, 2010: Memory management in Java (Arda Akcay), recording as WMV.
Wednesday December 15, 2010: GCJ (Thomas Liebetraut), slides as pdf recording as WMV.
Topics: Building blocks of a Java runtime environment, history if different Java implementations, GCJ's mode of operation, comparison Hotspot/GIJ/GCJ
- GCJ (GNU Compiler for Java) bytecode and Oracle's javac bytecode are very similar, so no performance differenz when using the same VM
- GIJ (GNU Interpreter for Java) is a LOT slower than Hotspot, especially when it comes to memory de-allocation
- GCJ to native code is somewhat faster than JITting (even with Hotspot), but has the same major problems with de-allocation as GIJ
- C++ with all optimizations still faster
Wednesday December 22, 2010: RTL optimization (Alexander Nutz) slides as pdf recording as WMV.
Topics: RTL in GCC: compiler internal representations: AST, CFG ; RTL as GCC's intermediate representation ; optimizations done in RTL
- AST (abstract syntax tree) is the representation a compiler works on, CFG (control flow graph) is for some (quite common) analyses
- For hardware-independent optimizations RTL is gradually replaced by Tree-SSA but it is still necessary for hardware-dependent optimizations like register allocation and still many optimizations are done in it
- When trying to read RTL (all passes can be output by -fdump-rtl-all) the sixth argument of each (insn ...) is the interesting one (LISP-like syntax)
Wednesday January 12, 2010: Arrays Java vs. C++ (Simon Skilevis, Ammar Qaseem) c++ slides as powerpoint c++ slides as pdf java slides as powerpoint .
Topics ( C++ ): 1D Array Representation and Space Overhead of 1D Array .
- 2D Array Representation ( Row-mapping representation,Column-mapping representation,and Array-of-array representation) and Space Overhead of each way.
- Buffer Overflow ( no Bounds Checking ): C and C++ provide no built-in protection against accessing or overwriting data in any part of memory and solution for this problem.
- Dynamic memory allocation( new and delete operator).
- STL-Vector as dynamic array and advantages of Vectors.
Topics ( Java ):
Wednesday January 19, 2010: Strings Java vs. C++ (Michael Pereira, Christoph Hofmann) c++ slides as pdf Java slides as pdf recording as WMV.
Topics ( C++ ): String Implementations (STL, CString), Sting Optimizations (Small String, Reserve, Copy-On-Write, Call-By-Reference), String Functions (find, Multibyte)
Remember 1: The STL brings many optimizations and functions to String and should be prefered over the old cstring
Remember 2: String Optimizations really can increase performance. Some are already implemented by Libraries (small string opt. by boost, copy on write by qt) or can be implemented by yourself.
Remember 3: Use reserve when working with large strings or concatenation and call-by-reference when passing strings to functions to really improve performance.
Topics ( Java ):
- Wednesday January 26, 2010: NO SESSION.
- Wednesday February 2, 2010: Threads Java vs. C++ (Niklas Meinzer).
Topics: Basics of Multithreading: Properties of Processes and Threads
- Threads in Java: Thread creation, Mutual exclusion and wait-notify thread coordination
- pthreads: C-style thread library: properties and usage
- boost::threads: C++ style thread library: properties and usage
- Performance tests: Thread creation and Locking
Wednesday February 9, 2010: Graphical User Interfaces Java cs. C++ (Daniel Brand, Franz Dietrich). slides
- Performance completely depends on hardware acceleration
Native look and feel vs. emulation ( AWT, SWT, Gtk <-> Swing)
Complex vs. simple layouting (SWT, Gtk <-> Swing)
- Avoid Swing under Linux when performance matters (might get better in future with accelerated backend)
Layers on Linux: Gtk -> Cairo -> xlib -> Driver
- You can't tell for sure which of them is better (depends on the needs and system you want to run it on)
Interesting additional topics: smart pointers / auto pointers / scoped pointers in C++.