Skip to content

Commit 988a018

Browse files
committed
2 parents 3f7b3fe + 98b14b3 commit 988a018

File tree

6 files changed

+27
-27
lines changed

6 files changed

+27
-27
lines changed

entries/abouchez/README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,14 @@ You will find in the [`src` sub-folder](./src) several implementations of the ch
8181

8282
The following table gives you an overview of these versions, in time implementation order. The first column gives direct access to each project source code:
8383

84-
project | shared | full | nobranch | submap | 41K | 400
85-
-------------------------------------------- |:------:|:----:|:--------:|:------:| ----:| ----:
86-
[`old`](./src/brcmormotold.lpr) | | `X` | | | 1814 | 1127
87-
[`sharedht`](./src/brcmormotsharedht.lpr) | `X` | | | | 1169 | 976
88-
[`fullcheck`](./src/brcmormotfullcheck.lpr) | | `X` | `X` | `X` | 1295 | 991
89-
[`perthreadht`](./src/brcmormotperthreadht.lpr) | | | `X` | `X` | 933 | 952
90-
[*final* `-a`](./src/brcmormot.lpr) | `X` | | `X` | `X` | 913 | 885
91-
[*final* `-f -a`](./src/brcmormot.lpr) | `X` | `X` | `X` | `X` | |
84+
project | shared | full | nobranch | submap | 41K | 400
85+
----------------------------------------------- |:------:|:----:|:--------:|:------:| ----:| ----:
86+
[`old`](./src/brcmormotold.lpr) | | `X` | | | 1350 | 1102
87+
[`sharedht`](./src/brcmormotsharedht.lpr) | `X` | | | | 1135 | 923
88+
[`fullcheck`](./src/brcmormotfullcheck.lpr) | | `X` | `X` | `X` | 1261 | 760
89+
[`perthreadht -a`](./src/brcmormotperthreadht.lpr) | | | `X` | `X` | 779 | 745
90+
[*final* `-a`](./src/brcmormot.lpr) | `X` | | `X` | `X` | 817 | 738
91+
[*final* `-f -a`](./src/brcmormot.lpr) | `X` | `X` | `X` | `X` | 1424 | 759
9292

9393
Here are the columns meaning:
9494

