mirror of
https://github.com/HDFGroup/hdf5.git
synced 2025-02-17 16:10:24 +08:00
[svn-r117] Added "seek position caching" code to shared file-records, which trimmed 20%
off the run-time for the current tests. (4.77s down to 3.89s)
This commit is contained in:
parent
2721bb4758
commit
cdb316b7e0
30
src/H5F.c
30
src/H5F.c
@ -1295,14 +1295,20 @@ H5F_block_read (H5F_t *f, haddr_t addr, size_t size, void *buf)
|
||||
if (0==size) return 0;
|
||||
addr += f->shared->file_create_parms.userblock_size;
|
||||
|
||||
if (H5F_SEEK (f->shared->file_handle, addr)<0) {
|
||||
/* low-level seek failure */
|
||||
HRETURN_ERROR (H5E_IO, H5E_SEEKERROR, FAIL);
|
||||
}
|
||||
/* Check for switching file access operations or mis-placed seek offset */
|
||||
if(f->shared->last_op!=OP_READ || f->shared->f_cur_off!=addr)
|
||||
{
|
||||
f->shared->last_op=OP_READ;
|
||||
if (H5F_SEEK (f->shared->file_handle, addr)<0) {
|
||||
/* low-level seek failure */
|
||||
HRETURN_ERROR (H5E_IO, H5E_SEEKERROR, FAIL);
|
||||
} /* end if */
|
||||
} /* end if */
|
||||
if (H5F_READ (f->shared->file_handle, buf, size)<0) {
|
||||
/* low-level read failure */
|
||||
HRETURN_ERROR (H5E_IO, H5E_READERROR, FAIL);
|
||||
}
|
||||
f->shared->f_cur_off=addr+size;
|
||||
|
||||
FUNC_LEAVE (SUCCEED);
|
||||
}
|
||||
@ -1343,14 +1349,22 @@ H5F_block_write (H5F_t *f, haddr_t addr, size_t size, void *buf)
|
||||
/* no write intent */
|
||||
HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL);
|
||||
}
|
||||
if (H5F_SEEK (f->shared->file_handle, addr)<0) {
|
||||
/* low-level seek failure */
|
||||
HRETURN_ERROR (H5E_IO, H5E_SEEKERROR, FAIL);
|
||||
}
|
||||
|
||||
/* Check for switching file access operations or mis-placed seek offset */
|
||||
if(f->shared->last_op!=OP_WRITE || f->shared->f_cur_off!=addr)
|
||||
{
|
||||
f->shared->last_op=OP_WRITE;
|
||||
if (H5F_SEEK (f->shared->file_handle, addr)<0) {
|
||||
/* low-level seek failure */
|
||||
HRETURN_ERROR (H5E_IO, H5E_SEEKERROR, FAIL);
|
||||
}
|
||||
} /* end if */
|
||||
|
||||
if (H5F_WRITE (f->shared->file_handle, buf, size)<0) {
|
||||
/* low-level write failure */
|
||||
HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL);
|
||||
}
|
||||
f->shared->f_cur_off=addr+size;
|
||||
|
||||
FUNC_LEAVE (SUCCEED);
|
||||
}
|
||||
|
@ -351,11 +351,25 @@ typedef struct H5F_search_t {
|
||||
ino_t ino; /* Unique file number on device */
|
||||
} H5F_search_t;
|
||||
|
||||
/* For determining what the last file operation was */
|
||||
typedef enum
|
||||
{
|
||||
OP_UNKNOWN = 0, /* Don't know what the last operation was (after fopen frex) */
|
||||
OP_SEEK, /* Last operation was a seek */
|
||||
OP_WRITE, /* Last operation was a write */
|
||||
OP_READ /* Last operation was a read */
|
||||
}
|
||||
H5F_fileop_t;
|
||||
|
||||
/*
|
||||
* Define the structure to store the file information for HDF5 files. One of
|
||||
* these structures is allocated per file, not per H5Fopen().
|
||||
*/
|
||||
typedef struct H5F_file_t {
|
||||
/* Seek caching info */
|
||||
haddr_t f_cur_off; /* Current location in the file */
|
||||
H5F_fileop_t last_op; /* the last file operation performed */
|
||||
|
||||
H5F_search_t key; /* The key for looking up files */
|
||||
uintn flags; /* Access Permissions for file */
|
||||
hdf_file_t file_handle; /* File handle for actual I/O */
|
||||
|
Loading…
Reference in New Issue
Block a user