Skip to content

Commit 295438e

Browse files
committed
the input file is now read via mORMot's type 'TMemoryMap', the hash code is now computed via mORMot's crc32c-function, several small improvements
1 parent 480f14e commit 295438e

File tree

5 files changed

+251
-58
lines changed

5 files changed

+251
-58
lines changed

entries/hgrosser/README.md

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,42 +3,33 @@
33
**1 billion row Challenge entry**
44

55
## Version
6-
Version 2.00 (first version with threads)
6+
Version 2.10 (version with threads, does NOT yet work for 400 stations or 5 billion rows)
77

88
## How to compile
99
The program was developed with FPC 3.2.2 and Lazarus 2.2.4
1010

11-
1brc.lpi + 1brc.pas = version without threads
11+
It uses package **mORMot 2** to compile, which you can download from https://github.com/synopse/mORMot2
1212

13-
1brc_th.lpi + 1brc_th.pas = version with threads
13+
Files to compile: **1brc_th.lpi** and **1brc_th.pas** = this version with threads
1414

1515
## How to start
1616
```
17-
Usage: <path to input file> <thread count> [<bit-width for hash-list> [buffer size in KB]]
18-
- thread count: allowed range = [1..32]
17+
Usage: <path to input file> <thread count> [bit-width for hash-list]
18+
- thread count: allowed range = [1..64]
1919
- bit-width for hash-list: sets the size of the hash list, e.g. '16' => 65536 entries,
20-
allowed range = [16..28], Default=18
21-
- buffer size in KB: allowed range = [1..2,000,000 KB], Default=128 KB
22-
Example: hgrosser measurements.txt 32 18 128
20+
allowed range = [16..28], Default=16
21+
Example: hgrosser measurements.txt 32 16
2322
```
24-
There are no switches like `-i` etc, only 2..4 values.
23+
There are no switches like `-i` etc, only 2 or 3 values.
2524

26-
### Optimizing the 2nd command line parameter
27-
This parameter sets the thread count. With my own old CPU I could only test 1..4 threads. Although I expect 32 threads to be the fastest, I would be very interested to see the results for 1, 4, 8, 16 and 32 threads. Please use for this test the defaults for the 3rd and 4th command line parameters.
28-
29-
### Optimizing the 3rd command line parameter
30-
In theory the program should run faster with greater bit-widths for the hash-list (because of less collisions). On the computer of Gus - without threads - 18 bits was the fastest. Please try the values from 16 to 20 again and use '32' for the 2nd command line parameter and the default for the 4th command line parameter.
31-
32-
### Optimizing the 4th command line parameter
33-
After the 2nd and 3rd command line parameters had been optimized, please try with them 64, 96, 128, 192 and 256 KB as the 4th command line parameter. Thanks a lot!
25+
There is no more need for further optimizing. Please use '32' as 2nd command line parameter and '16' as 3rd command line parameter.
3426

3527
## How the program works
36-
The Program works with multi threads.
28+
The Program works with threads.
3729

3830
To speed things up:
3931

40-
- the input file is read via procedure 'blockread' ...
41-
- into an AnsiString, so that function 'PosEx' can be used to parse it
32+
- the input file is read via **mORMot**'s type 'TMemoryMap'
4233
- to manage the city names, a self made hash-list is used
4334
- temperatures are stored as integers (multiplied by 10)
4435

@@ -50,4 +41,4 @@ To speed things up:
5041
- Version 1.60: hash-list optimized, some minor improvements, Conditional "noCR" added
5142
- Version 1.61: Conditional "noCR" constantely enabled => input files must NOT have CR's
5243
- Version 2.00: 1st version with threads
53-
44+
- Version 2.10: the input file is now read via **mORMot**'s type 'TMemoryMap', the hash code is now computed via **mORMot**'s crc32c-function, several small improvements

entries/hgrosser/src/1brc.lpi renamed to entries/hgrosser/src/1brc_old.lpi

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<CompatibilityMode Value="True"/>
1212
</Flags>
1313
<SessionStorage Value="InIDEConfig"/>
14-
<Title Value="1brc"/>
14+
<Title Value="1brc_old"/>
1515
<UseAppBundle Value="False"/>
1616
<ResourceType Value="res"/>
1717
</General>
@@ -24,7 +24,7 @@
2424
<CompilerOptions>
2525
<Version Value="11"/>
2626
<Target>
27-
<Filename Value="../../../bin/hgrosser"/>
27+
<Filename Value="../../../bin/hgrosser_old"/>
2828
</Target>
2929
<SearchPaths>
3030
<IncludeFiles Value="$(ProjOutDir)"/>
@@ -59,7 +59,7 @@
5959
<CompilerOptions>
6060
<Version Value="11"/>
6161
<Target>
62-
<Filename Value="../../../bin/hgrosser"/>
62+
<Filename Value="../../../bin/hgrosser_old"/>
6363
</Target>
6464
<SearchPaths>
6565
<IncludeFiles Value="$(ProjOutDir)"/>
@@ -104,15 +104,15 @@
104104
</RunParams>
105105
<Units Count="1">
106106
<Unit0>
107-
<Filename Value="1brc.pas"/>
107+
<Filename Value="1brc_old.pas"/>
108108
<IsPartOfProject Value="True"/>
109109
</Unit0>
110110
</Units>
111111
</ProjectOptions>
112112
<CompilerOptions>
113113
<Version Value="11"/>
114114
<Target>
115-
<Filename Value="../../../bin/hgrosser"/>
115+
<Filename Value="../../../bin/hgrosser_old"/>
116116
</Target>
117117
<SearchPaths>
118118
<IncludeFiles Value="$(ProjOutDir)"/>
File renamed without changes.

entries/hgrosser/src/1brc_th.lpi

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,11 @@
101101
</Mode0>
102102
</Modes>
103103
</RunParams>
104+
<RequiredPackages Count="1">
105+
<Item1>
106+
<PackageName Value="mormot2"/>
107+
</Item1>
108+
</RequiredPackages>
104109
<Units Count="1">
105110
<Unit0>
106111
<Filename Value="1brc_th.pas"/>
@@ -115,6 +120,7 @@
115120
</Target>
116121
<SearchPaths>
117122
<IncludeFiles Value="$(ProjOutDir)"/>
123+
<OtherUnitFiles Value="../../../baseline/Common"/>
118124
<UnitOutputDirectory Value="../../../bin/lib/$(TargetCPU)-$(TargetOS)"/>
119125
</SearchPaths>
120126
<Parsing>

0 commit comments

Comments
 (0)