Skip to content

Commit

Permalink
Commitlog offset index (#1671)
Browse files Browse the repository at this point in the history
Signed-off-by: Shubham Mishra <shubham@clockworklabs.io>
Co-authored-by: Kim Altintop <kim@eagain.io>
  • Loading branch information
Shubham8287 and kim authored Sep 24, 2024
1 parent eadea95 commit eeaa00a
Show file tree
Hide file tree
Showing 14 changed files with 1,828 additions and 999 deletions.
2,182 changes: 1,220 additions & 962 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions crates/bindings/tests/snapshots/deps__duplicate_deps.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
source: crates/bindings/tests/deps.rs
expression: cargo tree -p spacetimedb -e no-dev -d --depth 0
---
syn v1.0.109
heck v0.4.1

syn v2.0.39
heck v0.5.0
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
source: crates/bindings/tests/deps.rs
expression: "cargo tree -p spacetimedb -f {lib} -e no-dev"
---
total crates: 60
total crates: 62
spacetimedb
├── bytemuck
├── derive_more
Expand All @@ -26,6 +26,12 @@ spacetimedb
│ ├── libc
│ ├── rand_chacha
│ │ ├── ppv_lite86
│ │ │ └── zerocopy
│ │ │ ├── byteorder
│ │ │ └── zerocopy_derive
│ │ │ ├── proc_macro2 (*)
│ │ │ ├── quote (*)
│ │ │ └── syn (*)
│ │ └── rand_core
│ │ └── getrandom (*)
│ └── rand_core (*)
Expand All @@ -42,10 +48,7 @@ spacetimedb
│ │ ├── itertools
│ │ │ └── either
│ │ └── nohash_hasher
│ └── syn
│ ├── proc_macro2 (*)
│ ├── quote (*)
│ └── unicode_ident
│ └── syn (*)
├── spacetimedb_bindings_sys
│ └── spacetimedb_primitives (*)
├── spacetimedb_lib
Expand All @@ -65,7 +68,7 @@ spacetimedb
│ │ │ ├── ahash
│ │ │ │ ├── cfg_if
│ │ │ │ ├── once_cell
│ │ │ │ └── zerocopy
│ │ │ │ └── zerocopy (*)
│ │ │ │ [build-dependencies]
│ │ │ │ └── version_check
│ │ │ └── allocator_api2
Expand Down
2 changes: 2 additions & 0 deletions crates/commitlog/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ bitflags.workspace = true
crc32c.workspace = true
itertools.workspace = true
log.workspace = true
memmap2 = "0.9.4"
serde = { workspace = true, optional = true }
spacetimedb-primitives.workspace = true
spacetimedb-sats.workspace = true
tempfile.workspace = true
thiserror.workspace = true

[dev-dependencies]
Expand Down
4 changes: 2 additions & 2 deletions crates/commitlog/src/commitlog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,8 @@ impl<R: Repo, T> Generic<R, T> {
} else {
let byte_offset = segment::Header::LEN as u64 + bytes_read;
debug!("truncating segment {segment} to {offset} at {byte_offset}");
let file = self.repo.open_segment(segment)?;
file.ftruncate(byte_offset)?;
let mut file = self.repo.open_segment(segment)?;
file.ftruncate(offset, byte_offset)?;
// Some filesystems require fsync after ftruncate.
file.fsync()?;
break;
Expand Down
Loading

2 comments on commit eeaa00a

@github-actions
Copy link

@github-actions github-actions bot commented on eeaa00a Sep 24, 2024

Choose a reason for hiding this comment

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

Benchmarking failed. Please check the workflow run for details.

@github-actions
Copy link

@github-actions github-actions bot commented on eeaa00a Sep 24, 2024

Choose a reason for hiding this comment

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

Callgrind benchmark results Error when comparing benchmarks:

Caused by:

Please sign in to comment.