Skip to content

Commit 7ce393f

Browse files
committed
reduced memory consumption
1 parent 9d036a0 commit 7ce393f

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

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;

0 commit comments

Comments
 (0)