Performance fixture: real-world Rust file pair from vercel/next.js (turbopack/crates/turbo-persistence-tools/src/main.rs, commit 11823f8471cec98a093fd3af6d4193838da0b667) that takes diff_code roughly 5 seconds despite a combined AST size of only 925 nodes and ~2KB per file - one of the most extreme slowdowns found in the benchmark sample (~300x the fitted size/time trend). Captured via research/diff_pairs_benchmark_rust.csv; a strong candidate for profiling diff_code's worst-case behavior.

Code view:

A painting is a person's account of this edit as text, recorded independently of the node mapping - a rendering often has several equally defensible answers where the mapping has one. Deletions and insertions carry no position on the opposite side in a painting, so that panel draws no caret for them.

Before

1#![feature(iter_intersperse)]
2
3use std::path::PathBuf;
4
5use anyhow::{Context, Result, bail};
6use turbo_persistence::{MetaFileEntryInfo, SerialScheduler, TurboPersistence};
7
8fn main() -> Result<()> {
9 // Get CLI argument
10 let path = PathBuf::from(
11 std::env::args()
12 .nth(1)
13 .context("Please provide a path to the TurboPersistence directory")?,
14 );
15 if !path.exists() {
16 bail!("The provided path does not exist: {}", path.display());
17 }
18
19 let db: TurboPersistence<SerialScheduler, 0> = TurboPersistence::open_read_only(path)?;
20 let meta_info = db
21 .meta_info()
22 .context("Failed to retrieve meta information")?;
23 for meta_file in meta_info {
24 println!(
25 "META {:08}.meta: family = {}, sst_size = {} MiB",
…lines 26–67 unchanged (42 lines)

After

1#![feature(iter_intersperse)]
2
3use std::path::PathBuf;
4
5use anyhow::{Context, Result, bail};
6use turbo_persistence::{DbConfig, MetaFileEntryInfo, SerialScheduler, TurboPersistence};
7
8fn main() -> Result<()> {
9 // Get CLI argument
10 let path = PathBuf::from(
11 std::env::args()
12 .nth(1)
13 .context("Please provide a path to the TurboPersistence directory")?,
14 );
15 if !path.exists() {
16 bail!("The provided path does not exist: {}", path.display());
17 }
18
19 let db: TurboPersistence<SerialScheduler, 0> =
20 TurboPersistence::open_read_only_with_config(path, DbConfig::default())?;
21 let meta_info = db
22 .meta_info()
23 .context("Failed to retrieve meta information")?;
24 for meta_file in meta_info {
25 println!(
26 "META {:08}.meta: family = {}, sst_size = {} MiB",
…lines 27–68 unchanged (42 lines)

Before

source_file
inner_attribute_item
# "#"
! "!"
[ "["
attribute
identifier "feature"
token_tree
( "("
identifier "iter_intersperse"
) ")"
] "]"
use_declaration
use "use"
scoped_identifier
scoped_identifier
identifier "std"
:: "::"
identifier "path"
:: "::"
identifier "PathBuf"
; ";"
use_declaration
use "use"
scoped_use_list
identifier "anyhow"
:: "::"
use_list
{ "{"
identifier "Context"
, ","
identifier "Result"
, ","
identifier "bail"
} "}"
; ";"
use_declaration
use "use"
scoped_use_list
identifier "turbo_persistence"
:: "::"
use_list
{ "{"
identifier "MetaFileEntryInfo"
, ","
identifier "SerialScheduler"
, ","
identifier "TurboPersistence"
} "}"
; ";"
function_item
fn "fn"
identifier "main"
parameters
( "("
) ")"
-> "->"
generic_type
type_identifier "Result"
type_arguments
< "<"
unit_type
( "("
) ")"
> ">"
block
{ "{"
line_comment
// "//"
let_declaration (+46 nodes collapsed)
expression_statement (+35 nodes collapsed)
let_declaration
let "let"
identifier "db"
: ":"
generic_type
type_identifier "TurboPersistence"
type_arguments
< "<"
type_identifier "SerialScheduler"
, ","
integer_literal "0"
> ">"
= "="
try_expression
call_expression
scoped_identifier
identifier "TurboPersistence"
:: "::"
identifier "open_read_only"
arguments
( "("
identifier "path"
) ")"
? "?"
; ";"
let_declaration (+26 nodes collapsed)
expression_statement (+247 nodes collapsed)
call_expression
identifier "Ok"
arguments
( "("
unit_expression
( "("
) ")"
) ")"
} "}"

After

source_file
inner_attribute_item
# "#"
! "!"
[ "["
attribute
identifier "feature"
token_tree
( "("
identifier "iter_intersperse"
) ")"
] "]"
use_declaration
use "use"
scoped_identifier
scoped_identifier
identifier "std"
:: "::"
identifier "path"
:: "::"
identifier "PathBuf"
; ";"
use_declaration
use "use"
scoped_use_list
identifier "anyhow"
:: "::"
use_list
{ "{"
identifier "Context"
, ","
identifier "Result"
, ","
identifier "bail"
} "}"
; ";"
use_declaration
use "use"
scoped_use_list
identifier "turbo_persistence"
:: "::"
use_list
{ "{"
identifier "DbConfig"
, ","
identifier "MetaFileEntryInfo"
, ","
identifier "SerialScheduler"
, ","
identifier "TurboPersistence"
} "}"
; ";"
function_item
fn "fn"
identifier "main"
parameters
( "("
) ")"
-> "->"
generic_type
type_identifier "Result"
type_arguments
< "<"
unit_type
( "("
) ")"
> ">"
block
{ "{"
line_comment
// "//"
let_declaration (+46 nodes collapsed)
expression_statement (+35 nodes collapsed)
let_declaration
let "let"
identifier "db"
: ":"
generic_type
type_identifier "TurboPersistence"
type_arguments
< "<"
type_identifier "SerialScheduler"
, ","
integer_literal "0"
> ">"
= "="
try_expression
call_expression
scoped_identifier
identifier "TurboPersistence"
:: "::"
identifier "open_read_only_with_config"
arguments
( "("
identifier "path"
, ","
call_expression
scoped_identifier
identifier "DbConfig"
:: "::"
identifier "default"
arguments
( "("
) ")"
) ")"
? "?"
; ";"
let_declaration (+26 nodes collapsed)
expression_statement (+247 nodes collapsed)
call_expression
identifier "Ok"
arguments
( "("
unit_expression
( "("
) ")"
) ")"
} "}"