Skip to content

build: enable line tables in release builds so backtraces show file:line (#103)#546

Open
LeSingh1 wants to merge 1 commit into
openai:mainfrom
LeSingh1:enable-line-tables-in-release
Open

build: enable line tables in release builds so backtraces show file:line (#103)#546
LeSingh1 wants to merge 1 commit into
openai:mainfrom
LeSingh1:enable-line-tables-in-release

Conversation

@LeSingh1
Copy link
Copy Markdown

Summary

Fixes #103.

Release builds of the tiktoken Rust extension strip all debug info, so panic stack traces surface in Python without any file or line numbers. Adding debug = "line-tables-only" to the release profile keeps just enough DWARF to resolve backtraces to file:line, without the binary-size cost of full debug = true.

[profile.release]
debug = "line-tables-only"

Why line-tables-only and not debug = true?

The reporter's original suggestion was debug = true, and their benchmark in the issue showed no runtime impact. Both options give you the line numbers. line-tables-only (stable since Rust 1.69) is a strict subset that drops variable / type information while keeping .debug_line, so:

  • Backtraces still resolve function_name (path/file.rs:42)
  • Wheel size grows much less than with debug = true
  • No runtime perf change (optimization level is unaffected — the only thing that changes is the size of .debug_* sections, which aren't loaded into memory at runtime)

Happy to switch to debug = true if maintainers prefer it for parity with the original issue.

MSRV check

line-tables-only was stabilized in Rust 1.69 (May 2023). Cargo.toml already declares edition = "2024", which requires Rust 1.85+, so this is well within the existing MSRV.

Verification

  • cargo check --release --all-features passes (only pre-existing pyo3 deprecation warning).

Stack traces from release-built tiktoken wheels do not include file
or line numbers, which makes debugging panics that surface through
the Python extension harder than it needs to be (cf. openai#103).

Set `debug = "line-tables-only"` for the release profile. This adds
just enough DWARF for backtraces to resolve file:line, without the
binary-size cost of full `debug = true`. Optimization level is
unaffected, so the original concern that motivated stripping debug
info — runtime performance — is preserved (the benchmark in openai#103
showed identical throughput before/after enabling debug).
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.

Fix missing line numbers in stack traces

1 participant