Skip to content

Commit e7e86f1

Browse files
authored
Merge pull request #126 from georges-hatem/main
compatibility with LF rule instead of CRLF, and a few optimizations
2 parents 99b0d3a + c285380 commit e7e86f1

File tree

3 files changed

+23
-5
lines changed

3 files changed

+23
-5
lines changed

entries/ghatem-fpc/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,3 +224,12 @@ I implemented my own Dictionary class consisting of two arrays. We compute the m
224224

225225
edit:
226226
quadratic probing improved performance even further. we could probably do better with 2-level hashing, but finding such a hash function is going to take a lot of trials, this is probably acceptable results
227+
228+
**ACTUAL TIMING (busy machine): ~4 seconds as per gcarreno**
229+
230+
## v.4 (2024-04-24)
231+
232+
a few performance improvements, and measurements as per gcarreno on a busy machine:
233+
- using mORMot's `crc32c` function instead of the native `crc32`, time dropped to 3.8 seconds
234+
- I had removed my pre-allocated records implementation. restored it in the custom dictionary class, time dropped to 3.2 seconds
235+
- skipping a few chars that we don't need to bother with, no timing yet

entries/ghatem-fpc/src/OneBRCproj.lpi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
<Linking>
4646
<Debugging>
4747
<DebugInfoType Value="dsDwarf3"/>
48-
<UseHeaptrc Value="True"/>
4948
<TrashVariables Value="True"/>
5049
<UseValgrind Value="True"/>
5150
<UseExternalDbgSyms Value="True"/>

entries/ghatem-fpc/src/onebrc.pas

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ procedure TOneBRC.ProcessData (aThreadNb: UInt16; aStartIdx: Int64; aEndIdx: Int
318318
// the given ending point might be in the middle of a line:
319319
// find the beginning of that line (the last block works well)
320320
while True do begin
321-
if FData[aEndIdx] <> #13 then
321+
if FData[aEndIdx] <> #10 then
322322
Dec (aEndIdx)
323323
else
324324
break;
@@ -328,7 +328,7 @@ procedure TOneBRC.ProcessData (aThreadNb: UInt16; aStartIdx: Int64; aEndIdx: Int
328328
vLineStart := i;
329329

330330
while i < aEndIdx do begin
331-
if FData[i] = #13 then begin
331+
if FData[i] = #10 then begin
332332
// new line parsed, process its contents
333333
ExtractLineData (vLineStart, i - 1, vLenStationName, vTemp);
334334

@@ -360,8 +360,18 @@ procedure TOneBRC.ProcessData (aThreadNb: UInt16; aStartIdx: Int64; aEndIdx: Int
360360
FStationsDicts[aThreadNb].Add (vHash, vData);
361361
end;
362362

363-
// next char is #10, so we can skip 2 instead of 1
364-
vLineStart := i+2;
363+
// we're at a #10: next line starts at the next index
364+
vLineStart := i+1;
365+
366+
// we're at a #10:
367+
// until the next #10 char, there will be:
368+
// - 1 semicolon
369+
// - 3 chars for the temp (min)
370+
// - 2 chars for the name (min)
371+
// - the usual Inc (I)
372+
// so we should be able to skip 7 chars until another #10 may appear
373+
Inc (i, 7);
374+
continue;
365375
end;
366376

367377
Inc (i);

0 commit comments

Comments
 (0)