Differences

This shows you the differences between two versions of the page.

Link to this comparison view

ep:teme:01 [2026/02/24 21:37]
radu.mantu
ep:teme:01 [2026/03/04 14:35] (current)
radu.mantu [Memory access tracing]
Line 1: Line 1:
 ====== Assignment ====== ====== Assignment ======
-<​hidden>​ 
- 
-~~TOC~~ 
  
 ===== 01. Overview ===== ===== 01. Overview =====
Line 14: Line 11:
 ==== Partner up ==== ==== Partner up ====
  
-Select a partner for this assignment and submit your choice via this **form (TODO)** by **date (TODO)**.+Select a partner for this assignment and submit your choice via [[https://​forms.gle/​unnN3f8pksSbg85g9|this form]]. \\ 
 +If you can't find a partner, try advertising on the [[https://​curs.upb.ro/​2025/​mod/​forum/​discuss.php?​d=3902|assignment forum]].
  
 <note important>​ <note important>​
-Only one student is required to complete the form on behalf of the team. +Only one student is required to complete the form on behalf of the team.\\ 
- +Only one student (not necessarily the same) will have to upload the assignment on moodle.\\ 
-Only one student (not necessarily the same) will have to upload the assignment on moodle.+You are **required** to work with a partner on this assignment.
 </​note>​ </​note>​
  
 ==== Usage ==== ==== Usage ====
-Your application should be implemented in C/C++ and take as positional arguments the commandline invocation of the program under test. For example, ''​./​my_tracer curl http://​example.com''​ will launch the tracer program that will then fork() & exec() **curl** and start monitoring its memory transactions at the same time. In case you need to add flags to your application,​ you can separate them from the child process' commandline ​with ''​%%--%%''​.+ 
 +Your application should be implemented in C/C++ and take as positional arguments the commandline invocation of the program under test. For example, ''​./​my_tracer curl http://​example.com''​ will launch the tracer program that will then fork() & exec() **curl** and start monitoring its memory transactions at the same time. In case you need to add flags to your application,​ you can separate them from the commandline of the child process with ''​%%--%%''​.
  
 ==== Memory access tracing ==== ==== Memory access tracing ====
  
-Once the child process is up and running, you will have to monitor the **read** and **write** operations //​separately//​. Specifically,​ you will have to determine **what address has been accessed** and **what instruction ​has performed this access**. This can be achieved using [[https://​www.intel.com/​content/​www/​us/​en/​developer/​articles/​technical/​timed-process-event-based-sampling-tpebs.html|Intel Processor Event Based Sampling (PEBS)]], a mode of operation that will write detailed sample information in a physical memory ring buffer whenever the event counter triggers. You will not be required to interact with this system directly, but instead utilize the [[https://​man.archlinux.org/​man/​perf_event_open.2.en#​MMAP_layout|sampled mode]] of Linux Perf Events.+Once the child process is up and running, you will have to monitor the **read** and **write** operations //​separately//​. Specifically,​ you will have to determine **what address has been accessed** and **what instruction performed this access**. This can be achieved using [[https://​www.intel.com/​content/​www/​us/​en/​developer/​articles/​technical/​timed-process-event-based-sampling-tpebs.html|Intel Processor Event Based Sampling (PEBS)]], a mode of operation that will write detailed sample information in a physical memory ring buffer whenever the event counter triggers. You will not be required to interact with this system directly, but instead utilize the [[https://​man.archlinux.org/​man/​perf_event_open.2.en#​MMAP_layout|sampled mode]] of Linux Perf Events.
  
 ==== Mapping addresses to objects ==== ==== Mapping addresses to objects ====
  
-Once this task is complete, your next objective is to map both the accessed address and the instruction'​s address to a memory mapped object (where appropriate). For instance, you will have to be able to distinguish between a memory access performed by code belonging to **libc** or **libz**. Additionally,​ you must identify whether the accessed memory address belongs to a data segment of a memory mapped object, or the heap / stack instead. To solve this task, know that the Linux Perf system can generate more than PMC Event Records while in sampled mode. In fact, the kernel can be configured to report any **mmap()** that the program under test performs. ​In fact, this is how **perf record** can embed object information into each sample for **perf report** to subsequently translate into //"​hot"//​ functions, even with ASLR enabled.+Once this task is complete, your next objective is to map both the accessed address and the instruction'​s address to a memory mapped object (where appropriate). For instance, you will have to be able to distinguish between a memory access performed by code belonging to **libc** or **libz**. Additionally,​ you must identify whether the accessed memory address belongs to a data segment of a memory mapped object, or the heap / stack instead. To solve this task, know that the Linux Perf system can generate more than PMC Event Records while in sampled mode. In fact, the kernel can be configured to report any **mmap()** that the program under test performs. ​This is how **perf record** can embed object information into the sample ​file in order for **perf report** to subsequently translate ​those samples ​into //"​hot"//​ functions, even with ASLR enabled.
  
 <​note>​ <​note>​
Line 46: Line 45:
  
 <note important>​ <note important>​
-Small bonus available if you can limit the displayed samples to a user-specified time window. In other words, show the memory access distribution for the past **N** seconds while continuously updating the plot. Whether a sample is part of the window or not should be decided based on the time it was taken, not when you consumed it from the record ring buffer. Perf also has an option for including ​a timestamp to each record.+Small bonus available if you can limit the displayed samples to a user-specified time window. In other words, show the memory access distribution for the past **N** seconds while continuously updating the plot. Whether a sample is part of the window or not should be decided based on the time it was taken, not when you consumed it from the record ring buffer. Perf also has an option for attaching ​a timestamp to each record.
 </​note>​ </​note>​
  
Line 61: Line 60:
 ===== Grading ===== ===== Grading =====
  
-The deadline for this assignment is **date (TODO)**. Upload a **zip archive** containing the source code, Makefile, documentation and any **micro-benchmarks** used in testing (don't go and include **redis** in your submission). The archive should be uploaded to this **moodle assignment ​(TODO)**.+The deadline for this assignment is **11 May**. Upload a **zip archive** containing the source code, Makefile, documentation and any **micro-benchmarks** used in testing (don't go and include **redis** in your submission). The archive should be uploaded to this [[https://​curs.upb.ro/​2025/​mod/​assign/​view.php?​id=135330|moodle assignment]].
  
-This assignment is worth **??p** of your final grade. The breakdown by task is as follows: +This assignment is worth **1.5p** of your final grade. The breakdown by task is as follows: 
-  * **Memory access tracing (??p):** If nothing else, the application can provably monitor memory accesses by printing the relevant information to //​stdout//​. +  * **Memory access tracing (30%):** If nothing else, the application can provably monitor memory accesses by printing the relevant information to //​stdout//​. 
-  * **Mapping addresses to objects (??p):** The application should be able to generate statistics for both accessed data regions and code regions performing the accesses. Reads and writes must be treated separately. +  * **Mapping addresses to objects (30%):** The application should be able to generate statistics for both accessed data regions and code regions performing the accesses. Reads and writes must be treated separately. 
-  * **Plotting (??p):** Live illustration of the statistics mentioned in the previous task. Be creative and include even more data if you can. +  * **Plotting (10%):** Live illustration of the statistics mentioned in the previous task. Be creative and include even more data if you can. 
-  * **Documentation (??p):** Adequately explains the design and implementation. Can convincingly prove that both are sound. Describes the testing methodology and presents the results in a //concise// but thorough manner. In other words: //"​Someone has to read this so be considerate and don't waste their time. Improves your chances of not pissing them off."//​+  * **Documentation (30%):** Adequately explains the design and implementation. Can convincingly prove that both are sound. Describes the testing methodology and presents the results in a //concise// but thorough manner. In other words: //"​Someone has to read this so be considerate and don't waste their time. Improves your chances of not pissing them off."//​
  
 <note important>​ <note important>​
 The **first pair** that submits an assignment that receives **full marks** will automatically pass the exam with a maximum grade. The **first pair** that submits an assignment that receives **full marks** will automatically pass the exam with a maximum grade.
- 
-Up to **??p** bonus points can be awarded at the discretion of the teaching assistants for an exceptional implementation or evaluation. 
 </​note>​ </​note>​
  
-</​hidden>​+===== FAQ ===== 
 + 
 +:?:
ep/teme/01.1771961864.txt.gz · Last modified: 2026/02/24 21:37 by radu.mantu
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0