Skip to content

Commit e5c01ec

Browse files
authored
Merge branch 'gcarreno:main' into ikelaiah-rev06
2 parents 1919a8e + 9174964 commit e5c01ec

37 files changed

+5411
-147
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
/results
66
/entries/entries.json
77
*.sh
8+
*.cmd
89

910
# Compiled l10n files: .mo should be ignored
1011
*.mo

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright © 2024 Gustavo 'Gus' Carreno <guscarreno@gmail.com>
3+
Copyright © 2024 The 1BRC in Object Pascal participants
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

entries/abouchez/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ Here are the main ideas behind this implementation proposal:
6262
- The station names are stored as UTF-8 pointers to the memmap location where they appear first, in `StationName[]`, to be emitted eventually for the final output, not during temperature parsing;
6363
- No memory allocation (e.g. no transient `string` or `TBytes`) nor any syscall is done during the parsing process to reduce contention and ensure the process is only CPU-bound and RAM-bound (we checked this with `strace` on Linux);
6464
- Pascal code was tuned to generate the best possible asm output on FPC x86_64 (which is our target) - perhaps making it less readable, because we used pointer arithmetics when it matters (I like to think as such low-level pascal code as [portable assembly](https://sqlite.org/whyc.html#performance) similar to "unsafe" code in managed languages);
65+
- We even tried an optimized SSE2 asm sub-function for searching the name `';'` delimiter - which is a O(n) part of the process, and in practice... it was slower than a slightly unrolled pure pascal inlined loop;
6566
- It can optionally output timing statistics and resultset hash value on the console to debug and refine settings (with the `-v` command line switch);
6667
- It can optionally set each thread affinity to a single core (with the `-a` command line switch).
6768

entries/abouchez/src/brcmormot.lpr

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ function NameLen(p: PUtf8Char): PtrInt; inline;
172172
exit(result + 1)
173173
else
174174
exit;
175-
// this small (unrolled) inlined loop is as fast as the SSE2 :)
175+
// this small (unrolled) inlined loop is faster than a SSE2 function :)
176176
end;
177177
{$endif FPC_CPUX64}
178178

@@ -216,7 +216,7 @@ procedure TBrcThread.Execute;
216216
inc(s^.Count);
217217
m := s^.Min;
218218
if v < m then
219-
m := v; // branchless cmovl
219+
m := v; // branchless cmovg/cmovl
220220
s^.Min := m;
221221
m := s^.Max;
222222
if v > m then
@@ -243,7 +243,6 @@ constructor TBrcMain.Create(const fn: TFileName; threads, chunkmb, max: integer;
243243
raise ESynException.CreateUtf8('Impossible to find %', [fn]);
244244
fMax := max;
245245
fChunkSize := chunkmb shl 20;
246-
fList.Init(fMax);
247246
fCurrentChunk := pointer(fMem.Buffer);
248247
fCurrentRemain := fMem.Size;
249248
core := 0;

entries/dcornelius/src/dcornelius.dpr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
program dcornelius;
2-
(* as: OBRC_DCornelius.dpr
2+
(* as: DCornelius.dpr
33
* by: David Cornelius
44
* on: March, 2024
55
* in: Delphi 12 Athens
@@ -30,7 +30,7 @@ begin
3030
Writeln('SYNTAX: ' + ExtractFileName(ParamStr(0)) + ' <filename> <method>');
3131
Writeln(' where <filename> is a text file with weather station data');
3232
Writeln(' and <method> is the algorytm for summarizing the data:');
33-
Writeln(' TSL = read in all data to a TStringList (lots of memory needed)');
33+
Writeln(' TSL = read in all data to a TStringList');
3434
Writeln(' DIC = build a Dictionary, then sort after built');
3535
Writeln(' TBL = load a FireDAC in-memory table - warning: takes several hours!');
3636
Writeln;
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2+
<Import Condition="Exists('$(BDS)\bin\CodeGear.Deployment.targets')" Project="$(BDS)\bin\CodeGear.Deployment.targets"/>
3+
<ProjectExtensions>
4+
<ProjectFileVersion>12</ProjectFileVersion>
5+
</ProjectExtensions>
6+
<PropertyGroup>
7+
<DeviceId Condition="'$(Platform)'=='Android'"/>
8+
<DeviceId Condition="'$(Platform)'=='Android64'"/>
9+
<DeviceId Condition="'$(Platform)'=='iOSDevice64'"/>
10+
<DeviceId Condition="'$(Platform)'=='iOSSimARM64'"/>
11+
</PropertyGroup>
12+
<ItemGroup Condition="'$(Platform)'=='OSX64'"/>
13+
<ItemGroup Condition="'$(Platform)'=='Win32'">
14+
<DeployFile Include="Win32\Debug\obrc_dcornelius.exe" Condition="'$(Config)'=='Debug'">
15+
<RemoteDir>obrc_dcornelius\</RemoteDir>
16+
<RemoteName>obrc_dcornelius.exe</RemoteName>
17+
<DeployClass>ProjectOutput</DeployClass>
18+
<Operation>0</Operation>
19+
<LocalCommand/>
20+
<RemoteCommand/>
21+
<Overwrite>True</Overwrite>
22+
<Required>True</Required>
23+
</DeployFile>
24+
</ItemGroup>
25+
<ItemGroup Condition="'$(Platform)'=='Android64'"/>
26+
<ItemGroup Condition="'$(Platform)'=='Android'"/>
27+
<ItemGroup Condition="'$(Platform)'=='OSXARM64'"/>
28+
<ItemGroup Condition="'$(Platform)'=='Win64'"/>
29+
<ItemGroup Condition="'$(Platform)'=='iOSDevice64'"/>
30+
<ItemGroup Condition="'$(Platform)'=='iOSSimARM64'"/>
31+
<ItemGroup Condition="'$(Platform)'=='Linux64'">
32+
<DeployFile Include="Linux64\obrc_dcornelius" Condition="'$(Config)'=='Debug'">
33+
<RemoteDir>obrc_dcornelius\</RemoteDir>
34+
<RemoteName>obrc_dcornelius</RemoteName>
35+
<DeployClass>ProjectOutput</DeployClass>
36+
<Operation>1</Operation>
37+
<LocalCommand/>
38+
<RemoteCommand/>
39+
<Overwrite>True</Overwrite>
40+
<Required>True</Required>
41+
</DeployFile>
42+
</ItemGroup>
43+
</Project>
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
program obrc_dcornelius;
2+
(* as: OBRC_DCornelius.dpr
3+
* by: David Cornelius
4+
* on: March, 2024
5+
* in: Delphi 12 Athens
6+
* to: submit an entry in the One Billion Row Challenge
7+
*
8+
* Development/Testing was done on a 3.8 GHz Intel i7 desktop computer running Windows 11.
9+
*
10+
* NOTE: Build with 'Debug' configuration for messages, automatic timing, and a pause at the end.
11+
* Build with 'Release' configuration for the official submission.
12+
*)
13+
14+
{$APPTYPE CONSOLE}
15+
16+
{$R *.res}
17+
18+
uses
19+
System.SysUtils, System.Classes,
20+
{$IFDEF DEBUG}
21+
System.Diagnostics,
22+
{$ENDIF }
23+
uChallengeWithDictionary in 'uChallengeWithDictionary.pas',
24+
uChallengeCommon in 'uChallengeCommon.pas',
25+
uChallengeWithStringList in 'uChallengeWithStringList.pas',
26+
udmChallengeWithFireDAC in 'udmChallengeWithFireDAC.pas' {dmChallengeWithFireDAC: TDataModule};
27+
28+
procedure DisplaySyntax;
29+
begin
30+
Writeln('SYNTAX: ' + ExtractFileName(ParamStr(0)) + ' <filename> <method>');
31+
Writeln(' where <filename> is a text file with weather station data');
32+
Writeln(' and <method> is the algorytm for summarizing the data:');
33+
Writeln(' TSL = read in all data to a TStringList (lots of memory needed)');
34+
Writeln(' DIC = build a Dictionary, then sort after built');
35+
Writeln(' TBL = load a FireDAC in-memory table');
36+
Writeln;
37+
Writeln('Press ENTER...');
38+
Readln;
39+
end;
40+
41+
begin
42+
try
43+
if ParamCount <> 2 then
44+
DisplaySyntax
45+
else begin
46+
{$IFDEF DEBUG}
47+
var StopWatch := TStopwatch.StartNew;
48+
{$ENDIF}
49+
ChallengeCommon := TChallengeCommon.Create(ParamStr(1));
50+
try
51+
var Method := ParamStr(2);
52+
if SameText(Method, 'TSL') then
53+
ChallengeWithStringList
54+
else if SameText(Method, 'DIC') then
55+
ChallengeWithDictionary
56+
else if SameText(Method, 'TBL') then
57+
ChallengeWithFireDAC
58+
else
59+
raise EArgumentException.Create('Invalid method');
60+
finally
61+
ChallengeCommon.Free;
62+
end;
63+
{$IFDEF DEBUG}
64+
StopWatch.Stop;
65+
Writeln('Elapsed Time (seconds/milliseconds): ', StopWatch.Elapsed.Seconds, ' / ', StopWatch.ElapsedMilliseconds);
66+
Readln;
67+
{$ENDIF}
68+
end;
69+
except
70+
on E: Exception do
71+
Writeln(E.ClassName, ': ', E.Message);
72+
end;
73+
end.

0 commit comments

Comments
 (0)