News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Dynamic string array benchmark

Started by hutch--, April 06, 2008, 09:04:42 AM

Previous topic - Next topic

hutch--

Mark,

I tried manually setting the memory size in the OLE string call in arrset$ and tried multiple algos but they were not faster than placing the address directly into the OLE string call so I left it at its default in the OLE library that uses REP MOVSD internally. Apart from the OLE call there is little to improve in the arrset$ algo. I used the DWORD string length algo to set the allocation size for the OLE string but there is no reasonable way to make the API any faster that I know of.

This is the algo I changed in the alloc routine, I had forgotten to correct the array count for its 1 based index and it went BANG with small counts.


; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

    align 16

arralloc proc mcnt:DWORD

  ; ----------------------------------------------------------------
  ; return values = handle of pointer array or 0 on allocation error
  ; ----------------------------------------------------------------
    push esi

    mov eax, mcnt                               ; load the member count into EAX
    add eax, 1                                  ; correct for 1 based array
    lea eax, [0+eax*4]                          ; multiply it by 4 for memory size

    invoke GlobalAlloc,GMEM_FIXED,eax
    mov esi, eax

    test eax, eax                               ; if allocation failure return zero
    jz quit

    mov eax, esi
    mov ecx, mcnt
    mov DWORD PTR [eax], ecx                    ; write count to 1st member

    xor edx, edx
  @@:
    add edx, 1                                  ; write adress of null string to all members
    mov [eax+edx*4], OFFSET d_e_f_a_u_l_t__n_u_l_l_$
    cmp edx, ecx
    jle @B

    mov eax, esi                                ; return pointer array handle

  quit:
    pop esi

    ret

arralloc endp

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Mark_Larson

I pre-allocated 8 bytes per array element in arralloc.  The code is running a lot faster.  266-281 cycles for arrset.  I need to add more code like support for re-allocating more memory when it runs out of buffer size.  Or I might just allocate a second buffer, depending on how slow re-alloc is.

Mark

EDIT: hutch thanks for cutting and pasting the arralloc routine in the forum :)

EDIT2: my new timings, both arrset and arrfree are considerably faster.

0 ms array create
282 ms array load data
15 ms array read
0 ms array delete

EDIT3: I got rid of HeapAlloc.  I am exclusively using GlobalAlloc

EDIT4: attaching the executable.

[attachment deleted by admin]
BIOS programmers do it fastest, hehe.  ;)

My Optimization webpage
htttp://www.website.masmforum.com/mark/index.htm

Mark Jones

Oooh, Athlons really like your modifications Mark. :wink

Athlon dual-core x64 4000+ (WinXP x32)
5 million element test

47 ms array create
344 ms array load data
31 ms array read
16 ms array delete
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

hutch--

Mark,

These numbers are looking good. This is on my antique Northwood PIV.


5 million element test

16 ms array create
500 ms array load data
31 ms array read
0 ms array delete


Tolerate me at the moment, I am trying to track down minor bits and pieces in the version 10 of the masm32 SDK and I don't have much brain left at the moment. Just finished 6 weeks of writing a new editor, finishing off a new script engine, gutted and rebuilt the old sript engine for backwards copatibility, rebuilt 3 DLLs yesterday for the project, wrote a couple of others and i am writig web pages at the moment running on auto-pilate.  :bg
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Mark_Larson

Quote from: hutch-- on August 12, 2008, 03:08:42 PM
Mark,

These numbers are looking good. This is on my antique Northwood PIV.


5 million element test

16 ms array create
500 ms array load data
31 ms array read
0 ms array delete


Tolerate me at the moment, I am trying to track down minor bits and pieces in the version 10 of the masm32 SDK and I don't have much brain left at the moment. Just finished 6 weeks of writing a new editor, finishing off a new script engine, gutted and rebuilt the old sript engine for backwards copatibility, rebuilt 3 DLLs yesterday for the project, wrote a couple of others and i am writig web pages at the moment running on auto-pilate.  :bg

no worries  :bg  I'd recommend going to sleep, but I wouldn't do it either if our positions were reversed :bg

I am actually removing the prologue/epilogue code, since it gets called 5 million times.  Assuming that that adds 2 cycles ( roughly) that saves 10,000,000 cycles, which will also speed it up.  I haven't finished that version yet.  So you can always wait.
BIOS programmers do it fastest, hehe.  ;)

My Optimization webpage
htttp://www.website.masmforum.com/mark/index.htm

Mark_Larson


  I installed 64-bit Ubuntu on my computer and it ate my Windows XP.  So I am currently running from Linux only.  I can't even access the partition.  *kicks ubuntu*

Can some people please run the code that I posted and tell me what numbers they get?

  It's going to take me a few days to get back up to speed.  I can run the program in Wine, but it won't run at full speed.  I can use MASM with Wine.  So I have no way of testing it.  I do have a copy of Windows XP.  But I need to do some stuff in Linux first before I can restore XP. 
BIOS programmers do it fastest, hehe.  ;)

My Optimization webpage
htttp://www.website.masmforum.com/mark/index.htm

jj2007

Quote from: Mark_Larson on August 13, 2008, 08:42:42 PM
  I installed 64-bit Ubuntu on my computer and it ate my Windows XP.

Boa constrictor eats elephant? Bon appetit!  :bg

Mark_Larson

 I got Masm32 10.0 installed under Linux.  I am going to be testing it shortly.

EDIT:

the library correctly compiles.  I can get code to compile if it doesn't have XMM.  It may be because I am using ml 6.14 now instead of 6.15.  I need to check the code and make sure that is the problem.

EDIT2: you can do this under wine

wine cmd.exe and it'll give you a DOS shell to do your normal dos commands.

BIOS programmers do it fastest, hehe.  ;)

My Optimization webpage
htttp://www.website.masmforum.com/mark/index.htm