mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-23 14:03:07 +01:00
Archeology.
This commit is contained in:
parent
10d5b95fe4
commit
5667d54b84
@ -21,15 +21,17 @@
|
||||
* Contributor(s): ______________________________________.
|
||||
*/
|
||||
|
||||
#include "firebird.h"
|
||||
#include "../jrd/common.h"
|
||||
|
||||
#ifdef VMS
|
||||
#include "firebird.h"
|
||||
#include <types.h>
|
||||
#include "times.h"
|
||||
#else
|
||||
#ifdef HAVE_TIMES
|
||||
#include <sys/types.h>
|
||||
#include <sys/times.h>
|
||||
#endif
|
||||
#if TIME_WITH_SYS_TIME
|
||||
# include <sys/time.h>
|
||||
# include <time.h>
|
||||
@ -42,18 +44,31 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef WIN_NT
|
||||
#include <io.h> // open, close
|
||||
#endif
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include "jrd.h"
|
||||
#include "ods.h"
|
||||
#include "../jrd/jrd.h"
|
||||
#include "../jrd/ods.h"
|
||||
#include "../jrd/perf.h"
|
||||
|
||||
#ifndef HAVE_TIMES
|
||||
static time_t times(struct tms*);
|
||||
#endif
|
||||
|
||||
|
||||
using namespace Ods;
|
||||
|
||||
static void analyse(int, const SCHAR*, const pag*, int);
|
||||
static SLONG get_long(void);
|
||||
#ifdef VMS
|
||||
//#ifdef VMS
|
||||
static void db_error(int);
|
||||
static void db_open(const UCHAR*, USHORT);
|
||||
static void db_open(const char*, USHORT);
|
||||
static PAG db_read(SLONG);
|
||||
#endif
|
||||
//#endif
|
||||
|
||||
static FILE *trace;
|
||||
static int file;
|
||||
@ -68,9 +83,9 @@ const SSHORT trace_write = 5;
|
||||
const SSHORT trace_close = 6;
|
||||
|
||||
static USHORT page_size;
|
||||
static int map_length, map_base, map_count;
|
||||
static PAG global_buffer;
|
||||
static UCHAR *map_region;
|
||||
//static int map_length, map_base, map_count;
|
||||
static pag* global_buffer;
|
||||
//static UCHAR *map_region;
|
||||
|
||||
const int MAX_PAGES = 50000;
|
||||
|
||||
@ -89,42 +104,46 @@ void main( int argc, char **argv)
|
||||
* Replay all I/O to compute overhead of I/O system.
|
||||
*
|
||||
**************************************/
|
||||
SLONG reads, writes, n, length;
|
||||
SCHAR string[128], *p;
|
||||
struct tms after, before;
|
||||
SLONG n;
|
||||
SCHAR string[128] = "";
|
||||
|
||||
bool detail = true;
|
||||
|
||||
char** end;
|
||||
for (end = argv + argc, ++argv; argv < end; argv++) {
|
||||
p = *argv;
|
||||
if (*p++ == '-')
|
||||
switch (UPPER(*p)) {
|
||||
for (end = argv + argc, ++argv; argv < end; argv++)
|
||||
{
|
||||
const char* s = *argv;
|
||||
if (*s++ == '-')
|
||||
switch (UPPER(*s)) {
|
||||
case 'S':
|
||||
detail = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
reads = writes = 0;
|
||||
SLONG reads = 0, writes = 0;
|
||||
trace = fopen("trace.log", "r");
|
||||
page_size = 1024;
|
||||
SLONG sequence = 0;
|
||||
|
||||
SLONG elapsed = times(&before);
|
||||
struct tms before;
|
||||
time_t elapsed = times(&before);
|
||||
|
||||
const pag* page;
|
||||
SSHORT event;
|
||||
while ((event = getc(trace)) != trace_close && event != EOF)
|
||||
switch (event) {
|
||||
switch (event)
|
||||
{
|
||||
case trace_open:
|
||||
n = length = getc(trace);
|
||||
p = string;
|
||||
while (--n >= 0)
|
||||
*p++ = getc(trace);
|
||||
*p = 0;
|
||||
db_open(string, length);
|
||||
{
|
||||
const SLONG length = getc(trace);
|
||||
n = length;
|
||||
SCHAR* p = string;
|
||||
while (--n >= 0)
|
||||
*p++ = getc(trace);
|
||||
*p = 0;
|
||||
db_open(string, length);
|
||||
}
|
||||
break;
|
||||
|
||||
case trace_page_size:
|
||||
@ -135,7 +154,9 @@ void main( int argc, char **argv)
|
||||
|
||||
case trace_read:
|
||||
n = get_long();
|
||||
++read_counts[n];
|
||||
if (n < MAX_PAGES)
|
||||
++read_counts[n];
|
||||
|
||||
if (detail && (page = db_read(n)))
|
||||
analyse(n, "Read", page, ++sequence);
|
||||
reads++;
|
||||
@ -143,7 +164,9 @@ void main( int argc, char **argv)
|
||||
|
||||
case trace_write:
|
||||
n = get_long();
|
||||
++write_counts[n];
|
||||
if (n < MAX_PAGES)
|
||||
++write_counts[n];
|
||||
|
||||
if (detail && (page = db_read(n)))
|
||||
analyse(n, "Write", page, ++sequence);
|
||||
writes++;
|
||||
@ -154,6 +177,7 @@ void main( int argc, char **argv)
|
||||
abort();
|
||||
}
|
||||
|
||||
struct tms after;
|
||||
elapsed = times(&after) - elapsed;
|
||||
const SLONG cpu = after.tms_utime - before.tms_utime;
|
||||
const SLONG system = after.tms_stime - before.tms_stime;
|
||||
@ -212,12 +236,12 @@ static void analyse( int number, const SCHAR* string, const pag* page, int seque
|
||||
|
||||
case pag_pointer:
|
||||
printf("Pointer page, relation %d, sequence %d\n",
|
||||
((PPG) page)->ppg_relation, ((PPG) page)->ppg_sequence);
|
||||
((pointer_page*) page)->ppg_relation, ((pointer_page*) page)->ppg_sequence);
|
||||
break;
|
||||
|
||||
case pag_data:
|
||||
printf("Data page, relation %d, sequence %d\n",
|
||||
((DPG) page)->dpg_relation, ((DPG) page)->dpg_sequence);
|
||||
((data_page*) page)->dpg_relation, ((data_page*) page)->dpg_sequence);
|
||||
break;
|
||||
|
||||
case pag_root:
|
||||
@ -227,15 +251,15 @@ static void analyse( int number, const SCHAR* string, const pag* page, int seque
|
||||
|
||||
case pag_index:
|
||||
printf("B-Tree page, relation %d, index %d, level %d\n",
|
||||
((BTR) page)->btr_relation, ((BTR) page)->btr_id,
|
||||
((BTR) page)->btr_level);
|
||||
((btree_page*) page)->btr_relation, ((btree_page*) page)->btr_id,
|
||||
((btree_page*) page)->btr_level);
|
||||
break;
|
||||
|
||||
case pag_blob:
|
||||
printf
|
||||
("Blob page\n\tFlags: %x, lead page: %d, sequence: %d, length: %d\n\t",
|
||||
page->pag_flags, ((BLP) page)->blp_lead_page,
|
||||
((BLP) page)->blp_sequence, ((BLP) page)->blp_length);
|
||||
page->pag_flags, ((blob_page*) page)->blp_lead_page,
|
||||
((blob_page*) page)->blp_sequence, ((blob_page*) page)->blp_length);
|
||||
|
||||
break;
|
||||
|
||||
@ -262,24 +286,25 @@ static SLONG get_long(void)
|
||||
SSHORT i;
|
||||
SCHAR c;
|
||||
} value;
|
||||
SLONG i, x;
|
||||
|
||||
SCHAR* p = (SCHAR *) & value.l;
|
||||
x = i = getc(trace);
|
||||
SLONG i = getc(trace);
|
||||
const SLONG x = i;
|
||||
|
||||
while (--i >= 0)
|
||||
*p++ = getc(trace);
|
||||
|
||||
if (x == 1)
|
||||
return value.c;
|
||||
else if (x == 2)
|
||||
|
||||
if (x == 2)
|
||||
return value.i;
|
||||
else
|
||||
return value.l;
|
||||
|
||||
return value.l;
|
||||
}
|
||||
|
||||
|
||||
#ifdef VMS
|
||||
//#ifdef VMS
|
||||
static void db_error( int status)
|
||||
{
|
||||
/**************************************
|
||||
@ -297,7 +322,7 @@ static void db_error( int status)
|
||||
}
|
||||
|
||||
|
||||
static void db_open( const UCHAR* file_name, USHORT file_length)
|
||||
static void db_open( const char* file_name, USHORT file_length)
|
||||
{
|
||||
/**************************************
|
||||
*
|
||||
@ -331,7 +356,7 @@ static PAG db_read( SLONG page_number)
|
||||
UINT64 offset = ((UINT64)page_number) * ((UINT64)page_size);
|
||||
|
||||
if (!global_buffer)
|
||||
global_buffer = malloc(page_size);
|
||||
global_buffer = (pag*) malloc(page_size);
|
||||
|
||||
if (lseek (file, offset, 0) == -1)
|
||||
db_error(errno);
|
||||
@ -341,5 +366,25 @@ static PAG db_read( SLONG page_number)
|
||||
|
||||
return global_buffer;
|
||||
}
|
||||
//#endif
|
||||
|
||||
|
||||
#ifndef HAVE_TIMES
|
||||
static time_t times(struct tms* buffer)
|
||||
{
|
||||
/**************************************
|
||||
*
|
||||
* t i m e s
|
||||
*
|
||||
**************************************
|
||||
*
|
||||
* Functional description
|
||||
* Emulate the good old unix call "times". Only both with user time.
|
||||
*
|
||||
**************************************/
|
||||
|
||||
buffer->tms_utime = clock();
|
||||
return buffer->tms_utime;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user