Recent

Author Topic: Still hitting head against wall  (Read 18194 times)

eny

  • Hero Member
  • *****
  • Posts: 1634
Re: Still hitting head against wall
« Reply #15 on: July 02, 2012, 04:50:47 pm »
Nah dont work like that.

wish it did. here's pseudocode of what needs to be done.
What step of the process takes so long?
And what is done in this 3msec?

You could work with in memory hash tables.

it's not the size of the database it's thenumber of transactions. try hitting sqlite with 3 GB of transactions and see what happens  ;D
There are few relational databases that run 3Gig transactions in less than 3 msecs ;) so in your case indeed that might not be the solution.

[update on hashlist]
Quick test on XP: 3M hash entries.
2M lookups take a little less than 1 second.
« Last Edit: July 02, 2012, 05:10:52 pm by eny »
All posts based on: Win10 (Win64); Lazarus 2.0.10 'stable' (x64) unless specified otherwise...

liewald

  • Full Member
  • ***
  • Posts: 142
Re: Still hitting head against wall
« Reply #16 on: July 02, 2012, 05:17:30 pm »
the full process of read lookup and write used to take 3msec. it's the lookups that are killing it now because indexes cannot be established all calls to lookup are linear searches. kills the performance.


ludob

  • Hero Member
  • *****
  • Posts: 1173
Re: Still hitting head against wall
« Reply #17 on: July 02, 2012, 05:23:20 pm »
Have you tried using hash lists or any other specialised list?
I have written a double sorted string list which is a good compromise between insert speed and lookup speed. A small test program shows that such a list populated with 500000 different random string values (2-17 characters) will do 100000 lookups per second on a not so fast laptop. Loading the list with 500000 unique values from an array of 1 million random values takes 9 seconds. This includes the test to see if the value was already in the list before storing it.
Let me know if you are interested in this unit.

liewald

  • Full Member
  • ***
  • Posts: 142
Re: Still hitting head against wall
« Reply #18 on: July 02, 2012, 05:28:12 pm »
worth trying.

eny

  • Hero Member
  • *****
  • Posts: 1634
Re: Still hitting head against wall
« Reply #19 on: July 02, 2012, 05:29:56 pm »
the full process of read lookup and write used to take 3msec. it's the lookups that are killing it now because indexes cannot be established all calls to lookup are linear searches. kills the performance.
OK, clear.
Setting up an in mem db with the approx. 1M records takes a couple of seconds obviously.
But lookups are in the microsecond range.
I can do approx. 40K lookups in a second with SQLite i.e. 0,025 msec per lookup!!

All posts based on: Win10 (Win64); Lazarus 2.0.10 'stable' (x64) unless specified otherwise...

ludob

  • Hero Member
  • *****
  • Posts: 1173
Re: Still hitting head against wall
« Reply #20 on: July 02, 2012, 05:50:38 pm »
Attached is the test program I used.

TDSStringList (unit doublesortedlist) is used much like a TStringList with the difference that all strings are sorted when added. With every string you can associate a pointer that can point to anything: a record, an object, .... TDSStringList destroys all strings when destroyed but you need to provide a RemoveCallback procedure or  RemoveCallbackMethod method if you want TDSStringList to destroy the attached object for you.

TDSStringList.FindEntry (const s: string; var pentry: PDSStringListEntry ): boolean; is used to locate a string. It returns true if the string is found. pentry.value is the string found and pentry. p is the pointer associated with the string. If the string is not found, pentry will point to the string that is just before the string searched. Useful for fuzzy searches.

The string sort order is the normal ansi sort order and can be overridden by setting the CompareCallback property with your own string compare function.


eny

  • Hero Member
  • *****
  • Posts: 1634
Re: Still hitting head against wall
« Reply #21 on: July 02, 2012, 06:00:58 pm »
Or use the out of the box TFPHashList or TFPHashObjectList (in contnrs).
All posts based on: Win10 (Win64); Lazarus 2.0.10 'stable' (x64) unless specified otherwise...

