Skip to content

Commit

Permalink
WASM ABI: Strip leading underscore from syscall names (#1705)
Browse files Browse the repository at this point in the history
  • Loading branch information
Centril authored Sep 27, 2024
1 parent a9cead8 commit ccd7e84
Show file tree
Hide file tree
Showing 13 changed files with 107 additions and 110 deletions.
35 changes: 16 additions & 19 deletions crates/bindings-csharp/Runtime/Internal/FFI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,26 +115,23 @@ public readonly record struct RowIter(uint Handle)
}

[LibraryImport(StdbNamespace)]
public static partial CheckedStatus _table_id_from_name(
public static partial CheckedStatus table_id_from_name(
[In] byte[] name,
uint name_len,
out TableId out_
);

[LibraryImport(StdbNamespace)]
public static partial CheckedStatus _datastore_table_row_count(
TableId table_id,
out ulong out_
);
public static partial CheckedStatus datastore_table_row_count(TableId table_id, out ulong out_);

[LibraryImport(StdbNamespace)]
public static partial CheckedStatus _datastore_table_scan_bsatn(
public static partial CheckedStatus datastore_table_scan_bsatn(
TableId table_id,
out RowIter out_
);

[LibraryImport(StdbNamespace)]
public static partial CheckedStatus _iter_by_col_eq(
public static partial CheckedStatus iter_by_col_eq(
TableId table_id,
ColId col_id,
[In] byte[] value,
Expand All @@ -143,14 +140,14 @@ out RowIter out_
);

[LibraryImport(StdbNamespace)]
public static partial CheckedStatus _datastore_insert_bsatn(
public static partial CheckedStatus datastore_insert_bsatn(
TableId table_id,
Span<byte> row,
ref uint row_len
);

[LibraryImport(StdbNamespace)]
public static partial CheckedStatus _delete_by_col_eq(
public static partial CheckedStatus delete_by_col_eq(
TableId table_id,
ColId col_id,
[In] byte[] value,
Expand All @@ -159,33 +156,33 @@ out uint out_
);

[LibraryImport(StdbNamespace)]
public static partial CheckedStatus _iter_start_filtered(
public static partial CheckedStatus iter_start_filtered(
TableId table_id,
[In] byte[] filter,
uint filter_len,
out RowIter out_
);

[LibraryImport(StdbNamespace)]
public static partial Errno _row_iter_bsatn_advance(
public static partial Errno row_iter_bsatn_advance(
RowIter iter_handle,
[MarshalUsing(CountElementName = nameof(buffer_len))] [Out] byte[] buffer,
ref uint buffer_len
);

[LibraryImport(StdbNamespace)]
public static partial CheckedStatus _row_iter_bsatn_close(RowIter iter_handle);
public static partial CheckedStatus row_iter_bsatn_close(RowIter iter_handle);

[LibraryImport(StdbNamespace)]
public static partial CheckedStatus _datastore_delete_all_by_eq_bsatn(
public static partial CheckedStatus datastore_delete_all_by_eq_bsatn(
TableId table_id,
[In] byte[] relation,
uint relation_len,
out uint out_
);

[LibraryImport(StdbNamespace)]
public static partial void _volatile_nonatomic_schedule_immediate(
public static partial void volatile_nonatomic_schedule_immediate(
[In] byte[] name,
uint name_len,
[In] byte[] args,
Expand All @@ -203,7 +200,7 @@ public enum LogLevel : byte
}

[LibraryImport(StdbNamespace)]
public static partial void _console_log(
public static partial void console_log(
LogLevel level,
[In] byte[] target,
uint target_len,
Expand All @@ -215,14 +212,14 @@ uint message_len
);

[LibraryImport(StdbNamespace)]
public static partial Errno _bytes_source_read(
public static partial Errno bytes_source_read(
BytesSource source,
Span<byte> buffer,
ref uint buffer_len
);

[LibraryImport(StdbNamespace)]
public static partial CheckedStatus _bytes_sink_write(
public static partial CheckedStatus bytes_sink_write(
BytesSink sink,
ReadOnlySpan<byte> buffer,
ref uint buffer_len
Expand Down Expand Up @@ -254,8 +251,8 @@ internal static class ConsoleTimerIdMarshaller
}

[LibraryImport(StdbNamespace)]
public static partial ConsoleTimerId _console_timer_start([In] byte[] name, uint name_len);
public static partial ConsoleTimerId console_timer_start([In] byte[] name, uint name_len);

[LibraryImport(StdbNamespace)]
public static partial CheckedStatus _console_timer_end(ConsoleTimerId stopwatch_id);
public static partial CheckedStatus console_timer_end(ConsoleTimerId stopwatch_id);
}
2 changes: 1 addition & 1 deletion crates/bindings-csharp/Runtime/Internal/IReducer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public static void VolatileNonatomicScheduleImmediate(string name, MemoryStream
var name_bytes = Encoding.UTF8.GetBytes(name);
var args_bytes = args.ToArray();

FFI._volatile_nonatomic_schedule_immediate(
FFI.volatile_nonatomic_schedule_immediate(
name_bytes,
(uint)name_bytes.Length,
args_bytes,
Expand Down
16 changes: 8 additions & 8 deletions crates/bindings-csharp/Runtime/Internal/ITable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public bool MoveNext()
while (true)
{
buffer_len = (uint)buffer.Length;
var ret = FFI._row_iter_bsatn_advance(handle, buffer, ref buffer_len);
var ret = FFI.row_iter_bsatn_advance(handle, buffer, ref buffer_len);
if (ret == Errno.EXHAUSTED)
{
handle = FFI.RowIter.INVALID;
Expand Down Expand Up @@ -74,7 +74,7 @@ public void Dispose()
{
if (handle != FFI.RowIter.INVALID)
{
FFI._row_iter_bsatn_close(handle);
FFI.row_iter_bsatn_close(handle);
handle = FFI.RowIter.INVALID;
// Avoid running ~RowIter if Dispose was executed successfully.
GC.SuppressFinalize(this);
Expand Down Expand Up @@ -120,28 +120,28 @@ public IEnumerable<T> Parse()
private class RawTableIter(FFI.TableId tableId) : RawTableIterBase
{
protected override void IterStart(out FFI.RowIter handle) =>
FFI._datastore_table_scan_bsatn(tableId, out handle);
FFI.datastore_table_scan_bsatn(tableId, out handle);
}

private class RawTableIterFiltered(FFI.TableId tableId, byte[] filterBytes) : RawTableIterBase
{
protected override void IterStart(out FFI.RowIter handle) =>
FFI._iter_start_filtered(tableId, filterBytes, (uint)filterBytes.Length, out handle);
FFI.iter_start_filtered(tableId, filterBytes, (uint)filterBytes.Length, out handle);
}

private class RawTableIterByColEq(FFI.TableId tableId, FFI.ColId colId, byte[] value)
: RawTableIterBase
{
protected override void IterStart(out FFI.RowIter handle) =>
FFI._iter_by_col_eq(tableId, colId, value, (uint)value.Length, out handle);
FFI.iter_by_col_eq(tableId, colId, value, (uint)value.Length, out handle);
}

// Note: this must be Lazy to ensure that we don't try to get the tableId during startup, before the module is initialized.
private static readonly Lazy<FFI.TableId> tableId_ =
new(() =>
{
var name_bytes = System.Text.Encoding.UTF8.GetBytes(typeof(View).Name);
FFI._table_id_from_name(name_bytes, (uint)name_bytes.Length, out var out_);
FFI.table_id_from_name(name_bytes, (uint)name_bytes.Length, out var out_);
return out_;
});

Expand All @@ -159,7 +159,7 @@ protected static T Insert(T row)
// Insert the row.
var bytes = IStructuralReadWrite.ToBytes(row);
var bytes_len = (uint)bytes.Length;
FFI._datastore_insert_bsatn(tableId, bytes, ref bytes_len);
FFI.datastore_insert_bsatn(tableId, bytes, ref bytes_len);

// Write back any generated column values.
using var stream = new MemoryStream(bytes, 0, (int)bytes_len);
Expand Down Expand Up @@ -190,7 +190,7 @@ public static ColEq Where<TCol, TColRW>(ushort colId, TCol colValue, TColRW rw)

public bool Delete()
{
FFI._delete_by_col_eq(tableId, colId, value, (uint)value.Length, out var out_);
FFI.delete_by_col_eq(tableId, colId, value, (uint)value.Length, out var out_);
return out_ > 0;
}

Expand Down
4 changes: 2 additions & 2 deletions crates/bindings-csharp/Runtime/Internal/Module.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ private static byte[] Consume(this BytesSource source)
// Write into the spare capacity of the buffer.
var spare = buffer.AsSpan((int)written);
var buf_len = (uint)spare.Length;
var ret = FFI._bytes_source_read(source, spare, ref buf_len);
var ret = FFI.bytes_source_read(source, spare, ref buf_len);
written += buf_len;
switch (ret)
{
Expand Down Expand Up @@ -155,7 +155,7 @@ private static void Write(this BytesSink sink, byte[] bytes)
{
var written = (uint)bytes.Length;
var buffer = bytes.AsSpan((int)start);
FFI._bytes_sink_write(sink, buffer, ref written);
FFI.bytes_sink_write(sink, buffer, ref written);
start += written;
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/bindings-csharp/Runtime/Log.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ uint lineNumber
var filename_bytes = Encoding.UTF8.GetBytes(filename);
var text_bytes = Encoding.UTF8.GetBytes(text);

FFI._console_log(
FFI.console_log(
level,
target_bytes,
(uint)target_bytes.Length,
Expand Down
4 changes: 2 additions & 2 deletions crates/bindings-csharp/Runtime/LogStopwatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public sealed class LogStopwatch : IDisposable
public LogStopwatch(string name)
{
var name_bytes = Encoding.UTF8.GetBytes(name);
StopwatchId = FFI._console_timer_start(name_bytes, (uint)name_bytes.Length);
StopwatchId = FFI.console_timer_start(name_bytes, (uint)name_bytes.Length);
}

void IDisposable.Dispose()
Expand All @@ -24,7 +24,7 @@ void IDisposable.Dispose()

public void End()
{
FFI._console_timer_end(StopwatchId);
FFI.console_timer_end(StopwatchId);
WasStopped = true;
}
}
34 changes: 17 additions & 17 deletions crates/bindings-csharp/Runtime/bindings.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,54 +36,54 @@ OPAQUE_TYPEDEF(ConsoleTimerId, uint32_t);
#define IMPORT(ret, name, params, args) STDB_EXTERN(name) ret name params;
#endif

IMPORT(void, _console_log,
IMPORT(void, console_log,
(LogLevel level, const uint8_t* target_ptr, uint32_t target_len,
const uint8_t* filename_ptr, uint32_t filename_len, uint32_t line_number,
const uint8_t* message_ptr, uint32_t message_len),
(level, target_ptr, target_len, filename_ptr, filename_len, line_number,
message_ptr, message_len));

IMPORT(Status, _table_id_from_name,
IMPORT(Status, table_id_from_name,
(const uint8_t* name, uint32_t name_len, TableId* id),
(name, name_len, id));
IMPORT(Status, _datastore_table_row_count,
IMPORT(Status, datastore_table_row_count,
(TableId table_id, uint64_t* count),
(table_id, count));
IMPORT(Status, _datastore_table_scan_bsatn, (TableId table_id, RowIter* iter),
IMPORT(Status, datastore_table_scan_bsatn, (TableId table_id, RowIter* iter),
(table_id, iter));
IMPORT(Status, _iter_by_col_eq,
IMPORT(Status, iter_by_col_eq,
(TableId table_id, ColId col_id, const uint8_t* value,
uint32_t value_len, RowIter* iter),
(table_id, col_id, value, value_len, iter));
IMPORT(Status, _datastore_insert_bsatn, (TableId table_id, const uint8_t* row_ptr, size_t* row_len_ptr),
IMPORT(Status, datastore_insert_bsatn, (TableId table_id, const uint8_t* row_ptr, size_t* row_len_ptr),
(table_id, row_ptr, row_len_ptr));
IMPORT(Status, _delete_by_col_eq,
IMPORT(Status, delete_by_col_eq,
(TableId table_id, ColId col_id, const uint8_t* value,
uint32_t value_len, uint32_t* num_deleted),
(table_id, col_id, value, value_len, num_deleted));
IMPORT(Status, _iter_start_filtered,
IMPORT(Status, iter_start_filtered,
(TableId table_id, const uint8_t* filter, uint32_t filter_len,
RowIter* iter),
(table_id, filter, filter_len, iter));
IMPORT(int16_t, _row_iter_bsatn_advance,
IMPORT(int16_t, row_iter_bsatn_advance,
(RowIter iter, uint8_t* buffer_ptr, size_t* buffer_len_ptr),
(iter, buffer_ptr, buffer_len_ptr));
IMPORT(uint16_t, _row_iter_bsatn_close, (RowIter iter), (iter));
IMPORT(Status, _datastore_delete_all_by_eq_bsatn,
IMPORT(uint16_t, row_iter_bsatn_close, (RowIter iter), (iter));
IMPORT(Status, datastore_delete_all_by_eq_bsatn,
(TableId table_id, const uint8_t* rel_ptr, uint32_t rel_len,
uint32_t* num_deleted),
(table_id, rel_ptr, rel_len, num_deleted));
IMPORT(void, _volatile_nonatomic_schedule_immediate,
IMPORT(void, volatile_nonatomic_schedule_immediate,
(const uint8_t* name, size_t name_len, const uint8_t* args, size_t args_len),
(name, name_len, args, args_len));
IMPORT(int16_t, _bytes_source_read, (BytesSource source, uint8_t* buffer_ptr, size_t* buffer_len_ptr),
IMPORT(int16_t, bytes_source_read, (BytesSource source, uint8_t* buffer_ptr, size_t* buffer_len_ptr),
(source, buffer_ptr, buffer_len_ptr));
IMPORT(uint16_t, _bytes_sink_write, (BytesSink sink, const uint8_t* buffer_ptr, size_t* buffer_len_ptr),
IMPORT(uint16_t, bytes_sink_write, (BytesSink sink, const uint8_t* buffer_ptr, size_t* buffer_len_ptr),
(sink, buffer_ptr, buffer_len_ptr));
IMPORT(ConsoleTimerId, _console_timer_start,
IMPORT(ConsoleTimerId, console_timer_start,
(const uint8_t* name, size_t name_len),
(name, name_len));
IMPORT(Status, _console_timer_end,
IMPORT(Status, console_timer_end,
(ConsoleTimerId stopwatch_id),
(stopwatch_id));

Expand Down Expand Up @@ -236,7 +236,7 @@ int32_t WASI_NAME(fd_write)(__wasi_fd_t fd, const __wasi_ciovec_t* iovs,
// Note: this will produce ugly broken output, but there's not much we can
// do about it until we have proper line-buffered WASI writer in the core.
// It's better than nothing though.
_console_log((LogLevel){fd == STDERR_FILENO ? /*WARN*/ 1 : /*INFO*/
console_log((LogLevel){fd == STDERR_FILENO ? /*WARN*/ 1 : /*INFO*/
2},
CSTR("wasi"), CSTR(__FILE__), __LINE__, iovs[i].buf,
iovs[i].buf_len);
Expand Down
26 changes: 13 additions & 13 deletions crates/bindings-csharp/Runtime/build/SpacetimeDB.Runtime.targets
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
<ItemGroup Condition="'$(EXPERIMENTAL_WASM_AOT)' == '1'">
<NativeLibrary Include="$(MSBuildThisFileDirectory)..\bindings.c" />
<UnmanagedEntryPointsAssembly Include="SpacetimeDB.Runtime" />
<WasmImport Include="$(SpacetimeNamespace)!_iter_by_col_eq" />
<WasmImport Include="$(SpacetimeNamespace)!_delete_by_col_eq" />
<WasmImport Include="$(SpacetimeNamespace)!_iter_start_filtered" />
<WasmImport Include="$(SpacetimeNamespace)!_table_id_from_name" />
<WasmImport Include="$(SpacetimeNamespace)!_datastore_table_row_count" />
<WasmImport Include="$(SpacetimeNamespace)!_datastore_table_scan_bsatn" />
<WasmImport Include="$(SpacetimeNamespace)!_row_iter_bsatn_advance" />
<WasmImport Include="$(SpacetimeNamespace)!_row_iter_bsatn_close" />
<WasmImport Include="$(SpacetimeNamespace)!_datastore_insert_bsatn" />
<WasmImport Include="$(SpacetimeNamespace)!_datastore_delete_all_by_eq_bsatn" />
<WasmImport Include="$(SpacetimeNamespace)!_bytes_source_read" />
<WasmImport Include="$(SpacetimeNamespace)!_bytes_sink_write" />
<WasmImport Include="$(SpacetimeNamespace)!_console_log" />
<WasmImport Include="$(SpacetimeNamespace)!iter_by_col_eq" />
<WasmImport Include="$(SpacetimeNamespace)!delete_by_col_eq" />
<WasmImport Include="$(SpacetimeNamespace)!iter_start_filtered" />
<WasmImport Include="$(SpacetimeNamespace)!table_id_from_name" />
<WasmImport Include="$(SpacetimeNamespace)!datastore_table_row_count" />
<WasmImport Include="$(SpacetimeNamespace)!datastore_table_scan_bsatn" />
<WasmImport Include="$(SpacetimeNamespace)!row_iter_bsatn_advance" />
<WasmImport Include="$(SpacetimeNamespace)!row_iter_bsatn_close" />
<WasmImport Include="$(SpacetimeNamespace)!datastore_insert_bsatn" />
<WasmImport Include="$(SpacetimeNamespace)!datastore_delete_all_by_eq_bsatn" />
<WasmImport Include="$(SpacetimeNamespace)!bytes_source_read" />
<WasmImport Include="$(SpacetimeNamespace)!bytes_sink_write" />
<WasmImport Include="$(SpacetimeNamespace)!console_log" />

<PackageReference Include="Microsoft.DotNet.ILCompiler.LLVM" Version="8.0.0-*" />
<PackageReference Include="runtime.win-x64.Microsoft.DotNet.ILCompiler.LLVM" Version="8.0.0-*" />
Expand Down
Loading

2 comments on commit ccd7e84

@github-actions
Copy link

@github-actions github-actions bot commented on ccd7e84 Sep 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Callgrind benchmark results

Callgrind Benchmark Report

These benchmarks were run using callgrind,
an instruction-level profiler. They allow comparisons between sqlite (sqlite), SpacetimeDB running through a module (stdb_module), and the underlying SpacetimeDB data storage engine (stdb_raw). Callgrind emulates a CPU to collect the below estimates.

Measurement changes larger than five percent are in bold.

In-memory benchmarks

callgrind: empty transaction

db total reads + writes old total reads + writes Δrw estimated cycles old estimated cycles Δcycles
stdb_raw 5411 5411 0.00% 5453 5453 0.00%
sqlite 5555 5555 0.00% 5965 5965 0.00%

callgrind: filter

db schema indices count preload _column data_type total reads + writes old total reads + writes Δrw estimated cycles old estimated cycles Δcycles
stdb_raw u32_u64_str no_index 64 128 2 string 117813 117813 0.00% 118289 118289 0.00%
stdb_raw u32_u64_str no_index 64 128 1 u64 75401 75401 0.00% 75849 75853 -0.01%
stdb_raw u32_u64_str btree_each_column 64 128 2 string 24069 24069 0.00% 24485 24489 -0.02%
stdb_raw u32_u64_str btree_each_column 64 128 1 u64 23036 23036 0.00% 23376 23376 0.00%
sqlite u32_u64_str no_index 64 128 2 string 144678 144678 0.00% 146144 146144 0.00%
sqlite u32_u64_str no_index 64 128 1 u64 124027 124027 0.00% 125249 125245 0.00%
sqlite u32_u64_str btree_each_column 64 128 2 string 134477 134477 0.00% 136203 136203 0.00%
sqlite u32_u64_str btree_each_column 64 128 1 u64 131344 131344 0.00% 132914 132914 0.00%

callgrind: insert bulk

db schema indices count preload total reads + writes old total reads + writes Δrw estimated cycles old estimated cycles Δcycles
stdb_raw u32_u64_str unique_0 64 128 905308 905202 0.01% 958258 958160 0.01%
stdb_raw u32_u64_str btree_each_column 64 128 1054689 1054256 0.04% 1125033 1124584 0.04%
sqlite u32_u64_str unique_0 64 128 398292 398292 0.00% 417288 417280 0.00%
sqlite u32_u64_str btree_each_column 64 128 983609 983609 0.00% 1021809 1021789 0.00%

callgrind: iterate

db schema indices count total reads + writes old total reads + writes Δrw estimated cycles old estimated cycles Δcycles
stdb_raw u32_u64_str unique_0 1024 152697 152697 0.00% 152735 152735 0.00%
stdb_raw u32_u64_str unique_0 64 15722 15722 0.00% 15756 15756 0.00%
sqlite u32_u64_str unique_0 1024 1068223 1068223 0.00% 1071495 1071495 0.00%
sqlite u32_u64_str unique_0 64 76209 76209 0.00% 77263 77263 0.00%

callgrind: serialize_product_value

count format total reads + writes old total reads + writes Δrw estimated cycles old estimated cycles Δcycles
64 json 47118 47118 0.00% 49770 49770 0.00%
64 bsatn 25716 25716 0.00% 27994 27994 0.00%
16 json 12062 12062 0.00% 13966 13966 0.00%
16 bsatn 8117 8117 0.00% 9477 9477 0.00%

callgrind: update bulk

db schema indices count preload total reads + writes old total reads + writes Δrw estimated cycles old estimated cycles Δcycles
stdb_raw u32_u64_str unique_0 1024 1024 20715351 20755354 -0.19% 21316081 21352856 -0.17%
stdb_raw u32_u64_str unique_0 64 128 1308206 1310698 -0.19% 1381042 1384234 -0.23%
sqlite u32_u64_str unique_0 1024 1024 1801983 1801983 0.00% 1811077 1811077 0.00%
sqlite u32_u64_str unique_0 64 128 128329 128329 0.00% 131247 131247 0.00%
On-disk benchmarks

callgrind: empty transaction

db total reads + writes old total reads + writes Δrw estimated cycles old estimated cycles Δcycles
stdb_raw 5421 5421 0.00% 5467 5467 0.00%
sqlite 5597 5597 0.00% 6071 6071 0.00%

callgrind: filter

db schema indices count preload _column data_type total reads + writes old total reads + writes Δrw estimated cycles old estimated cycles Δcycles
stdb_raw u32_u64_str no_index 64 128 2 string 118933 117823 0.94% 119425 118279 0.97%
stdb_raw u32_u64_str no_index 64 128 1 u64 75411 75411 0.00% 75855 75855 0.00%
stdb_raw u32_u64_str btree_each_column 64 128 2 string 24079 24084 -0.02% 24495 24500 -0.02%
stdb_raw u32_u64_str btree_each_column 64 128 1 u64 23046 23046 0.00% 23378 23378 0.00%
sqlite u32_u64_str no_index 64 128 2 string 146599 146599 0.00% 148385 148385 0.00%
sqlite u32_u64_str no_index 64 128 1 u64 125948 125948 0.00% 127534 127534 0.00%
sqlite u32_u64_str btree_each_column 64 128 2 string 136599 136599 0.00% 138835 138835 0.00%
sqlite u32_u64_str btree_each_column 64 128 1 u64 133440 133458 -0.01% 135488 135522 -0.03%

callgrind: insert bulk

db schema indices count preload total reads + writes old total reads + writes Δrw estimated cycles old estimated cycles Δcycles
stdb_raw u32_u64_str unique_0 64 128 855024 854378 0.08% 907340 906534 0.09%
stdb_raw u32_u64_str btree_each_column 64 128 1007022 1005217 0.18% 1077736 1076055 0.16%
sqlite u32_u64_str unique_0 64 128 415829 415829 0.00% 434073 434073 0.00%
sqlite u32_u64_str btree_each_column 64 128 1021870 1021870 0.00% 1059672 1059672 0.00%

callgrind: iterate

db schema indices count total reads + writes old total reads + writes Δrw estimated cycles old estimated cycles Δcycles
stdb_raw u32_u64_str unique_0 1024 152707 152707 0.00% 152741 152741 0.00%
stdb_raw u32_u64_str unique_0 64 15732 15732 0.00% 15766 15766 0.00%
sqlite u32_u64_str unique_0 1024 1071291 1071291 0.00% 1074861 1074861 0.00%
sqlite u32_u64_str unique_0 64 77981 77981 0.00% 79247 79247 0.00%

callgrind: serialize_product_value

count format total reads + writes old total reads + writes Δrw estimated cycles old estimated cycles Δcycles
64 json 47118 47118 0.00% 49770 49770 0.00%
64 bsatn 25716 25716 0.00% 27994 27994 0.00%
16 json 12062 12062 0.00% 13966 13966 0.00%
16 bsatn 8117 8117 0.00% 9477 9477 0.00%

callgrind: update bulk

db schema indices count preload total reads + writes old total reads + writes Δrw estimated cycles old estimated cycles Δcycles
stdb_raw u32_u64_str unique_0 1024 1024 19458524 19457529 0.01% 20128178 20128309 -0.00%
stdb_raw u32_u64_str unique_0 64 128 1262220 1262409 -0.01% 1334530 1334733 -0.02%
sqlite u32_u64_str unique_0 1024 1024 1809556 1809538 0.00% 1818292 1818266 0.00%
sqlite u32_u64_str unique_0 64 128 132449 132449 0.00% 135457 135457 0.00%

@github-actions
Copy link

@github-actions github-actions bot commented on ccd7e84 Sep 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Criterion benchmark results

Criterion benchmark report

YOU SHOULD PROBABLY IGNORE THESE RESULTS.

Criterion is a wall time based benchmarking system that is extremely noisy when run on CI. We collect these results for longitudinal analysis, but they are not reliable for comparing individual PRs.

Go look at the callgrind report instead.

empty

db on disk new latency old latency new throughput old throughput
sqlite 💿 408.0±3.04ns 406.0±3.97ns - -
sqlite 🧠 403.2±5.42ns 403.2±2.15ns - -
stdb_raw 💿 625.5±0.54ns 624.9±0.85ns - -
stdb_raw 🧠 626.6±0.70ns 625.7±1.17ns - -

insert_1

db on disk schema indices preload new latency old latency new throughput old throughput

insert_bulk

db on disk schema indices preload count new latency old latency new throughput old throughput
sqlite 💿 u32_u64_str btree_each_column 2048 256 581.7±0.51µs 586.0±0.74µs 1719 tx/sec 1706 tx/sec
sqlite 💿 u32_u64_str unique_0 2048 256 148.3±0.40µs 150.3±0.78µs 6.6 Ktx/sec 6.5 Ktx/sec
sqlite 💿 u32_u64_u64 btree_each_column 2048 256 470.3±0.68µs 473.2±23.13µs 2.1 Ktx/sec 2.1 Ktx/sec
sqlite 💿 u32_u64_u64 unique_0 2048 256 134.5±0.23µs 134.5±0.26µs 7.3 Ktx/sec 7.3 Ktx/sec
sqlite 🧠 u32_u64_str btree_each_column 2048 256 443.6±0.98µs 449.2±1.30µs 2.2 Ktx/sec 2.2 Ktx/sec
sqlite 🧠 u32_u64_str unique_0 2048 256 120.6±0.71µs 125.2±0.38µs 8.1 Ktx/sec 7.8 Ktx/sec
sqlite 🧠 u32_u64_u64 btree_each_column 2048 256 364.8±0.46µs 365.1±0.25µs 2.7 Ktx/sec 2.7 Ktx/sec
sqlite 🧠 u32_u64_u64 unique_0 2048 256 103.9±0.52µs 103.1±0.19µs 9.4 Ktx/sec 9.5 Ktx/sec
stdb_raw 💿 u32_u64_str btree_each_column 2048 256 586.7±18.36µs 604.6±19.41µs 1704 tx/sec 1653 tx/sec
stdb_raw 💿 u32_u64_str unique_0 2048 256 424.8±15.18µs 425.8±19.43µs 2.3 Ktx/sec 2.3 Ktx/sec
stdb_raw 💿 u32_u64_u64 btree_each_column 2048 256 381.0±4.95µs 337.3±3.84µs 2.6 Ktx/sec 2.9 Ktx/sec
stdb_raw 💿 u32_u64_u64 unique_0 2048 256 352.4±9.75µs 338.2±20.04µs 2.8 Ktx/sec 2.9 Ktx/sec
stdb_raw 🧠 u32_u64_str btree_each_column 2048 256 306.7±0.31µs 307.3±0.37µs 3.2 Ktx/sec 3.2 Ktx/sec
stdb_raw 🧠 u32_u64_str unique_0 2048 256 241.1±0.15µs 241.1±0.12µs 4.1 Ktx/sec 4.0 Ktx/sec
stdb_raw 🧠 u32_u64_u64 btree_each_column 2048 256 245.6±0.25µs 245.0±0.09µs 4.0 Ktx/sec 4.0 Ktx/sec
stdb_raw 🧠 u32_u64_u64 unique_0 2048 256 219.8±0.26µs 221.1±0.24µs 4.4 Ktx/sec 4.4 Ktx/sec

iterate

db on disk schema indices new latency old latency new throughput old throughput
sqlite 💿 u32_u64_str unique_0 23.0±0.10µs 22.6±0.21µs 42.5 Ktx/sec 43.1 Ktx/sec
sqlite 💿 u32_u64_u64 unique_0 21.2±0.06µs 21.2±0.28µs 46.0 Ktx/sec 46.0 Ktx/sec
sqlite 🧠 u32_u64_str unique_0 20.0±0.24µs 20.5±0.22µs 48.9 Ktx/sec 47.7 Ktx/sec
sqlite 🧠 u32_u64_u64 unique_0 18.4±0.09µs 18.4±0.20µs 53.2 Ktx/sec 53.0 Ktx/sec
stdb_raw 💿 u32_u64_str unique_0 4.7±0.00µs 4.7±0.00µs 206.1 Ktx/sec 206.2 Ktx/sec
stdb_raw 💿 u32_u64_u64 unique_0 4.6±0.00µs 4.6±0.00µs 211.2 Ktx/sec 211.3 Ktx/sec
stdb_raw 🧠 u32_u64_str unique_0 4.7±0.00µs 4.7±0.00µs 206.2 Ktx/sec 206.3 Ktx/sec
stdb_raw 🧠 u32_u64_u64 unique_0 4.6±0.00µs 4.6±0.00µs 211.0 Ktx/sec 211.1 Ktx/sec

find_unique

db on disk key type preload new latency old latency new throughput old throughput

filter

db on disk key type index strategy load count new latency old latency new throughput old throughput
sqlite 💿 string index 2048 256 69.2±0.13µs 68.8±0.30µs 14.1 Ktx/sec 14.2 Ktx/sec
sqlite 💿 u64 index 2048 256 65.0±0.16µs 65.6±0.08µs 15.0 Ktx/sec 14.9 Ktx/sec
sqlite 🧠 string index 2048 256 65.4±0.32µs 65.2±0.13µs 14.9 Ktx/sec 15.0 Ktx/sec
sqlite 🧠 u64 index 2048 256 59.9±0.06µs 60.8±0.12µs 16.3 Ktx/sec 16.1 Ktx/sec
stdb_raw 💿 string index 2048 256 4.8±0.00µs 4.8±0.00µs 201.9 Ktx/sec 201.8 Ktx/sec
stdb_raw 💿 u64 index 2048 256 4.8±0.00µs 4.8±0.00µs 201.5 Ktx/sec 201.8 Ktx/sec
stdb_raw 🧠 string index 2048 256 4.8±0.00µs 4.8±0.00µs 201.8 Ktx/sec 201.7 Ktx/sec
stdb_raw 🧠 u64 index 2048 256 4.8±0.00µs 4.8±0.00µs 201.7 Ktx/sec 202.0 Ktx/sec

serialize

schema format count new latency old latency new throughput old throughput
u32_u64_str bflatn_to_bsatn_fast_path 100 3.3±0.01µs 3.3±0.02µs 29.3 Mtx/sec 29.0 Mtx/sec
u32_u64_str bflatn_to_bsatn_slow_path 100 3.4±0.00µs 3.4±0.01µs 28.3 Mtx/sec 28.3 Mtx/sec
u32_u64_str bsatn 100 2.4±0.00µs 2.4±0.02µs 39.8 Mtx/sec 39.4 Mtx/sec
u32_u64_str bsatn 100 40.3±0.19ns 40.2±0.11ns 2.3 Gtx/sec 2.3 Gtx/sec
u32_u64_str json 100 4.8±0.05µs 4.9±0.05µs 20.0 Mtx/sec 19.6 Mtx/sec
u32_u64_str json 100 7.5±0.05µs 7.5±0.02µs 12.7 Mtx/sec 12.7 Mtx/sec
u32_u64_str product_value 100 1019.5±0.70ns 1017.2±0.57ns 93.5 Mtx/sec 93.8 Mtx/sec
u32_u64_u64 bflatn_to_bsatn_fast_path 100 1104.9±17.84ns 1221.1±16.23ns 86.3 Mtx/sec 78.1 Mtx/sec
u32_u64_u64 bflatn_to_bsatn_slow_path 100 2.8±0.00µs 2.8±0.00µs 34.3 Mtx/sec 34.4 Mtx/sec
u32_u64_u64 bsatn 100 1710.4±34.66ns 1825.5±29.92ns 55.8 Mtx/sec 52.2 Mtx/sec
u32_u64_u64 bsatn 100 39.3±0.12ns 29.0±0.16ns 2.4 Gtx/sec 3.2 Gtx/sec
u32_u64_u64 json 100 3.2±0.03µs 3.0±0.01µs 29.4 Mtx/sec 31.6 Mtx/sec
u32_u64_u64 json 100 5.3±0.08µs 5.4±0.01µs 18.1 Mtx/sec 17.7 Mtx/sec
u32_u64_u64 product_value 100 1015.8±1.70ns 1013.7±1.54ns 93.9 Mtx/sec 94.1 Mtx/sec
u64_u64_u32 bflatn_to_bsatn_fast_path 100 891.5±1.27ns 901.3±1.03ns 107.0 Mtx/sec 105.8 Mtx/sec
u64_u64_u32 bflatn_to_bsatn_slow_path 100 2.8±0.00µs 2.8±0.00µs 34.2 Mtx/sec 34.4 Mtx/sec
u64_u64_u32 bsatn 100 1697.4±32.92ns 1717.2±29.84ns 56.2 Mtx/sec 55.5 Mtx/sec
u64_u64_u32 bsatn 100 753.1±0.53ns 751.8±0.34ns 126.6 Mtx/sec 126.9 Mtx/sec
u64_u64_u32 json 100 3.2±0.03µs 3.0±0.02µs 30.0 Mtx/sec 31.3 Mtx/sec
u64_u64_u32 json 100 5.1±0.04µs 5.0±0.06µs 18.8 Mtx/sec 19.0 Mtx/sec
u64_u64_u32 product_value 100 1017.5±0.72ns 1015.0±0.71ns 93.7 Mtx/sec 94.0 Mtx/sec

stdb_module_large_arguments

arg size new latency old latency new throughput old throughput
64KiB 113.2±5.17µs 114.5±6.95µs - -

stdb_module_print_bulk

line count new latency old latency new throughput old throughput
1 52.9±6.65µs 53.1±5.42µs - -
100 597.7±7.06µs 591.7±6.52µs - -
1000 3.9±0.77ms 5.1±0.51ms - -

remaining

name new latency old latency new throughput old throughput
special/db_game/circles/load=10 284.5±2.59µs 285.0±1.89µs - -
special/db_game/circles/load=100 286.2±2.90µs 281.5±4.56µs - -
special/db_game/ia_loop/load=10 0.0±0.00ns 0.0±0.00ns - -
special/db_game/ia_loop/load=100 0.0±0.00ns 0.0±0.00ns - -
sqlite/💿/update_bulk/u32_u64_str/unique_0/load=2048/count=256 54.9±0.20µs 53.7±0.10µs 17.8 Ktx/sec 18.2 Ktx/sec
sqlite/💿/update_bulk/u32_u64_u64/unique_0/load=2048/count=256 46.5±0.09µs 45.9±0.16µs 21.0 Ktx/sec 21.3 Ktx/sec
sqlite/🧠/update_bulk/u32_u64_str/unique_0/load=2048/count=256 39.9±0.31µs 39.2±0.22µs 24.5 Ktx/sec 24.9 Ktx/sec
sqlite/🧠/update_bulk/u32_u64_u64/unique_0/load=2048/count=256 35.4±0.07µs 35.5±0.24µs 27.6 Ktx/sec 27.5 Ktx/sec
stdb_module/💿/update_bulk/u32_u64_str/unique_0/load=2048/count=256 1263.4±19.06µs 1251.8±5.79µs 791 tx/sec 798 tx/sec
stdb_module/💿/update_bulk/u32_u64_u64/unique_0/load=2048/count=256 980.8±10.50µs 979.6±4.93µs 1019 tx/sec 1020 tx/sec
stdb_raw/💿/update_bulk/u32_u64_str/unique_0/load=2048/count=256 648.9±36.08µs 642.2±23.40µs 1541 tx/sec 1557 tx/sec
stdb_raw/💿/update_bulk/u32_u64_u64/unique_0/load=2048/count=256 493.1±7.46µs 488.6±9.64µs 2028 tx/sec 2046 tx/sec
stdb_raw/🧠/update_bulk/u32_u64_str/unique_0/load=2048/count=256 381.5±0.54µs 379.5±0.38µs 2.6 Ktx/sec 2.6 Ktx/sec
stdb_raw/🧠/update_bulk/u32_u64_u64/unique_0/load=2048/count=256 345.4±0.76µs 344.7±0.30µs 2.8 Ktx/sec 2.8 Ktx/sec

Please sign in to comment.