Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
bea0fbe
extract types from entrypoint
gshigin Jun 26, 2026
023b6fe
Merge remote-tracking branch 'origin/pp' into entrypoint_split
gshigin Jun 26, 2026
1a54159
format fix
gshigin Jun 26, 2026
9a7d15d
Merge remote-tracking branch 'origin/pp' into entrypoint_split
gshigin Jun 26, 2026
205d1c4
entrypoint tests
gshigin Jun 26, 2026
c0f0c48
refine tests
gshigin Jun 29, 2026
0f73bbd
Merge remote-tracking branch 'origin/pp' into entrypoint_tests
gshigin Jun 29, 2026
049edea
entrypoint types tests build
gshigin Jun 30, 2026
e986670
Merge remote-tracking branch 'origin/pp' into entrypoint_split
gshigin Jun 30, 2026
2627923
move components to entrypoint
gshigin Jun 30, 2026
e7de0c9
Merge branch 'entrypoint_split' into entrypoint_tests
gshigin Jun 30, 2026
3141713
build fixes
gshigin Jun 30, 2026
db4d0a4
consistent namespace naming
gshigin Jun 30, 2026
e5b5b29
Merge branch 'entrypoint_split' into entrypoint_tests
gshigin Jun 30, 2026
caa02a2
update namespaces in tests
gshigin Jun 30, 2026
12afebe
add libclang to docker container
gshigin Jul 1, 2026
d1b9e6a
init tooling
gshigin Jul 5, 2026
f70ed15
ref
gshigin Jul 6, 2026
5217d79
more ref
gshigin Jul 6, 2026
fe734e5
remove build system
gshigin Jul 6, 2026
05ac747
new build system
gshigin Jul 6, 2026
cd32776
Merge remote-tracking branch 'origin/pp' into entrypoint_codegen_tool
gshigin Jul 6, 2026
dd3f206
Merge remote-tracking branch 'origin/pp' into entrypoint_codegen_tool
gshigin Jul 7, 2026
2581d38
ignore tools for //... target
gshigin Jul 7, 2026
3add2c0
Merge branch 'pp' into entrypoint_split
gshigin Jul 8, 2026
8b6073b
Merge branch 'entrypoint_split' into entrypoint_tests
gshigin Jul 8, 2026
11c4ed9
rewiew fixes
gshigin Jul 8, 2026
8301db4
ref
gshigin Jul 8, 2026
080affc
facts review
gshigin Jul 8, 2026
fc0699f
facts tests tweak
gshigin Jul 8, 2026
11df36a
contract review
gshigin Jul 8, 2026
c475a34
rules_cc fall back
gshigin Jul 8, 2026
e8e4000
review diagnostics
gshigin Jul 9, 2026
93820db
i hate libclang
gshigin Jul 9, 2026
47c5973
emit review
gshigin Jul 9, 2026
67b6004
app review
gshigin Jul 9, 2026
6a03f12
fix entrypoint discovery
gshigin Jul 9, 2026
8687f67
merge entrypoint code generation tool
gshigin Jul 13, 2026
943790d
merge entrypoint split
gshigin Jul 13, 2026
22bfc22
merge entrypoint tests
gshigin Jul 13, 2026
77c165d
fix tool
gshigin Jul 13, 2026
95f4592
annotate entrypoint
gshigin Jul 13, 2026
5090bbb
isolate helpers in nameless namespace
gshigin Jul 13, 2026
a753673
change annotations, don't ignore error
gshigin Jul 14, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions pp/.bazelignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ bazel-pp
bazel-out
bazel-testlogs
bazel-external

# Standalone Bzlmod module consumed through @entrypoint_codegen via local_path_override.
# Keep it out of root //... package discovery.
tools/entrypoint_codegen
62 changes: 51 additions & 11 deletions pp/BUILD
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
load("//:bazel/rules/cc_static_library.bzl", "cc_static_library")
load("//:bazel/rules/entrypoint_codegen.bzl", "entrypoint_fact_checking")

package(default_visibility = ["//visibility:public"])

Expand Down Expand Up @@ -183,21 +184,48 @@ cc_test(
)

cc_library(
name = "entrypoint",
name = "entrypoint_types",
hdrs = glob([
"entrypoint/types/**/*.h",
]),
linkstatic = True,
deps = [
":bare_bones",
":head",
":primitives",
":series_data",
":series_index",
":wal",
],
)

cc_test(
name = "entrypoint_types_test",
srcs = glob(["entrypoint/types/**/*_tests.cpp"]),
deps = [
":bare_bones",
":entrypoint_types",
":metrics",
":prometheus",
":wal",
"@gtest//:gtest_main",
],
)

cc_library(
name = "entrypoint_bridge",
srcs = glob(
include = ["entrypoint/**/*.cpp"],
exclude = [
"entrypoint/init/**",
"entrypoint/**/*_tests.cpp",
],
include = ["entrypoint/bridge/**/*.cpp"],
exclude = ["entrypoint/bridge/**/*_tests.cpp"],
),
hdrs = glob([
"entrypoint/**/*.h",
"entrypoint/**/*.hpp",
"entrypoint/bridge/**/*.h",
"entrypoint/bridge/**/*.hpp",
]),
linkstatic = True,
deps = [
":bare_bones",
":entrypoint_types",
":head",
":metrics",
":primitives",
Expand All @@ -208,19 +236,31 @@ cc_library(
}),
)

