Skip to content

Conversation

@ZenasSong
Copy link

The thread stack size could be critical on mobile devices. Adding the param thread_stack_size could be more flexible, especially for building a mobile application.

Does your PR solve an issue?

Delete this text and add "fixes #(issue number)".

Do not just list issue numbers here as they will not be automatically closed on merging this pull request unless prefixed with "fixes" or "closes".

Is this a breaking change?

Delete this text and answer yes/no and explain.

If yes, this pull request will need to wait for the next major release (0.{x + 1}.0)

Behavior changes can be breaking if significant enough.
Consider Hyrum's Law:

With a sufficient number of users of an API,
it does not matter what you promise in the contract:
all observable behaviors of your system
will be depended on by somebody.

// Soft limit on the number of rows that `ANALYZE` touches per index.
pragmas.insert("analysis_limit".into(),None);

let default_thread_stack_size = 512*1024;// 512KB
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not comfortable making the default stack size this small. Because we invoke user-supplied callbacks from the worker thread, it's impossible to say what a safe minimum stack size is besides the current default.

Additionally, there's no leeway for platform-specific requirements. 64-bit platforms are going to need more stack size than 32-bit platforms because the size of pointers and usize/isize values is doubled.

This should be Option<usize> and default to not specifying a stack size and just letting the std choose.

Copy link
Author

@ZenasSongZenasSongAug 22, 2025

Choose a reason for hiding this comment

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

Agree with you, I'll post a new PR!

@abonander
Copy link
Collaborator

Closing due to inactivity and unaddressed feedback. Feel free to open a new PR after addressing the comment.

ZenasSong added a commit to ZenasSong/sqlx that referenced this pull request Nov 1, 2025
Changes `thread_stack_size` from `usize` to `Option<usize>` to address concerns about safety and platform compatibility. Key improvements: - Default to `None`, using Rust std's default stack size (typically 2MB) - Only apply custom stack size when explicitly configured - Safer for user callbacks with unpredictable stack requirements - Platform-agnostic (handles 32-bit vs 64-bit differences automatically) - Marked as an advanced option in documentation with appropriate warnings This addresses the feedback from PR launchbadge#3885 about hardcoded stack sizes being unsafe due to: 1. Unpredictable stack needs of user-supplied callbacks 2. Platform-specific requirements (32-bit vs 64-bit) 3. Need for conservative defaults Related: launchbadge#3885
Sign up for freeto 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.

2 participants

@ZenasSong@abonander