PDA

View Full Version : Really slow reads with BBA



showka
November 4th, 2006, 20:05
Hi guys. I got the Ethernet cable awhile back and am using it on this cross platform project I'm working on (Windows and Dreamcast). Well, I've been neglecting the Dreamcast side of things for a long while, and discovered recently when ever I ran my project the reads from the BBA took a long time compared to how fast I remembered them.

I'm doing file reads using a platform specific implementation of a file reader class.



#ifdef COMPILE_TARGET_DREAMCAST

#include <kos.h>
#include <kos/fs.h>

/*
extern uint8 romdisk[];
KOS_INIT_ROMDISK(romdisk);
*/

char data[920000];

KOS_INIT_FLAGS(INIT_DEFAULT | INIT_MALLOCSTATS);
int main(int argc, char **argv)
{
printf("I am alive.!\n");

pvr_init_params_t params = {
// Enable opaque and translucent polygons with size 16
{ PVR_BINSIZE_16, PVR_BINSIZE_0, PVR_BINSIZE_16, PVR_BINSIZE_0, PVR_BINSIZE_16 },
//{ PVR_BINSIZE_16, PVR_BINSIZE_0, PVR_BINSIZE_0, PVR_BINSIZE_0, PVR_BINSIZE_0 },
// Vertex buffer size 512K
512*1024
};

// Initializes KOS
pvr_init(&params);

fs_chdir("/pc/cygdrive/c/LP3/DevCpp/DcOnly/DcIoTest");

FILE * fp;
fp = fopen("starfield.bmp", "rb");
if (fp == NULL)
{
printf("File not found");
return 1;
}
int byteLength = 1000;
int bytesRead = 0;
int fileSize = 900000;
int gcount = 0;

uint32 secs, msecs;
timer_ms_gettime(&secs, &msecs);
printf("START TIME %d.%d\n", secs, msecs);
for (bytesRead = 0; bytesRead < fileSize; bytesRead += gcount)
{
gcount = fread(data, 1, byteLength, fp);
}
timer_ms_gettime(&secs, &msecs);
printf("END TIME %d.%d\n", secs, msecs);
fclose(fp);

return 1;
}

#endif



Tests/starfield.bmp is a 640 x 480 24 bit bitmap thats just under a megabyte (921 kb).

Here is the output I see:



Interface: 192.168.10.2 --- 0x2
Internet Address Physical Address Type
192.168.10.1 00-0c-e5-48-f3-6d dynamic

Interface: 192.168.2.5 --- 0x10004
Internet Address Physical Address Type
192.168.2.4 00-d0-f1-02-9a-f3 static

C:\LP3\Dreamcast\DcTool\dctool-ip_1.0.3\dc-tool.exeC:\LP3\DevCpp\DcOnly\DcIoTest
\DcIoTest.elf
Console enabled
Upload <C:\LP3\DevCpp\DcOnly\DcIoTest\DcIoTest.elf>
File format is elf32-shl, start address is 0x8c010140
Section .text, lma 0x8c010000, size 264928
Section .rodata, lma 0x8c050ae0, size 33835
Section .data, lma 0x8c058fa0, size 11244
Section .eh_frame, lma 0x8c05bb8c, size 2992
Section .gcc_except_table, lma 0x8c05c73c, size 268
Section .ctors, lma 0x8c05c848, size 8
Section .dtors, lma 0x8c05c850, size 8
Section .stack, lma 0x30000, size 4
transferred at 517829.752082 bytes / sec
Executing at <0x8c010140>
Sending execute command (0x8c010140, console=1, cdfsredir=0)...executing

--
KallistiOS ##version##: Wed Dec 7 00:19:35 PST 2005
Cyle@cyle-411fb01f29:/usr/local/dc/kos/kos
thd: pre-emption enabled, HZ=100
maple: active drivers:
Dreameye (Camera): Camera
Sound Input Peripheral: Microphone
PuruPuru (Vibration) Pack: JumpPack
VMU Driver: Clock, LCD, MemoryCard
Mouse Driver: Mouse
Keyboard Driver: Keyboard
Controller Driver: Controller
DMA Buffer at ac173e20
vid_set_mode: 640x480 NTSC
dc-load console support enabled
maple: attached devices:
A0: Dreamcast Controller (01000000: Controller)
A1: Visual Memory (0e000000: Clock, LCD, MemoryCard)
B0: Dreamcast Controller (01000000: Controller)
I am alive.!
pvr: disabling vertical scaling for VGA
START TIME 1.130
END TIME 23.52
arch: shutting down kernel
maple: final stats -- device count = 3, vbl_cntr = 895, dma_cntr = 449
vid_set_mode: 640x480 NTSC
max system bytes = 149128
system bytes = 149128
in use bytes = 6200
KM_DBG: Still-allocated memory blocks:
INUSE 8c18e2f8: size 380, thread 1, addr 8c050a0c, type malloc
INUSE 8c18d450: size 1024, thread 1, addr 8c050a0c, type malloc
INUSE 8c172cb8: size 2, thread 1, addr 8c050a0c, type malloc
INUSE 8c172620: size 12, thread 1, addr 8c017a02, type malloc
INUSE 8c1723f8: size 12, thread 1, addr 8c02faac, type malloc
INUSE 8c170628: size 12, thread 1, addr 8c022e36, type malloc
INUSE 8c170020: size 1024, thread 1, addr 8c050a0c, type malloc

Program finished. Press enter to quit.


This code takes about 22 seconds to execute. I tried setting byteLength to ridiculous levels just to see if maybe its becasue the reads weren't being buffered but its just as slow.

I honesly remember this being much faster. It seems like the GD-Rom would be faster than this, and the ethernet port should stream things from a willing PC even faster than the GD-Rom can read them.

A part of me thinks I've messed up the ethernet settings on my computer somehow to make it go this slow. I'm not sure how, though.

Also want to point out that a 632 KB elf file loads almost instantaneously.

Any suggestions?