entrypoint_fact_checking(
name = "entrypoint_fact_checking",
srcs = glob(
include = ["entrypoint/**/*.cpp"],
exclude = [
"entrypoint/init/**",
"entrypoint/**/*_tests.cpp",
],
),
target = ":entrypoint_bridge",
)

cc_static_library(
name = "entrypoint_aio",
deps = [
":entrypoint",
":entrypoint_bridge",
],
)

cc_library(
name = "entrypoint_init",
srcs = glob(["entrypoint/init/*.cpp"]),
hdrs = glob([
"entrypoint/init/*.h",
"entrypoint/init/*.hpp",
"entrypoint/init/**/*.h",
"entrypoint/init/**/*.hpp",
]),
linkstatic = True,
)
Expand Down
8 changes: 8 additions & 0 deletions pp/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ bazel_dep(name = "platforms", version = "0.0.11")
bazel_dep(name = "rules_cc", version = "0.1.1")
bazel_dep(name = "rules_foreign_cc", version = "0.15.1")

# Local standalone component. It can be built independently from
# tools/entrypoint_codegen, and pp consumes it as an external module.
bazel_dep(name = "entrypoint_codegen", version = "0", dev_dependency = True)
local_path_override(
module_name = "entrypoint_codegen",
path = "tools/entrypoint_codegen",
)

# --- Tools not published to BCR (use git_override) ----------------------------
# bazel_clang_tidy is only used by `make tidy` (clang-tidy aspect); it never
# enters the production entrypoint build, so it is a dev-only dependency. This
Expand Down
3 changes: 3 additions & 0 deletions pp/bare_bones/preprocess.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#pragma once

// Dispatch a PromPP macro category to a function-like implementation.
#define PROMPP(category, ...) PROMPP_DETAIL_##category(__VA_ARGS__)

#define PROMPP_ATTRIBUTE_INLINE __attribute__((always_inline))
#define PROMPP_ATTRIBUTE_NOINLINE __attribute__((noinline))

Expand Down
144 changes: 144 additions & 0 deletions pp/bazel/rules/entrypoint_codegen.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
def _prefixed_args(flag, values):
return [flag + value for value in values]

def _path_args(flag, paths):
return _prefixed_args(flag, [path for path in paths])

def _compilation_args(ctx):
target = ctx.attr.target
compilation_context = target[CcInfo].compilation_context
args = []
args.extend(_prefixed_args("-D", compilation_context.defines.to_list()))
args.extend(_path_args("-I", compilation_context.includes.to_list()))
args.extend(_path_args("-iquote", compilation_context.quote_includes.to_list()))
args.extend(_path_args("-isystem", compilation_context.system_includes.to_list()))
args.append("-iquote.")
args.append("-iquote" + ctx.bin_dir.path)
return args

def _entrypoint_fact_checking_impl(ctx):
output = ctx.actions.declare_file(ctx.label.name + ".json")
log = ctx.actions.declare_file(ctx.label.name + ".log")

compilation_context = ctx.attr.target[CcInfo].compilation_context
clang_args = list(ctx.attr.clang_args)
clang_args.extend(_compilation_args(ctx))

json_args = ctx.actions.args()
json_args.add("--mode=json")
json_args.add("--output=" + output.path)
json_args.add_all(ctx.files.srcs)
json_args.add("--")
json_args.add_all(clang_args)

lint_args = ctx.actions.args()
lint_args.add("--mode=lint")
lint_args.add_all(ctx.files.srcs)
lint_args.add("--")
lint_args.add_all(clang_args)

inputs = depset(
direct = ctx.files.srcs,
transitive = [
compilation_context.headers,
ctx.attr.target[DefaultInfo].files,
],
)

ctx.actions.run_shell(
inputs = inputs,
tools = [ctx.executable.tool],
outputs = [
output,
log,
],
arguments = [
ctx.executable.tool.path,
log.path,
output.path,
json_args,
"--entrypoint_fact_checking_lint_args--",
lint_args,
],
command = """
tool="$1"
log="$2"
output="$3"
shift 3

json_args=()
while [ "$#" -gt 0 ] && [ "$1" != "--entrypoint_fact_checking_lint_args--" ]; do
json_args+=("$1")
shift
done

if [ "$#" -gt 0 ]; then
shift
fi

lint_args=("$@")

set +e
"${tool}" "${json_args[@]}" >"${log}" 2>&1
status=$?

{
echo
echo "entrypoint_fact_checking diagnostics:"
} >>"${log}"
"${tool}" "${lint_args[@]}" >>"${log}" 2>&1
lint_status=$?

if [ "${status}" -eq 0 ]; then
status="${lint_status}"
fi

if [ -s "${log}" ]; then
sed 's/^/entrypoint_fact_checking: /' "${log}" >&2
fi

if [ ! -s "${output}" ]; then
echo "ERROR: entrypoint_fact_checking did not produce ${output}; see ${log}" >&2
if [ "${status}" -ne 0 ]; then
exit "${status}"
fi
exit 1
fi

if [ "${status}" -ne 0 ]; then
echo "WARNING: entrypoint_fact_checking reported diagnostics; see ${output} and ${log}" >&2
fi
exit 0
""",
mnemonic = "EntrypointFactChecking",
progress_message = "Checking entrypoint facts for %{label}",
)

