H5FDlog.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479
  1. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  2. * Copyright by The HDF Group. *
  3. * Copyright by the Board of Trustees of the University of Illinois. *
  4. * All rights reserved. *
  5. * *
  6. * This file is part of HDF5. The full HDF5 copyright notice, including *
  7. * terms governing use, modification, and redistribution, is contained in *
  8. * the COPYING file, which can be found at the root of the source code *
  9. * distribution tree, or in https://www.hdfgroup.org/licenses. *
  10. * If you do not have access to either file, you may request a copy from *
  11. * help@hdfgroup.org. *
  12. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  13. /*
  14. * Programmer: Quincey Koziol
  15. * Monday, April 17, 2000
  16. *
  17. * Purpose: The public header file for the log driver.
  18. */
  19. #ifndef H5FDlog_H
  20. #define H5FDlog_H
  21. #define H5FD_LOG (H5FDperform_init(H5FD_log_init))
  22. #define H5FD_LOG_VALUE H5_VFD_LOG
  23. /* Flags for H5Pset_fapl_log() */
  24. /* Flags for tracking 'meta' operations (truncate) */
  25. #define H5FD_LOG_TRUNCATE 0x00000001
  26. #define H5FD_LOG_META_IO (H5FD_LOG_TRUNCATE)
  27. /* Flags for tracking where reads/writes/seeks occur */
  28. #define H5FD_LOG_LOC_READ 0x00000002
  29. #define H5FD_LOG_LOC_WRITE 0x00000004
  30. #define H5FD_LOG_LOC_SEEK 0x00000008
  31. #define H5FD_LOG_LOC_IO (H5FD_LOG_LOC_READ | H5FD_LOG_LOC_WRITE | H5FD_LOG_LOC_SEEK)
  32. /* Flags for tracking number of times each byte is read/written */
  33. #define H5FD_LOG_FILE_READ 0x00000010
  34. #define H5FD_LOG_FILE_WRITE 0x00000020
  35. #define H5FD_LOG_FILE_IO (H5FD_LOG_FILE_READ | H5FD_LOG_FILE_WRITE)
  36. /* Flag for tracking "flavor" (type) of information stored at each byte */
  37. #define H5FD_LOG_FLAVOR 0x00000040
  38. /* Flags for tracking total number of reads/writes/seeks/truncates */
  39. #define H5FD_LOG_NUM_READ 0x00000080
  40. #define H5FD_LOG_NUM_WRITE 0x00000100
  41. #define H5FD_LOG_NUM_SEEK 0x00000200
  42. #define H5FD_LOG_NUM_TRUNCATE 0x00000400
  43. #define H5FD_LOG_NUM_IO (H5FD_LOG_NUM_READ | H5FD_LOG_NUM_WRITE | H5FD_LOG_NUM_SEEK | H5FD_LOG_NUM_TRUNCATE)
  44. /* Flags for tracking time spent in open/stat/read/write/seek/truncate/close */
  45. #define H5FD_LOG_TIME_OPEN 0x00000800
  46. #define H5FD_LOG_TIME_STAT 0x00001000
  47. #define H5FD_LOG_TIME_READ 0x00002000
  48. #define H5FD_LOG_TIME_WRITE 0x00004000
  49. #define H5FD_LOG_TIME_SEEK 0x00008000
  50. #define H5FD_LOG_TIME_TRUNCATE 0x00010000
  51. #define H5FD_LOG_TIME_CLOSE 0x00020000
  52. #define H5FD_LOG_TIME_IO \
  53. (H5FD_LOG_TIME_OPEN | H5FD_LOG_TIME_STAT | H5FD_LOG_TIME_READ | H5FD_LOG_TIME_WRITE | \
  54. H5FD_LOG_TIME_SEEK | H5FD_LOG_TIME_TRUNCATE | H5FD_LOG_TIME_CLOSE)
  55. /* Flags for tracking allocation/release of space in file */
  56. #define H5FD_LOG_ALLOC 0x00040000
  57. #define H5FD_LOG_FREE 0x00080000
  58. #define H5FD_LOG_ALL \
  59. (H5FD_LOG_FREE | H5FD_LOG_ALLOC | H5FD_LOG_TIME_IO | H5FD_LOG_NUM_IO | H5FD_LOG_FLAVOR | \
  60. H5FD_LOG_FILE_IO | H5FD_LOG_LOC_IO | H5FD_LOG_META_IO)
  61. #ifdef __cplusplus
  62. extern "C" {
  63. #endif
  64. H5_DLL hid_t H5FD_log_init(void);
  65. /**
  66. * \ingroup FAPL
  67. *
  68. * \brief Sets up the logging virtual file driver (#H5FD_LOG) for use
  69. *
  70. * \fapl_id
  71. * \param[in] logfile Name of the log file
  72. * \param[in] flags Flags specifying the types of logging activity
  73. * \param[in] buf_size The size of the logging buffers, in bytes (see description)
  74. * \returns \herr_t
  75. *
  76. * \details H5Pset_fapl_log() modifies the file access property list to use the
  77. * logging driver, #H5FD_LOG. The logging virtual file driver (VFD) is
  78. * a clone of the standard SEC2 (#H5FD_SEC2) driver with additional
  79. * facilities for logging VFD metrics and activity to a file.
  80. *
  81. * \p logfile is the name of the file in which the logging entries are
  82. * to be recorded.
  83. *
  84. * The actions to be logged are specified in the parameter \p flags
  85. * using the pre-defined constants described in the following
  86. * table. Multiple flags can be set through the use of a logical \c OR
  87. * contained in parentheses. For example, logging read and write
  88. * locations would be specified as
  89. * \Code{(H5FD_LOG_LOC_READ|H5FD_LOG_LOC_WRITE)}.
  90. *
  91. * <table>
  92. * <caption>Table1: Logging Flags</caption>
  93. * <tr>
  94. * <td>
  95. * #H5FD_LOG_LOC_READ
  96. * </td>
  97. * <td rowspan="3">
  98. * Track the location and length of every read, write, or seek operation.
  99. * </td>
  100. * </tr>
  101. * <tr><td>#H5FD_LOG_LOC_WRITE</td></tr>
  102. * <tr><td>#H5FD_LOG_LOC_SEEK</td></tr>
  103. * <tr>
  104. * <td>
  105. * #H5FD_LOG_LOC_IO
  106. * </td>
  107. * <td>
  108. * Track all I/O locations and lengths. The logical equivalent of the following:
  109. * \Code{(#H5FD_LOG_LOC_READ | #H5FD_LOG_LOC_WRITE | #H5FD_LOG_LOC_SEEK)}
  110. * </td>
  111. * </tr>
  112. * <tr>
  113. * <td>
  114. * #H5FD_LOG_FILE_READ
  115. * </td>
  116. * <td rowspan="2">
  117. * Track the number of times each byte is read or written.
  118. * </td>
  119. * </tr>
  120. * <tr><td>#H5FD_LOG_FILE_WRITE</td></tr>
  121. * <tr>
  122. * <td>
  123. * #H5FD_LOG_FILE_IO
  124. * </td>
  125. * <td>
  126. * Track the number of times each byte is read and written. The logical
  127. * equivalent of the following:
  128. * \Code{(#H5FD_LOG_FILE_READ | #H5FD_LOG_FILE_WRITE)}
  129. * </td>
  130. * </tr>
  131. * <tr>
  132. * <td>
  133. * #H5FD_LOG_FLAVOR
  134. * </td>
  135. * <td>
  136. * Track the type, or flavor, of information stored at each byte.
  137. * </td>
  138. * </tr>
  139. * <tr>
  140. * <td>
  141. * #H5FD_LOG_NUM_READ
  142. * </td>
  143. * <td rowspan="4">
  144. * Track the total number of read, write, seek, or truncate operations that occur.
  145. * </td>
  146. * </tr>
  147. * <tr><td>#H5FD_LOG_NUM_WRITE</td></tr>
  148. * <tr><td>#H5FD_LOG_NUM_SEEK</td></tr>
  149. * <tr><td>#H5FD_LOG_NUM_TRUNCATE</td></tr>
  150. * <tr>
  151. * <td>
  152. * #H5FD_LOG_NUM_IO
  153. * </td>
  154. * <td>
  155. * Track the total number of all types of I/O operations. The logical equivalent
  156. * of the following:
  157. * \Code{(#H5FD_LOG_NUM_READ | #H5FD_LOG_NUM_WRITE | #H5FD_LOG_NUM_SEEK | #H5FD_LOG_NUM_TRUNCATE)}
  158. * </td>
  159. * </tr>
  160. * <tr>
  161. * <td>
  162. * #H5FD_LOG_TIME_OPEN
  163. * </td>
  164. * <td rowspan="6">
  165. * Track the time spent in open, stat, read, write, seek, or close operations.
  166. * </td>
  167. * </tr>
  168. * <tr><td>#H5FD_LOG_TIME_STAT</td></tr>
  169. * <tr><td>#H5FD_LOG_TIME_READ</td></tr>
  170. * <tr><td>#H5FD_LOG_TIME_WRITE</td></tr>
  171. * <tr><td>#H5FD_LOG_TIME_SEEK</td></tr>
  172. * <tr><td>#H5FD_LOG_TIME_CLOSE</td></tr>
  173. * <tr>
  174. * <td>
  175. * #H5FD_LOG_TIME_IO
  176. * </td>
  177. * <td>
  178. * Track the time spent in each of the above operations. The logical equivalent
  179. * of the following:
  180. * \Code{(#H5FD_LOG_TIME_OPEN | #H5FD_LOG_TIME_STAT | #H5FD_LOG_TIME_READ | #H5FD_LOG_TIME_WRITE |
  181. * #H5FD_LOG_TIME_SEEK | #H5FD_LOG_TIME_CLOSE)}
  182. * </td>
  183. * </tr>
  184. * <tr>
  185. * <td>
  186. * #H5FD_LOG_ALLOC
  187. * </td>
  188. * <td>
  189. * Track the allocation of space in the file.
  190. * </td>
  191. * </tr>
  192. * <tr>
  193. * <td>
  194. * #H5FD_LOG_ALL
  195. * </td>
  196. * <td>
  197. * Track everything. The logical equivalent of the following:
  198. * \Code{(#H5FD_LOG_ALLOC | #H5FD_LOG_TIME_IO | #H5FD_LOG_NUM_IO | #H5FD_LOG_FLAVOR | #H5FD_LOG_FILE_IO |
  199. * #H5FD_LOG_LOC_IO)}
  200. * </td>
  201. * </tr>
  202. * </table>
  203. * The logging driver can track the number of times each byte in the file is
  204. * read from or written to (using #H5FD_LOG_FILE_READ and #H5FD_LOG_FILE_WRITE)
  205. * and what kind of data is at that location (e.g., metadata, raw data; using
  206. * #H5FD_LOG_FLAVOR). This information is tracked in internal buffers of size
  207. * buf_size, which must be at least the maximum size in bytes of the file to be
  208. * logged while the log driver is in use.\n
  209. * One buffer of size buf_size will be created for each of #H5FD_LOG_FILE_READ,
  210. * #H5FD_LOG_FILE_WRITE and #H5FD_LOG_FLAVOR when those flags are set; these
  211. * buffers will not grow as the file increases in size.
  212. *
  213. * \par Output:
  214. * This section describes the logging driver (LOG VFD) output.\n
  215. * The table, immediately below, describes output of the various logging driver
  216. * flags and function calls. A list of valid flavor values, describing the type
  217. * of data stored, follows the table.
  218. * <table>
  219. * <caption>Table2: Logging Output</caption>
  220. * <tr>
  221. * <th>Flag</th><th>VFD Call</th><th>Output and Comments</th>
  222. * </th>
  223. * </tr>
  224. * <tr>
  225. * <td>#H5FD_LOG_LOC_READ</td>
  226. * <td>Read</td>
  227. * <td>
  228. * \Code{%10a-%10a (%10Zu bytes) (%s) Read}\n\n
  229. * Start position\n
  230. * End position\n
  231. * Number of bytes\n
  232. * Flavor of read\n\n
  233. * Adds \Code{(\%f s)} and seek time if #H5FD_LOG_TIME_SEEK is also set.
  234. * </td>
  235. * </tr>
  236. * <tr>
  237. * <td>#H5FD_LOG_LOC_READ</td>
  238. * <td>Read Error</td>
  239. * <td>
  240. * \Code{Error! Reading: %10a-%10a (%10Zu bytes)}\n\n
  241. * Same parameters as non-error entry.
  242. * </td>
  243. * </tr>
  244. * <tr>
  245. * <td>#H5FD_LOG_LOC_WRITE</td>
  246. * <td>Write</td>
  247. * <td>
  248. * \Code{%10a-%10a (%10Zu bytes) (%s) Written}\n\n
  249. * Start position\n
  250. * End position\n
  251. * Number of bytes\n
  252. * Flavor of write\n\n
  253. * Adds \Code{(\%f s)} and seek time if #H5FD_LOG_TIME_SEEK is also set.
  254. * </td>
  255. * </tr>
  256. * <tr>
  257. * <td>#H5FD_LOG_LOC_WRITE</td>
  258. * <td>Write Error</td>
  259. * <td>
  260. * \Code{Error! Writing: %10a-%10a (%10Zu bytes)}\n\n
  261. * Same parameters as non-error entry.
  262. * </td>
  263. * </tr>
  264. * <tr>
  265. * <td>#H5FD_LOG_LOC_SEEK</td>
  266. * <td>Read, Write</td>
  267. * <td>
  268. * \Code{Seek: From %10a-%10a}\n\n
  269. * Start position\n
  270. * End position\n\n
  271. * Adds \Code{(\%f s)} and seek time if #H5FD_LOG_TIME_SEEK is also set.
  272. * </td>
  273. * </tr>
  274. * <tr>
  275. * <td>#H5FD_LOG_FILE_READ</td>
  276. * <td>Close</td>
  277. * <td>
  278. * Begins with:\n
  279. * Dumping read I/O information\n\n
  280. * Then, for each range of identical values, there is this line:\n
  281. * \Code{Addr %10-%10 (%10lu bytes) read from %3d times}\n\n
  282. * Start address\n
  283. * End address\n
  284. * Number of bytes\n
  285. * Number of times read\n\n
  286. * Note: The data buffer is scanned and each range of identical values
  287. * gets one entry in the log file to save space and make it easier to read.
  288. * </td>
  289. * </tr>
  290. * <tr>
  291. * <td>#H5FD_LOG_FILE_WRITE</td>
  292. * <td>Close</td>
  293. * <td>
  294. * Begins with:\n
  295. * Dumping read I/O information\n\n
  296. * Then, for each range of identical values, there is this line:\n
  297. * \Code{Addr %10-%10 (%10lu bytes) written to %3d times}\n\n
  298. * Start address\n
  299. * End address\n
  300. * Number of bytes\n
  301. * Number of times written\n\n
  302. * Note: The data buffer is scanned and each range of identical values
  303. * gets one entry in the log file to save space and make it easier to read.
  304. * </td>
  305. * </tr>
  306. * <tr>
  307. * <td>#H5FD_LOG_FLAVOR</td>
  308. * <td>Close</td>
  309. * <td>
  310. * Begins with:\n
  311. * Dumping I/O flavor information\n\n
  312. * Then, for each range of identical values, there is this line:\n
  313. * \Code{Addr %10-%10 (%10lu bytes) flavor is %s}\n\n
  314. * Start address\n
  315. * End address\n
  316. * Number of bytes\n
  317. * Flavor\n\n
  318. * Note: The data buffer is scanned and each range of identical values
  319. * gets one entry in the log file to save space and make it easier to read.
  320. * </td>
  321. * </tr>
  322. * <tr>
  323. * <td>#H5FD_LOG_NUM_READ</td>
  324. * <td>Close</td>
  325. * <td>
  326. * Total number of read operations: \Code{%11u}
  327. * </td>
  328. * </tr>
  329. * <tr>
  330. * <td>#H5FD_LOG_NUM_WRITE</td>
  331. * <td>Close</td>
  332. * <td>
  333. * Total number of write operations: \Code{%11u}
  334. * </td>
  335. * </tr>
  336. * <tr>
  337. * <td>#H5FD_LOG_NUM_SEEK</td>
  338. * <td>Close</td>
  339. * <td>
  340. * Total number of seek operations: \Code{%11u}
  341. * </td>
  342. * </tr>
  343. * <tr>
  344. * <td>#H5FD_LOG_NUM_TRUNCATE</td>
  345. * <td>Close</td>
  346. * <td>
  347. * Total number of truncate operations: \Code{%11u}
  348. * </td>
  349. * </tr>
  350. * <tr>
  351. * <td>#H5FD_LOG_TIME_OPEN</td>
  352. * <td>Open</td>
  353. * <td>
  354. * Open took: \Code{(\%f s)}
  355. * </td>
  356. * </tr>
  357. * <tr>
  358. * <td>#H5FD_LOG_TIME_READ</td>
  359. * <td>Close, Read</td>
  360. * <td>
  361. * Total time in read operations: \Code{\%f s}\n\n
  362. * See also: #H5FD_LOG_LOC_READ
  363. * </td>
  364. * </tr>
  365. * </tr>
  366. * <tr>
  367. * <td>#H5FD_LOG_TIME_WRITE</td>
  368. * <td>Close, Write</td>
  369. * <td>
  370. * Total time in write operations: \Code{\%f s}\n\n
  371. * See also: #H5FD_LOG_LOC_WRITE
  372. * </td>
  373. * </tr>
  374. * <tr>
  375. * <td>#H5FD_LOG_TIME_SEEK</td>
  376. * <td>Close, Read, Write</td>
  377. * <td>
  378. * Total time in write operations: \Code{\%f s}\n\n
  379. * See also: #H5FD_LOG_LOC_SEEK or #H5FD_LOG_LOC_WRITE
  380. * </td>
  381. * </tr>
  382. * <tr>
  383. * <td>#H5FD_LOG_TIME_CLOSE</td>
  384. * <td>Close</td>
  385. * <td>
  386. * Close took: \Code{(\%f s)}
  387. * </td>
  388. * </tr>
  389. * <tr>
  390. * <td>#H5FD_LOG_TIME_STAT</td>
  391. * <td>Open</td>
  392. * <td>
  393. * Stat took: \Code{(\%f s)}
  394. * </td>
  395. * </tr>
  396. * <tr>
  397. * <td>#H5FD_LOG_ALLOC</td>
  398. * <td>Alloc</td>
  399. * <td>
  400. * \Code{%10-%10 (%10Hu bytes) (\%s) Allocated}\n\n
  401. * Start of address space\n
  402. * End of address space\n
  403. * Total size allocation\n
  404. * Flavor of allocation
  405. * </td>
  406. * </tr>
  407. * </table>
  408. *
  409. * \par Flavors:
  410. * The \Emph{flavor} describes the type of stored information. The following
  411. * table lists the flavors that appear in log output and briefly describes each.
  412. * These terms are provided here to aid in the construction of log message
  413. * parsers; a full description is beyond the scope of this document.
  414. * <table>
  415. * <caption>Table3: Flavors of logged data</caption>
  416. * <tr>
  417. * <th>Flavor</th><th>Description</th>
  418. * </th>
  419. * </tr>
  420. * <tr>
  421. * <td>#H5FD_MEM_NOLIST</td>
  422. * <td>Error value</td>
  423. * </tr>
  424. * <tr>
  425. * <td>#H5FD_MEM_DEFAULT</td>
  426. * <td>Value not yet set.\n
  427. * May also be a datatype set in a larger allocation that will be
  428. * suballocated by the library.</td>
  429. * </tr>
  430. * <tr>
  431. * <td>#H5FD_MEM_SUPER</td>
  432. * <td>Superblock data</td>
  433. * </tr>
  434. * <tr>
  435. * <td>#H5FD_MEM_BTREE</td>
  436. * <td>B-tree data</td>
  437. * </tr>
  438. * <tr>
  439. * <td>#H5FD_MEM_DRAW</td>
  440. * <td>Raw data (for example, contents of a dataset)</td>
  441. * </tr>
  442. * <tr>
  443. * <td>#H5FD_MEM_GHEAP</td>
  444. * <td>Global heap data</td>
  445. * </tr>
  446. * <tr>
  447. * <td>#H5FD_MEM_LHEAP</td>
  448. * <td>Local heap data</td>
  449. * </tr>
  450. * <tr>
  451. * <td>#H5FD_MEM_OHDR</td>
  452. * <td>Object header data</td>
  453. * </tr>
  454. * </table>
  455. *
  456. * \version 1.8.7 The flags parameter has been changed from \Code{unsigned int}
  457. * to \Code{unsigned long long}.
  458. * The implementation of the #H5FD_LOG_TIME_OPEN, #H5FD_LOG_TIME_READ,
  459. * #H5FD_LOG_TIME_WRITE, and #H5FD_LOG_TIME_SEEK flags has been finished.
  460. * New flags were added: #H5FD_LOG_NUM_TRUNCATE and #H5FD_LOG_TIME_STAT.
  461. * \version 1.6.0 The \c verbosity parameter has been removed.
  462. * Two new parameters have been added: \p flags of type \Code{unsigned} and
  463. * \p buf_size of type \Code{size_t}.
  464. * \since 1.4.0
  465. *
  466. */
  467. H5_DLL herr_t H5Pset_fapl_log(hid_t fapl_id, const char *logfile, unsigned long long flags, size_t buf_size);
  468. #ifdef __cplusplus
  469. }
  470. #endif
  471. #endif