2006-01-23 21:05:09 +01:00
|
|
|
#ifndef VFS_OPTIMIZER_H__
|
|
|
|
#define VFS_OPTIMIZER_H__
|
|
|
|
|
|
|
|
extern void trace_enable(bool want_enabled);
|
2006-01-28 23:19:42 +01:00
|
|
|
extern void trace_shutdown();
|
2006-01-23 21:05:09 +01:00
|
|
|
|
2006-02-02 05:11:07 +01:00
|
|
|
extern void trace_notify_load(const char* P_fn, size_t size, uint flags);
|
|
|
|
extern void trace_notify_free(const char* P_fn, size_t size);
|
2006-01-23 21:05:09 +01:00
|
|
|
|
2006-01-28 23:19:42 +01:00
|
|
|
// TraceEntry operation type.
|
|
|
|
// note: rather than only a list of accessed files, we also need to
|
|
|
|
// know the application's behavior WRT caching (e.g. when it releases
|
|
|
|
// cached buffers). this is necessary so that our simulation can
|
|
|
|
// yield the same results.
|
|
|
|
enum TraceOp
|
|
|
|
{
|
|
|
|
TO_LOAD,
|
|
|
|
TO_FREE
|
|
|
|
};
|
|
|
|
|
|
|
|
// stores one event that is relevant for file IO / caching.
|
|
|
|
//
|
|
|
|
// size-optimized a bit since these are all kept in memory
|
|
|
|
// (to prevent trace file writes from affecting other IOs)
|
2006-01-23 21:05:09 +01:00
|
|
|
struct TraceEntry
|
|
|
|
{
|
2006-02-02 05:11:07 +01:00
|
|
|
// note: float instead of double for nice 16 byte struct size
|
|
|
|
float timestamp; // returned by get_time before operation starts
|
2006-01-28 23:19:42 +01:00
|
|
|
const char* atom_fn; // path+name of affected file
|
2006-02-02 05:11:07 +01:00
|
|
|
// rationale: store size in the trace because other applications
|
|
|
|
// that use this trace format but not our IO code wouldn't know
|
|
|
|
// size (since they cannot retrieve the file info given atom_fn).
|
|
|
|
size_t size; // of IO (usually the entire file)
|
2006-01-28 23:19:42 +01:00
|
|
|
uint op : 8; // operation - see TraceOp
|
|
|
|
uint flags : 24; // misc, e.g. file_io flags.
|
2006-01-23 21:05:09 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
struct Trace
|
|
|
|
{
|
|
|
|
const TraceEntry* ents;
|
2006-01-28 23:19:42 +01:00
|
|
|
size_t num_ents;
|
2006-01-23 21:05:09 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
extern void trace_get(Trace* t);
|
2006-01-28 23:19:42 +01:00
|
|
|
extern LibError trace_write_to_file(const char* trace_filename);
|
|
|
|
extern LibError trace_read_from_file(const char* trace_filename, Trace* t);
|
2006-01-23 21:05:09 +01:00
|
|
|
|
2006-02-23 08:55:32 +01:00
|
|
|
extern LibError vfs_opt_rebuild_main_archive(const char* P_archive_path, const char* trace_filename);
|
|
|
|
|
2006-03-01 23:31:11 +01:00
|
|
|
extern void vfs_opt_cancel();
|
|
|
|
|
|
|
|
extern int vfs_opt_auto_build(const char* P_dst_path,
|
|
|
|
const char* main_archive_name_fmt, const char* trace_filename);
|
2006-02-09 06:59:33 +01:00
|
|
|
|
|
|
|
extern void vfs_opt_notify_loose_file(const char* atom_fn);
|
2006-03-01 23:31:11 +01:00
|
|
|
extern void vfs_opt_notify_non_loose_file(const char* atom_fn);
|
2006-01-31 04:47:52 +01:00
|
|
|
|
2006-01-23 21:05:09 +01:00
|
|
|
#endif // #ifndef VFS_OPTIMIZER_H__
|