return [
DefaultInfo(files = depset([
output,
log,
])),
]

entrypoint_fact_checking = rule(
implementation = _entrypoint_fact_checking_impl,
attrs = {
"clang_args": attr.string_list(
default = ["-std=c++2b"],
),
"srcs": attr.label_list(
allow_files = [".cc", ".cpp", ".cxx"],
mandatory = True,
),
"target": attr.label(
mandatory = True,
providers = [CcInfo],
),
"tool": attr.label(
default = Label("@entrypoint_codegen//:entrypoint_codegen"),
executable = True,
cfg = "exec",
),
},
)
9 changes: 6 additions & 3 deletions pp/entrypoint/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ else
sed := sed
endif

# All headers in entrypoint
# All C API headers in entrypoint/bridge
#
# This headers combined to result header-file.
# Symbols from this files used to build runtime entrypoint.
# So if the symbol is not described in these headers, no entrypoint will be created for it.
#
# We separate .h and .hpp files here, because we need _helper.hpp file with no exported symbols,
# but with internal re-used code.
headers := $(wildcard *.h)
headers := $(wildcard bridge/*.h)

# Platform detected from host
#
Expand Down Expand Up @@ -75,6 +75,9 @@ install: $(result_dir)/$(platform)_entrypoint_init_aio_$(result_suffix).a
install: $(prefixed_archives)
@install $^ $(install_dir)

$(result_dir)/entrypoint.h: $(headers) entrypoint.h.template ## Concat all headers in one
# Shared type/layout contracts that the Go side reads via cgo (e.g. Sizeof_* macros).
type_headers := ../entrypoint/types/go_constants.h

$(result_dir)/entrypoint.h: $(type_headers) $(headers) entrypoint.h.template ## Concat all headers in one
@mkdir -p ${@D}
@cat $^ > $@
13 changes: 13 additions & 0 deletions pp/entrypoint/bridge/annotations.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#pragma once

#include "bare_bones/preprocess.h"

#define PROMPP_DETAIL_entrypoint(kind) PROMPP_DETAIL_entrypoint_##kind()

#ifdef __clang__
#define PROMPP_DETAIL_entrypoint_cgo() __attribute__((annotate("prompp.entrypoint.cgo")))
#define PROMPP_DETAIL_entrypoint_fastcgo() __attribute__((annotate("prompp.entrypoint.fastcgo")))
#else
#define PROMPP_DETAIL_entrypoint_cgo()
#define PROMPP_DETAIL_entrypoint_fastcgo()
#endif
34 changes: 29 additions & 5 deletions pp/entrypoint/common.cpp → pp/entrypoint/bridge/common.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "common.h"
#include "annotations.h"
#include "bare_bones/jemalloc.h"

#if !JEMALLOC_AVAILABLE
Expand All @@ -7,21 +8,34 @@

#include "primitives/go_slice.h"

extern "C" void prompp_free_bytes(void* args) {
/**
* @brief Free memory allocated for response as []byte
*
* @param args *[]byte
*/
extern "C" PROMPP(entrypoint, fastcgo) void prompp_free_bytes(void* args) {
using Slice = PromPP::Primitives::Go::Slice<char>;
using Arguments = Slice;

static_cast<Slice*>(args)->~Slice();
static_cast<Arguments*>(args)->~Slice();
}

extern "C" void je_jemalloc_constructor(void);

extern "C" void prompp_jemalloc_init() {
extern "C" PROMPP(entrypoint, fastcgo) void prompp_jemalloc_init() {
#if JEMALLOC_AVAILABLE
je_jemalloc_constructor();
#endif
}

extern "C" void prompp_mem_info(void* res) {
/**
* @brief Return information about using memory by core
*
* @param res {
* in_use uint64 // bytes in use
* }
*/
extern "C" PROMPP(entrypoint, fastcgo) void prompp_mem_info(void* res) {
struct Result {
int64_t in_use;
int64_t allocated;
Expand All @@ -47,7 +61,17 @@ extern "C" void prompp_mem_info(void* res) {
#endif
}

extern "C" void prompp_dump_memory_profile([[maybe_unused]] void* args, void* res) {
/**
* @brief Dump jemalloc memory profile to file
*
* @param args {
* filename string
* }
* @param res {
* int error
* }
*/
extern "C" PROMPP(entrypoint, fastcgo) void prompp_dump_memory_profile([[maybe_unused]] void* args, void* res) {
struct Arguments {
PromPP::Primitives::Go::String filename;
};
Expand Down
File renamed without changes.
Loading
Loading