ludob

  • Hero Member
  • *****
  • Posts: 1173
Re: Still hitting head against wall
« Reply #22 on: July 02, 2012, 06:53:34 pm »
Or use the out of the box TFPHashList or TFPHashObjectList (in contnrs).
Modified my little test program to use TFPHashList and it is roughly 10-13 times faster than TDSStringList. So if you just need the lookup feature then TFPHashList is the better choice with more than 1M lookups per second.

avra

  • Hero Member
  • *****
  • Posts: 2514
    • Additional info
Re: Still hitting head against wall
« Reply #23 on: July 03, 2012, 10:11:05 am »
Looks like they found then bug and fixed it in 2.7.1 but just cant get 2.7.1 to work and no 2.6 patch was released.
CodeTyphon v2.70 works out of the box with Lazarus 1.1 and FPC 2.7.1 from 19.6.2012 and SVN 37429 CT.
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

liewald

  • Full Member
  • ***
  • Posts: 142
Re: Still hitting head against wall
« Reply #24 on: July 03, 2012, 10:39:42 am »
Ok I used a TFPStringHashTable to hold the lookup values and populated it using virtually the same routines as the bufdataset.

Process the 21 files and created output file in about  45seconds... WOW

love saving millisecs :D

thanks Ludob for the heads up.

would still like to get the bufdatset working for some other stuff though!



BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: Still hitting head against wall
« Reply #25 on: July 03, 2012, 10:54:21 am »
Quote from: liewald
would still like to get the bufdatset working for some other stuff though!

Hello? Are you receiving me?

BTW, if it works with FPC 2.7, you could ask for a backport to 2.6.1 (if it isn't in the pipeline already), e.g. via raising a bugtracker issue. Marcov would probably do the backporting...

Will insytall a local copy on mysql and tect but not hopefull
I'd also try getting an FPC 2.7.1 version in (much easier if you don't need Lazarus - FPC revision 21757 compiles fine... it's just Lazarus that won't work well... at least in my setup).

Either use fpcup or get it using subversion yourself... fpcup is the easiest way though.

You could use e.g. ludob's and my fpcup tool (see 3rd party announcements for details) to do a parallel installation of FPC trunk+Lazarus in c:\development\ (on Windows) or ~/lazarus and ~/fpc.
Note: you'll have to specify the --fpcurl parameter as fpcup defaults to fixes 2.6/2.6.1; see fpcup --help for details.
Works on Linux and Windows.
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

liewald

  • Full Member
  • ***
  • Posts: 142
Re: Still hitting head against wall
« Reply #26 on: July 03, 2012, 10:59:39 am »
Receiving loud and clear.....

Busy running about 40 analyses I have cued to be followed by 150 3d brain reconstructions from MRI Scans and 80 other MRI analyses. Also building my new 24 processor thread 96 GB linux processing server.

Lifes a bitch aint it :D

Dave

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: Still hitting head against wall
« Reply #27 on: July 03, 2012, 11:17:02 am »
As long as you're having fun ;)
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

liewald

  • Full Member
  • ***
  • Posts: 142
Re: Still hitting head against wall
« Reply #28 on: July 03, 2012, 11:24:27 am »
Fun is relative :D

much rather be playing about doing 3D art..... saving humanity takes so much bloody time!

eny

  • Hero Member
  • *****
  • Posts: 1634
Re: Still hitting head against wall
« Reply #29 on: July 03, 2012, 12:10:40 pm »
Ok I used a TFPStringHashTable to hold the lookup values and populated it using virtually the same routines as the bufdataset.

Process the 21 files and created output file in about  45seconds... WOW

love saving millisecs :D

thanks Ludob for the heads up.
Using hash classes, wow, I wish I would have thought of that...  %)
All posts based on: Win10 (Win64); Lazarus 2.0.10 'stable' (x64) unless specified otherwise...

 

TinyPortal © 2005-2018