@@ -360,6 +360,10 @@ profiles generated by older tools or compilers.
360
360
General Storage Layout
361
361
-----------------------
362
362
363
+ The ASCII art depicts the general storage layout of indexed profiles.
364
+ Specifically, the indexed profile header describes the byte offset of individual
365
+ payload sections.
366
+
363
367
::
364
368
365
369
+-----------------------+---+
@@ -369,55 +373,49 @@ General Storage Layout
369
373
+-----------------------+ |
370
374
| HashType | H
371
375
+-----------------------+ E
372
- +-------| HashOffset | A
373
- | +-----------------------+ D
374
- +-----------| MemProfOffset | E
375
- | | +-----------------------+ R
376
- | | +--| BinaryIdOffset | |
377
- | | | +-----------------------+ |
378
- +---------------| TemporalProf- | |
379
- | | | | | TracesOffset | |
380
- | | | | +-----------------------+---+
381
- | | | | | Profile Summary | |
382
- | | | | +-----------------------+ P
383
- | | +------>| Function data | A
384
- | | | +-----------------------+ Y
385
- | +---------->| MemProf profile data | L
386
- | | +-----------------------+ O
387
- | +->| Binary Ids | A
376
+ | Byte Offset | A
377
+ +------ | of section A | D
378
+ | +-----------------------+ E
379
+ | | Byte Of fset | R
380
+ +-----------| of section B | |
381
+ | | +-----------------------+ |
382
+ | | | ... | |
383
+ | | +-----------------------+ |
384
+ | | | Byte Offset | |
385
+ +---------------| of section Z | |
386
+ | | | +-----------------------+---+
387
+ | | | | Profile Summary | |
388
+ | | | +-----------------------+ P
389
+ | | +------>| Section A | A
390
+ | | +-----------------------+ Y
391
+ | +---------->| Section B | L
392
+ | +-----------------------+ O
393
+ | | ... | A
388
394
| +-----------------------+ D
389
- +-------------->| Temporal profiles | |
395
+ +-------------->| Section Z | |
390
396
+-----------------------+---+
391
397
392
- Header
393
- --------
398
+ .. note ::
394
399
395
- ``Magic ``
396
- The purpose of the magic number is to be able to tell if the profile is an
397
- indexed profile.
400
+ Profile summary section is at the beginning of payload. It's right after the
401
+ header so its position is implicitly known after reading the header.
398
402
399
- ``Version ``
400
- Similar to raw profile version, the lower 32 bits specify the version of the
401
- indexed profile and the most significant 32 bits are reserved to specify the
402
- variant types of the profile.
403
+ Header
404
+ --------
403
405
404
- ``HashType ``
405
- The hashing scheme for on-disk hash table keys. Only MD5 hashing is used as of
406
- writing.
406
+ The `Header struct `_ is the source of truth and struct fields should explain
407
+ what's in the header. At a high level, `*Offset ` fields record section byte
408
+ offsets, which are used by readers to locate interesting sections and skip
409
+ uninteresting ones.
407
410
408
- ``HashOffset ``
409
- An on-disk hash table stores the per-function profile records. This field records
410
- the offset of this hash table's metadata (i.e., the number of buckets and
411
- entries), which follows right after the payload of the entire hash table.
411
+ .. note ::
412
412
413
- ``MemProfOffset ``
414
- Records the byte offset of MemProf profiling data.
413
+ To maintain backward compatibility of the indexed profiles, existing fields
414
+ shouldn't be deleted from struct definition; the field order shouldn't be
415
+ modified. New fields should be appended.
415
416
416
- ``BinaryIdOffset ``
417
- Records the byte offset of binary id sections.
417
+ .. _`Header struct` : https://github.com/llvm/llvm-project/blob/1a2960bab6381f2b288328e2371829b460ac020c/llvm/include/llvm/ProfileData/InstrProf.h#L1053-L1080
418
418
419
- ``TemporalProfTracesOffset ``
420
- Records the byte offset of temporal profiles.
421
419
422
420
Payload Sections
423
421
------------------
0 commit comments