Skip to content

Commit

Permalink
use avx2 instructionset for bloommatch, use el8 to build (#16)
Browse files Browse the repository at this point in the history
* avx2?

* upgrade build pipeline to el8, fix avx2 handling

* restore symlink name

* use CFLAGS="-mavx2 -O3" and compatible types to automatically generate avx2 code

* emacs auto indent

* add missing return statement

* inclde stdlib.h to avoid implicit declarations of functions malloc and free
  • Loading branch information
kortemik authored Nov 18, 2024
1 parent f2d7107 commit 4fab538
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 36 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM centos:7
RUN yum -y install make automake autoconf libtool mariadb-devel
FROM rockylinux:8
RUN dnf -y install make automake autoconf libtool mariadb-devel
WORKDIR /code
COPY docker-entrypoint.sh /docker-entrypoint.sh
ENTRYPOINT [ "/docker-entrypoint.sh" ]
2 changes: 1 addition & 1 deletion docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
cd /code || exit 1;
autoreconf -fvi
bash configure
CFLAGS="-mavx2 -O3" bash configure
make
make install DESTDIR=/code/buildroot
51 changes: 21 additions & 30 deletions lib_mysqludf_bloom.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>

/* For Windows, define PACKAGE_STRING in the VS project */
#ifndef __WIN__
Expand Down Expand Up @@ -69,38 +71,28 @@ void bloommatch_deinit(UDF_INIT *initid)
{
}

my_bool bloommatch(UDF_INIT *initid, UDF_ARGS *args, char* result, unsigned long* length, char *is_null, char *error)
{
if (args->lengths[0] > args->lengths[1])
{
return 0;
}

char* b1=args->args[0];
char* b2=args->args[1];
int limit_a = args->lengths[0];
int limit_b = args->lengths[1];
if (limit_a != limit_b)
{
return 0;
}

unsigned char a;
unsigned char b;
int i;
for (i=0;i<limit_a;i++)
{
a = (unsigned char) b1[i];
b = (unsigned char) b2[i];
if ((a & b) != a)
{
return 0;
}
}
return 1;
my_bool bloommatch(UDF_INIT *initid, UDF_ARGS *args, char *result, unsigned long *length, char *is_null, char *error)
{
if (args->lengths[0] != args->lengths[1])
{
return 0;
}

const uint8_t *b1 = (const uint8_t *)args->args[0];
const uint8_t *b2 = (const uint8_t *)args->args[1];

size_t limit = args->lengths[0];

for (size_t i = 0; i < limit; i++) {
if ((b1[i] & b2[i]) != b1[i]) {
return 0;
}
}

return 1;
}


my_bool bloomupdate_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
{
/* make sure user has provided exactly two string arguments */
Expand Down Expand Up @@ -160,4 +152,3 @@ char* bloomupdate(UDF_INIT *initid, UDF_ARGS *args, char* result, unsigned long*
*length = limit;
return initid->ptr;
}

6 changes: 3 additions & 3 deletions rpm.pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<packaging>rpm</packaging>
<modelVersion>4.0.0</modelVersion>
<artifactId>blf_02</artifactId>
<version>${revision}${sha1}${changelist}.el7</version>
<version>${revision}${sha1}${changelist}.el8</version>
<name>blf_02</name>
<description>blf_02</description>
<groupId>com.teragrep</groupId>
Expand Down Expand Up @@ -74,7 +74,7 @@
<recurseDirectories>true</recurseDirectories>
<sources>
<source>
<location>${project.basedir}/buildroot/usr/lib64/mysql/plugin</location>
<location>${project.basedir}/buildroot/usr/lib64/mariadb/plugin</location>
</source>
</sources>
</mapping>
Expand All @@ -98,7 +98,7 @@
</mapping>
<!-- symlink for the payload -->
<mapping>
<directory>/usr/lib64/mysql/plugin</directory>
<directory>/usr/lib64/mariadb/plugin</directory>
<sources>
<softlinkSource>
<location>/opt/teragrep/${project.artifactId}/lib/lib_mysqludf_bloom.so</location>
Expand Down

0 comments on commit 4fab538

Please sign in to comment.