Skip to content

Commit 3afb4be

Browse files
dbecksvenklemm
andcommitted
Modified and reimplemented FastLanes library in C
There is a background and intro document in src/fl/README.md The short version is: this change brings a C implementation of the FastLanes library to Timescale DB. The original idea is from 'The FastLanes Compression Layout: Decoding >100 Billion Integers per Second with Scalar Code' by Azim Afroozeh and Peter Boncz (https://doi.org/10.14778/3598581.3598587) Our version departs from the original ideas in a few ways: - instead of having a single 1024 bit virtual register, I introduce multiple smaller register widths, that I call 'tiered FL', the widths are 8, 16, 32, 64, 128 and 256 - we do not have 1024 bit virtual registers - our implementation relies on C macros, instead of C++ templates and code generation The src/fl/README.md file provides more details about the library. Co-authored-by: Sven Klemm <31455525+svenklemm@users.noreply.github.com> Signed-off-by: David Beck <david.beck.priv@gmail.com>
1 parent 235b708 commit 3afb4be

1 file changed

Lines changed: 11 additions & 23 deletions

File tree

tsl/test/src/test_fastlanes.c

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,36 +13,22 @@
1313
#include <time.h>
1414
#include <utils/palloc.h>
1515

16+
TS_FUNCTION_INFO_V1(ts_test_fastlanes);
17+
1618
/*
17-
* palloc_aligned was added in PG 16. On PG 15 we over-allocate
18-
* with palloc, manually aligning, and stashing the raw pointer
19-
* in the slot just before the aligned address so the matching
20-
* pfree_aligned can recover it. On PG 16+ palloc_aligned
21-
* is native and regular pfree handles its output
19+
* palloc_aligned was added in PG 16. As PG 15 support
20+
* is about to be removed, this test is skipped on PG15.
2221
*/
2322
#if PG_VERSION_NUM < 160000
24-
static inline void *
25-
ts_test_palloc_aligned(Size size, Size alignto, int flags)
26-
{
27-
(void) flags;
28-
void *raw = palloc(size + alignto + sizeof(void *));
29-
uintptr_t aligned =
30-
((uintptr_t) raw + sizeof(void *) + alignto - 1) & ~(uintptr_t) (alignto - 1);
31-
((void **) aligned)[-1] = raw;
32-
return (void *) aligned;
33-
}
34-
static inline void
35-
ts_test_pfree_aligned(void *p)
23+
24+
Datum
25+
ts_test_fastlanes(PG_FUNCTION_ARGS)
3626
{
37-
pfree(((void **) p)[-1]);
27+
PG_RETURN_VOID();
3828
}
39-
#define palloc_aligned(size, alignto, flags) ts_test_palloc_aligned((size), (alignto), (flags))
40-
#define pfree_aligned(p) ts_test_pfree_aligned(p)
29+
4130
#else
4231
#define pfree_aligned(p) pfree(p)
43-
#endif
44-
45-
TS_FUNCTION_INFO_V1(ts_test_fastlanes);
4632

4733
/*
4834
* The below tests have a few goals to achieve, to act as a full
@@ -838,3 +824,5 @@ ts_test_fastlanes(PG_FUNCTION_ARGS)
838824
test_w0_coverage();
839825
PG_RETURN_VOID();
840826
}
827+
828+
#endif

0 commit comments

Comments
 (0)