@@ -97,11 +97,11 @@ Here are the columns meaning:
9797
- "full" indicates that the full station name is checked, byte-per-byte, to detect any hash collision (not required by our Pascal challenge, but required by the original Java challenge) - so no `X` here states that the ["perfect hash trick"](#perfect-hash-trick) is used by this solution;
9898
- "nobranch" indicates that the temperature parsing is using a branchless algorithm;
9999
- "submap" indicates that `mmap()` is not called for the whole 16GB input file, but for each chunk in its own worker thread;
100-
- "41K" and "400" are the time (in milliseconds) reported on OVH public cloud by `paweld` in [the "Alternative results" discussion thread](https://github.com/gcarreno/1brc-ObjectPascal/discussions/103#discussioncomment-9273061) for 41343 or 400 stations - so it is on AMD CPU, but not the "official" timing.
100+
- "41K" and "400" are the time (in milliseconds) reported on OVH public cloud by `paweld` in [the "Alternative results" discussion thread](https://github.com/gcarreno/1brc-ObjectPascal/discussions/103#discussioncomment-9307532) for 41343 or 400 stations - so it is on AMD CPU, but not the "official" timing.
101101

102102
So we have a good coverage on what should be the best solution to propose.
103103

104-
Note that those timings differs from what I got on my own Intel Core i5 computer, on which the 400 stations version is much faster than the 41K stations. Seems to be because of diverse CPU cache sizes - [see below](#analysis).
104+
Note that those timings differs from what I got on my own Intel Core i5 computer, on which the 400 stations version is much faster than the 41K stations, and the *final* project is always faster (by a noticeable margin). Seems to be because of diverse CPU cache sizes - [see below](#analysis).
105105

106106
## Why L1 Cache Matters
107107

entries/hgrosser/src/1brc_th.lpi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<CompilerOptions>
2525
<Version Value="11"/>
2626
<Target>
27-
<Filename Value="../../../bin/hgrosser"/>
27+
<Filename Value="../../../bin/hgrosser-th"/>
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-th"/>
6363
</Target>
6464
<SearchPaths>
6565
<IncludeFiles Value="$(ProjOutDir)"/>
@@ -111,7 +111,7 @@
111111
<CompilerOptions>
112112
<Version Value="11"/>
113113
<Target>
114-
<Filename Value="../../../bin/hgrosser"/>
114+
<Filename Value="../../../bin/hgrosser-th"/>
115115
</Target>
116116
<SearchPaths>
117117
<IncludeFiles Value="$(ProjOutDir)"/>

entries/ikelaiah/README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,10 @@ Iwan Kelaiah
141141
* Reduced buffer for `TStreamReader` to `65536 * 2`. This saves approx 5 seconds.
142142
* Changed hashmap from `TGHashMapLP` (linear probing) to `TGHashMapQP` (quadratic probing). This saves approx 5 seconds.
143143

144+
* 1.11
145+
* Revision release - Sequential approach. 3-5 mins on my Inspiron 15 7510 laptop, around 2m55s (no improvement on speed).
146+
* Replaced `LGenerics` with `Generics.Collections` for the time being.
147+
144148
## License
145149

146150
This project is licensed under the MIT License - see the LICENSE.md file for details
@@ -166,4 +170,4 @@ Inspiration, code snippets, libraries, etc.
166170
5. Shraddha Agrawal - https://www.bytesizego.com/blog/one-billion-row-challenge-go.
167171
- The advice for not storing measurements for each station in a data structure.
168172
6. Arman Hajisafi - https://arman-hs.github.io
169-
- Encouragements and inspirations.
173+
- Encouragements and inspirations.

entries/ikelaiah/src/OneBRC.lpi

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
</Target>
2727
<SearchPaths>
2828
<IncludeFiles Value="$(ProjOutDir)"/>
29-
<OtherUnitFiles Value="..\..\..\baseline\Common"/>
29+
<OtherUnitFiles Value="..\..\..\baseline;lgenerics"/>
3030
<UnitOutputDirectory Value="..\..\..\bin\lib\$(TargetCPU)-$(TargetOS)"/>
3131
</SearchPaths>
3232
<Parsing>
@@ -69,7 +69,7 @@
6969
</Target>
7070
<SearchPaths>
7171
<IncludeFiles Value="$(ProjOutDir)"/>
72-
<OtherUnitFiles Value="..\..\..\baseline\Common"/>
72+
<OtherUnitFiles Value="..\..\..\baseline\Common;lgenerics"/>
7373
<UnitOutputDirectory Value="..\..\..\bin\lib\$(TargetCPU)-$(TargetOS)"/>
7474
</SearchPaths>
7575
<CodeGeneration>
@@ -100,11 +100,6 @@
100100
<RunParams>
101101
<FormatVersion Value="2"/>
102102
</RunParams>
103-
<RequiredPackages Count="1">
104-
<Item1>
105-
<PackageName Value="LGenerics"/>
106-
</Item1>
107-
</RequiredPackages>
108103
<Units Count="3">
109104
<Unit0>
110105
<Filename Value="OneBRC.lpr"/>

entries/ikelaiah/src/OneBRC.lpr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
WeatherStation;
3737

3838
const
39-
version = '1.5';
39+
version = '1.11';
4040

4141
type
4242

entries/ikelaiah/src/weatherstation.pas

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ interface
1010
, Math
1111
, streamex
1212
, bufstream
13-
, lgHashMap
13+
//, lgHashMap
14+
, generics.Collections
1415
{$IFDEF DEBUG}
1516
, Stopwatch
1617
{$ENDIF}
@@ -35,11 +36,11 @@ TStat = record
3536

3637
type
3738
// Using this dictionary, now approx 4 mins faster than Generics.Collections.TDictionary
38-
TWeatherDictionaryLG = specialize TGHashMapQP<ShortString, PStat>;
39+
TWeatherDictionaryLG = specialize TFastHashMap<ShortString, PStat>;
3940

4041
type
4142
// a type for storing valid lookup temperature
42-
TValidTemperatureDictionary = specialize TGHashMapQP<ShortString, int64>;
43+
TValidTemperatureDictionary = specialize TFastHashMap<ShortString, int64>;
4344

4445
type
4546
// Create a class to encapsulate the temperature observations of each weather station.
@@ -121,10 +122,10 @@ constructor TWeatherStation.Create(const filename: string);
121122
// Create a lookup
122123
self.lookupStrFloatToIntList := TValidTemperatureDictionary.Create;
123124
// Set expected capacity - saves 10 seconds.
124-
self.lookupStrFloatToIntList.EnsureCapacity(44691);
125+
self.lookupStrFloatToIntList.Capacity := 44691;
125126
// Create a dictionary
126127
weatherDictionary := TWeatherDictionaryLG.Create;
127-
weatherDictionary.EnsureCapacity(44691);
128+
weatherDictionary.Capacity := 44691;
128129
// Create a TStringList for sorting
129130
weatherStationList := TStringList.Create;
130131
end;

0 commit comments

Comments
 (0)