Skip to content

Conversation

@hero78119
Copy link
Collaborator

@hero78119 hero78119 commented Dec 24, 2025

Follow up on #1171
replace rkyv with custom serde for 2 reasons

  • serialization to bytes need to implement rkyv friendly struct, or leverage external library, e.g. "rkyv + bincode". rkyv friendly struct is not friendly for existing application in particular struct are defined in 3rd-party library. Thus previously we integrate bincode for the serialiation to bytes. This bring extra effort for guest program as we need bincode to deserialize back to owned struct.
  • in deserialize rkyv will access high addr to retrieve some meta information before sequential read. Below are example read pattern
hint address 28000004
hint address 28000008
hint address 280c8770 <- high addr accessed to fetch meta data
hint address 280c876c
hint address 280c876c
hint address 280c8770
hint address 28000010
hint address 28000010
hint address 28000010
hint address 28000010
hint address 28000014
hint address 28000014
hint address 28000014
...

The high order access not friendly if we want to record max accessed address in each shard for memory region initialized across shard.

New ceno_serde crates credits to https://github.com/openvm-org/openvm/tree/main/crates/toolchain/openvm/src/serde

benchmark

Run on 23817600 with K=6, cache trace = none, 1x4090

Component base Time Init-Across-Shard Time Custom Serde Time Init-Across-Shard Improvement Custom Serde Improvement
app.prove 203 s 175 s 160 s ↓ 13.8% ↓ 21.2%
emulator.preflight-execute 43.9 s 35.8 s 36.6 s ↓ 18.5% ↓ 16.6%
app_prove.inner 158 s 139 s 123 s ↓ 12.0% ↓ 22.2%
create_proof_of_shard (shard_id = 0) 14.9 s 4.91 s 8.46 s ↓ 67.0% ↓ 43.2%
create_proof_of_shard (shard_id = 1) 16.4 s 12.7 s 3.74 s ↓ 22.6% ↓ 77.2%

Overall cycle 322620252 -> 315955342 (2.06%)

Custom Serde updated setting: max cell: (1 << 30) * 8 / 4 / 2 ------> (1 << 30) * 10 / 4 / 2
keccak blowup K=6 unchange

@hero78119 hero78119 force-pushed the feat/hint_region_seq_read branch from 585ecec to 84625fd Compare December 24, 2025 07:03
@hero78119 hero78119 force-pushed the feat/hint_region_seq_read branch from ebff007 to 18cbd19 Compare December 26, 2025 02:24
@hero78119 hero78119 changed the base branch from feat/shard_mem_init to master December 30, 2025 07:46
Copy link
Collaborator

@kunxian-xia kunxian-xia left a comment

Choose a reason for hiding this comment

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

LGTM except one minor issue.

Comment on lines +28 to +34
let mut cursor = len_start;
let data_offset = unsafe { ptr::read(cursor) };
cursor = unsafe { cursor.add(1) };
self.alignment = unsafe { ptr::read(cursor) };
cursor = unsafe { cursor.add(1) };
self.next_len_at = cursor;
self.next_data_at = unsafe { data_start.add(data_offset) };
Copy link
Collaborator

@kunxian-xia kunxian-xia Dec 30, 2025

Choose a reason for hiding this comment

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

nitpick: add a link to the function finalize() in ceno_host/src/lib.rs so that whenever we make any change here, we won't forget to reflect it there.

@hero78119 hero78119 force-pushed the feat/hint_region_seq_read branch from 58bc8d7 to 2e32d99 Compare December 31, 2025 00:32
@hero78119 hero78119 enabled auto-merge December 31, 2025 00:34
@hero78119 hero78119 added this pull request to the merge queue Dec 31, 2025
Merged via the queue into master with commit cff9d41 Dec 31, 2025
4 checks passed
@hero78119 hero78119 deleted the feat/hint_region_seq_read branch December 31, 2025 01:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants