Skip to content

GH-33807: [R] Add a message if we detect running under emulation - #37777

Merged
jonkeane merged 5 commits into
apache:mainfrom
jonkeane:detect_emulated_macos
Sep 19, 2023
Merged

jonkeane merged 5 commits into
apache:mainfrom
jonkeane:detect_emulated_macos

Conversation

@jonkeane

@jonkeane jonkeane commented Sep 18, 2023 •

Copy link
Copy Markdown
Member

Resolves #33807 and #37034

Rationale for this change

If someone is running R under emulation, arrow segfaults without error. We can detect this when we load so can also warn people that this is not recommended. Though the version of R being run is not directly an arrow issue, arrow fails very quickly in this configuration.

What changes are included in this PR?

Detect when running under rosetta (on macOS only) and warn when the library is attached

Are these changes tested?

No, given the paucity of ARM-based mac CI, testing this organically would be difficult. But the logic is straightforward.

Are there any user-facing changes?

Yes, a warning when someone loads arrow under emulation.

@github-actions

Copy link
Copy Markdown

⚠️ GitHub issue #37760 has been automatically assigned in GitHub to PR creator.

Comment thread r/R/arrow-package.R Outdated
# On MacOS only, Check if we are running in under emulation, and warn this will not work
rosetta <- identical(sysname, "darwin") && identical(system("sysctl -n sysctl.proc_translated", intern = TRUE), "1")
if (rosetta) {
packageStartupMessage(

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Should this actually be a warning()? Or even a stop()?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I guess it depends on the extent of the problem; does it always segfault, or just when we use some of the functionality?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

There might be some functionality that works, but everything I've seen people try (even open_dataset() |> nrow() segfaults. Given opcodes + architectures + emulation, I would be surprised if much of anything of use in arrow will work.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think packageStartupMessage is appropriate, I wouldn't raise other signals in onLoad

Comment thread r/R/arrow-package.R Outdated
"(typically, this is running an x86 build of R on an ARM or",
"M processor based mac). This configuration is not supported",
"by arrow and we highly recommend you install a native (arm64)",
"build of R and use arrow with that."

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is more verbose than many of our messages (and I'm happy for some streamlining), but my reasoning for being so explicit is that if someone finds themselves in this situation, they might not even realized what is going on with architectures, versions, emulation etc. So I wanted to give people more details to be able to get to a good state (native R + native arrow)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I might explicitly link to https://cran.r-project.org/bin/macosx/ and say install the arm64 version. And I (personally) would be a bit more direct: you're running R built for Intel on a non-Intel mac, and arrow won't work in that context; to fix, install the arm64 version of R from CRAN and then reinstall R.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks for the "Intel on a non-Intel mac" that's probably the clearest way to describe it to folks who are most likely to run into this.

@jonkeane jonkeane changed the title GH-37760: [R] Add a message if we detect running under emulation GH-33807: [R] Add a message if we detect running under emulation Sep 18, 2023
@jonkeane

Copy link
Copy Markdown
Member Author

Sorry for the errant issue tag — too many tabs open! I've corrected it in the title + issue description

Comment thread r/R/arrow-package.R Outdated
}

# On MacOS only, Check if we are running in under emulation, and warn this will not work
rosetta <- identical(sysname, "darwin") && identical(system("sysctl -n sysctl.proc_translated", intern = TRUE), "1")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I see this is also in install_arrow(), NBD but we could factor this out and put it in arrow-package.R alongside on_macos_10_13_or_lower() et al.

@nealrichardson

Copy link
Copy Markdown
Member

Are these changes tested?

No, given the paucity of ARM-based mac CI, testing this organically would be difficult. But the logic is straightforward.

Have you confirmed locally at least?

@nealrichardson

Copy link
Copy Markdown
Member

Also resolves #37034?

@nealrichardson

Copy link
Copy Markdown
Member

Should this get mentioned in the docs somewhere too?

@jonkeane

Copy link
Copy Markdown
Member Author

Have you confirmed locally at least?

Yes, here is an example of the output. After seeing it in the terminal I've moved it up about the missing features message + also add "Warning:" and some spacing to hopefully set this apart a little bit more.

Platform: x86_64-apple-darwin17.0 (64-bit)
...
> library(arrow)
Warning:
  It appears that you are running R and Arrow in emulation (i.e. you're
  running an Intel version of R on a non-Intel mac). This configuration is
  not supported by arrow, you should install a native (arm64) build of R
  and use arrow with that. See https://cran.r-project.org/bin/macosx/

Some features are not enabled in this build of Arrow. Run `arrow_info()` for more information.

Attaching package: ‘arrow’

The following object is masked from ‘package:utils’:

    timestamp

@jonkeane

Copy link
Copy Markdown
Member Author

Should this get mentioned in the docs somewhere too?

Add this to the readme section under caveats.

@nealrichardson nealrichardson left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for doing this!

@jonkeane
jonkeane merged commit 64ad8e5 into apache:main Sep 19, 2023
@jonkeane
jonkeane deleted the detect_emulated_macos branch September 19, 2023 16:22
@conbench-apache-arrow

Copy link
Copy Markdown

After merging your PR, Conbench analyzed the 5 benchmarking runs that have been run so far on merge-commit 64ad8e5.

There were no benchmark performance regressions. 🎉

The full Conbench report has more details. It also includes information about possible false positives for unstable benchmarks that are known to sometimes produce them.

loicalleyne pushed a commit to loicalleyne/arrow that referenced this pull request Nov 13, 2023
apache#37777)

Resolves apache#33807 and apache#37034

### Rationale for this change

If someone is running R under emulation, arrow segfaults without error. We can detect this when we load so can also warn people that this is not recommended. Though the version of R being run is not directly an arrow issue, arrow fails very quickly in this configuration.

### What changes are included in this PR?

Detect when running under rosetta (on macOS only) and warn when the library is attached

### Are these changes tested?

No, given the paucity of ARM-based mac CI, testing this organically would be difficult. But the logic is straightforward.

### Are there any user-facing changes?

Yes, a warning when someone loads arrow under emulation.
* Closes: apache#33807

Authored-by: Jonathan Keane <[email protected]>
Signed-off-by: Jonathan Keane <[email protected]>
dgreiss pushed a commit to dgreiss/arrow that referenced this pull request Feb 19, 2024
apache#37777)

Resolves apache#33807 and apache#37034

If someone is running R under emulation, arrow segfaults without error. We can detect this when we load so can also warn people that this is not recommended. Though the version of R being run is not directly an arrow issue, arrow fails very quickly in this configuration.

Detect when running under rosetta (on macOS only) and warn when the library is attached

No, given the paucity of ARM-based mac CI, testing this organically would be difficult. But the logic is straightforward.

Yes, a warning when someone loads arrow under emulation.
* Closes: apache#33807

Authored-by: Jonathan Keane <[email protected]>
Signed-off-by: Jonathan Keane <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[R] Using dplyr::tally with an Arrow FileSystemDataset crashes R

3 participants