Submit Search
Upload
Supporting R C-language API in R-compatible Engine
•
0 likes
•
167 views
AI-enhanced title
A
adamwelc
Follow
Presentation at the RIOT 2015 workshop by Michael Sannella.
Read less
Read more
Software
Report
Share
Report
Share
1 of 16
Download now
Download to read offline
Recommended
The Compatibility Challenge:Examining R and Developing TERR
The Compatibility Challenge:Examining R and Developing TERR
Lou Bajuk
PLAZMA TD Tech Talk 2018 at Shibuya: Hive2 as a new td hadoop core engine
PLAZMA TD Tech Talk 2018 at Shibuya: Hive2 as a new td hadoop core engine
Ryu Kobayashi
Airframe: Lightweight Building Blocks for Scala @ TD Tech Talk 2018-10-17
Airframe: Lightweight Building Blocks for Scala @ TD Tech Talk 2018-10-17
Taro L. Saito
Managing Machine Learning workflows on Treasure Data
Managing Machine Learning workflows on Treasure Data
Aki Ariga
Custom Script Execution Environment on TD Workflow @ TD Tech Talk 2018-10-17
Custom Script Execution Environment on TD Workflow @ TD Tech Talk 2018-10-17
Muga Nishizawa
Python indroduction
Python indroduction
FEG
201810 td tech_talk
201810 td tech_talk
Keisuke Suzuki
Seattle useR Group - R + Scala
Seattle useR Group - R + Scala
Shouheng Yi
Recommended
The Compatibility Challenge:Examining R and Developing TERR
The Compatibility Challenge:Examining R and Developing TERR
Lou Bajuk
PLAZMA TD Tech Talk 2018 at Shibuya: Hive2 as a new td hadoop core engine
PLAZMA TD Tech Talk 2018 at Shibuya: Hive2 as a new td hadoop core engine
Ryu Kobayashi
Airframe: Lightweight Building Blocks for Scala @ TD Tech Talk 2018-10-17
Airframe: Lightweight Building Blocks for Scala @ TD Tech Talk 2018-10-17
Taro L. Saito
Managing Machine Learning workflows on Treasure Data
Managing Machine Learning workflows on Treasure Data
Aki Ariga
Custom Script Execution Environment on TD Workflow @ TD Tech Talk 2018-10-17
Custom Script Execution Environment on TD Workflow @ TD Tech Talk 2018-10-17
Muga Nishizawa
Python indroduction
Python indroduction
FEG
201810 td tech_talk
201810 td tech_talk
Keisuke Suzuki
Seattle useR Group - R + Scala
Seattle useR Group - R + Scala
Shouheng Yi
Building APIs with Kotlin and Spark
Building APIs with Kotlin and Spark
Nordic APIs
Recent Changes and Challenges for Future Presto
Recent Changes and Challenges for Future Presto
Kai Sasaki
An Introduction to ANTLR
An Introduction to ANTLR
Morteza Zakeri
Developer insight into why applications run amazingly Fast in CF 2018
Developer insight into why applications run amazingly Fast in CF 2018
Pavan Kumar
Airframe: Lightweight Building Blocks for Scala - Scale By The Bay 2018
Airframe: Lightweight Building Blocks for Scala - Scale By The Bay 2018
Taro L. Saito
Apriori
Apriori
Khaled Boussaidi
.NET Fest 2018. Vagif Abilov. Akka + F# = Akkling
.NET Fest 2018. Vagif Abilov. Akka + F# = Akkling
NETFest
Apriori algorithm
Apriori algorithm
DHIVYADEVAKI
8051 Assembly Language Programming
8051 Assembly Language Programming
Ravikumar Tiwari
BPFR_11644022_Sagar_Sathe
BPFR_11644022_Sagar_Sathe
Sagar Sathe
CRIT Library Presentation (3)
CRIT Library Presentation (3)
Ramona Duran
Mi ple isabel miramontes
Mi ple isabel miramontes
mariaisabel3185235
TWRA.tv 2016 deck
TWRA.tv 2016 deck
Scott Scrip
Entrevistando al entrevistador
Entrevistando al entrevistador
sys army
Cómo hacer troubleshooting y no morir en el intento
Cómo hacer troubleshooting y no morir en el intento
sys army
Git 101+
Git 101+
sys army
Headshot! FPS networking
Headshot! FPS networking
sys army
Revision of syllabus_of_gnm_last_3_dec _2__final
Revision of syllabus_of_gnm_last_3_dec _2__final
pravallika vasikarla
Extra hepatic biliary atresia
Extra hepatic biliary atresia
pravallika vasikarla
Patent ductus arteriosus
Patent ductus arteriosus
pravallika vasikarla
determinants og organizational effectiveness
determinants og organizational effectiveness
pravallika vasikarla
Philosophy of staffing in nursing
Philosophy of staffing in nursing
pravallika vasikarla
More Related Content
What's hot
Building APIs with Kotlin and Spark
Building APIs with Kotlin and Spark
Nordic APIs
Recent Changes and Challenges for Future Presto
Recent Changes and Challenges for Future Presto
Kai Sasaki
An Introduction to ANTLR
An Introduction to ANTLR
Morteza Zakeri
Developer insight into why applications run amazingly Fast in CF 2018
Developer insight into why applications run amazingly Fast in CF 2018
Pavan Kumar
Airframe: Lightweight Building Blocks for Scala - Scale By The Bay 2018
Airframe: Lightweight Building Blocks for Scala - Scale By The Bay 2018
Taro L. Saito
Apriori
Apriori
Khaled Boussaidi
.NET Fest 2018. Vagif Abilov. Akka + F# = Akkling
.NET Fest 2018. Vagif Abilov. Akka + F# = Akkling
NETFest
Apriori algorithm
Apriori algorithm
DHIVYADEVAKI
8051 Assembly Language Programming
8051 Assembly Language Programming
Ravikumar Tiwari
What's hot
(9)
Building APIs with Kotlin and Spark
Building APIs with Kotlin and Spark
Recent Changes and Challenges for Future Presto
Recent Changes and Challenges for Future Presto
An Introduction to ANTLR
An Introduction to ANTLR
Developer insight into why applications run amazingly Fast in CF 2018
Developer insight into why applications run amazingly Fast in CF 2018
Airframe: Lightweight Building Blocks for Scala - Scale By The Bay 2018
Airframe: Lightweight Building Blocks for Scala - Scale By The Bay 2018
Apriori
Apriori
.NET Fest 2018. Vagif Abilov. Akka + F# = Akkling
.NET Fest 2018. Vagif Abilov. Akka + F# = Akkling
Apriori algorithm
Apriori algorithm
8051 Assembly Language Programming
8051 Assembly Language Programming
Viewers also liked
BPFR_11644022_Sagar_Sathe
BPFR_11644022_Sagar_Sathe
Sagar Sathe
CRIT Library Presentation (3)
CRIT Library Presentation (3)
Ramona Duran
Mi ple isabel miramontes
Mi ple isabel miramontes
mariaisabel3185235
TWRA.tv 2016 deck
TWRA.tv 2016 deck
Scott Scrip
Entrevistando al entrevistador
Entrevistando al entrevistador
sys army
Cómo hacer troubleshooting y no morir en el intento
Cómo hacer troubleshooting y no morir en el intento
sys army
Git 101+
Git 101+
sys army
Headshot! FPS networking
Headshot! FPS networking
sys army
Revision of syllabus_of_gnm_last_3_dec _2__final
Revision of syllabus_of_gnm_last_3_dec _2__final
pravallika vasikarla
Extra hepatic biliary atresia
Extra hepatic biliary atresia
pravallika vasikarla
Patent ductus arteriosus
Patent ductus arteriosus
pravallika vasikarla
determinants og organizational effectiveness
determinants og organizational effectiveness
pravallika vasikarla
Philosophy of staffing in nursing
Philosophy of staffing in nursing
pravallika vasikarla
Atrial septal defect
Atrial septal defect
pravallika vasikarla
Ines De Castro George E Lucia
Ines De Castro George E Lucia
dmcb
MãE Adriely
MãE Adriely
roseconrado
Homero5ºA
Homero5ºA
roseconrado
Tecnologia Sep 11
Tecnologia Sep 11
seisvalt
Juan Carlos
Juan Carlos
roseconrado
Trata.aspectos.basicos
Trata.aspectos.basicos
Marcos Sanchez
Viewers also liked
(20)
BPFR_11644022_Sagar_Sathe
BPFR_11644022_Sagar_Sathe
CRIT Library Presentation (3)
CRIT Library Presentation (3)
Mi ple isabel miramontes
Mi ple isabel miramontes
TWRA.tv 2016 deck
TWRA.tv 2016 deck
Entrevistando al entrevistador
Entrevistando al entrevistador
Cómo hacer troubleshooting y no morir en el intento
Cómo hacer troubleshooting y no morir en el intento
Git 101+
Git 101+
Headshot! FPS networking
Headshot! FPS networking
Revision of syllabus_of_gnm_last_3_dec _2__final
Revision of syllabus_of_gnm_last_3_dec _2__final
Extra hepatic biliary atresia
Extra hepatic biliary atresia
Patent ductus arteriosus
Patent ductus arteriosus
determinants og organizational effectiveness
determinants og organizational effectiveness
Philosophy of staffing in nursing
Philosophy of staffing in nursing
Atrial septal defect
Atrial septal defect
Ines De Castro George E Lucia
Ines De Castro George E Lucia
MãE Adriely
MãE Adriely
Homero5ºA
Homero5ºA
Tecnologia Sep 11
Tecnologia Sep 11
Juan Carlos
Juan Carlos
Trata.aspectos.basicos
Trata.aspectos.basicos
Similar to Supporting R C-language API in R-compatible Engine
Sannella use r2013-terr-memory-management
Sannella use r2013-terr-memory-management
Lou Bajuk
Migrating Airflow-based Apache Spark Jobs to Kubernetes – the Native Way
Migrating Airflow-based Apache Spark Jobs to Kubernetes – the Native Way
Databricks
Deploying R in BI and Real time Applications
Deploying R in BI and Real time Applications
Lou Bajuk
RTBkit Meetup - Developer Spotlight, Behind the Scenes of RTBkit and Intro to...
RTBkit Meetup - Developer Spotlight, Behind the Scenes of RTBkit and Intro to...
Datacratic
React advance
React advance
Vivek Tikar
TERR in BI and Real Time applications
TERR in BI and Real Time applications
Lou Bajuk
Manchester Meetup #3
Manchester Meetup #3
Francis Edwards
R programming groundup-basic-section-i
R programming groundup-basic-section-i
Dr. Awase Khirni Syed
MuleSoft Manchester Meetup #3 slides 31st March 2020
MuleSoft Manchester Meetup #3 slides 31st March 2020
Ieva Navickaite
Functional programming, TypeScript and RXJS
Functional programming, TypeScript and RXJS
Vivek Tikar
Zend server for IBM i update 5.6
Zend server for IBM i update 5.6
Zend by Rogue Wave Software
Code generation
Code generation
Aparna Nayak
Using the R Language in BI and Real Time Applications (useR 2015)
Using the R Language in BI and Real Time Applications (useR 2015)
Lou Bajuk
Extend the Reach of R to the Enterprise (for useR! 2013)
Extend the Reach of R to the Enterprise (for useR! 2013)
Lou Bajuk
Application Deployment on IBM i
Application Deployment on IBM i
Zend by Rogue Wave Software
Stupid DITA Tricks:After-The-Fact Specialization: Treating Aircraft Manuals ...
Stupid DITA Tricks:After-The-Fact Specialization: Treating Aircraft Manuals ...
Contrext Solutions
West Yorkshire Mulesoft Meetup #6
West Yorkshire Mulesoft Meetup #6
Francis Edwards
Extending the R language to BI and Real-time Applications JSM 2015
Extending the R language to BI and Real-time Applications JSM 2015
Lou Bajuk
Introducing TiDB Operator
Introducing TiDB Operator
Kevin Xu
HKG18-318 - OpenAMP Workshop
HKG18-318 - OpenAMP Workshop
Linaro
Similar to Supporting R C-language API in R-compatible Engine
(20)
Sannella use r2013-terr-memory-management
Sannella use r2013-terr-memory-management
Migrating Airflow-based Apache Spark Jobs to Kubernetes – the Native Way
Migrating Airflow-based Apache Spark Jobs to Kubernetes – the Native Way
Deploying R in BI and Real time Applications
Deploying R in BI and Real time Applications
RTBkit Meetup - Developer Spotlight, Behind the Scenes of RTBkit and Intro to...
RTBkit Meetup - Developer Spotlight, Behind the Scenes of RTBkit and Intro to...
React advance
React advance
TERR in BI and Real Time applications
TERR in BI and Real Time applications
Manchester Meetup #3
Manchester Meetup #3
R programming groundup-basic-section-i
R programming groundup-basic-section-i
MuleSoft Manchester Meetup #3 slides 31st March 2020
MuleSoft Manchester Meetup #3 slides 31st March 2020
Functional programming, TypeScript and RXJS
Functional programming, TypeScript and RXJS
Zend server for IBM i update 5.6
Zend server for IBM i update 5.6
Code generation
Code generation
Using the R Language in BI and Real Time Applications (useR 2015)
Using the R Language in BI and Real Time Applications (useR 2015)
Extend the Reach of R to the Enterprise (for useR! 2013)
Extend the Reach of R to the Enterprise (for useR! 2013)
Application Deployment on IBM i
Application Deployment on IBM i
Stupid DITA Tricks:After-The-Fact Specialization: Treating Aircraft Manuals ...
Stupid DITA Tricks:After-The-Fact Specialization: Treating Aircraft Manuals ...
West Yorkshire Mulesoft Meetup #6
West Yorkshire Mulesoft Meetup #6
Extending the R language to BI and Real-time Applications JSM 2015
Extending the R language to BI and Real-time Applications JSM 2015
Introducing TiDB Operator
Introducing TiDB Operator
HKG18-318 - OpenAMP Workshop
HKG18-318 - OpenAMP Workshop
Recently uploaded
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
Marharyta Nedzelska
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Ahmed Mohamed
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion Application
BradBedford3
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
BrainSell Technologies
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Natan Silnitsky
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf
31events.com
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Matt Ray
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Cizo Technology Services
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
Hanief Utama
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
Łukasz Chruściel
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identity
team-WIBU
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
qr0udbr0
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
OnePlan Solutions
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
jennyeacort
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
Christian Birchler
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
Andreas Granig
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Stefano Stabellini
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
How To Manage Restaurant Staff -BTRESTRO
How To Manage Restaurant Staff -BTRESTRO
motivationalword821
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
Hr365.us smith
Recently uploaded
(20)
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion Application
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identity
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
How To Manage Restaurant Staff -BTRESTRO
How To Manage Restaurant Staff -BTRESTRO
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
Supporting R C-language API in R-compatible Engine
1.
Supporting the “Rapi” C-language
API in an R-compatible engine Michael Sannella msannell@tibco.com RIOT 2015
2.
TERR, Packages, and
Rapi • TERR: TIBCO® Enterprise Runtime for R • A commercial R-compatible statistics engine • We want TERR to support many external packages • Much of the value of R lies in packages from CRAN and other repositories (Bioconductor, Github, etc.) • Many packages are pure “R-language” packages • About 70% of CRAN packages are pure R-language • Many packages contain C-language code • C-language code can access the R engine using the R engine’s C-language API (“Rapi”) RIOT 2015 --- July 2015 © Copyright 2000-2015 TIBCO Software Inc. 2
3.
TERR Rapi Support •
Ultimate goal: TERR supports loading and executing binary packages unchanged • Fallback: Modify package sources and rebuild before loading • If necessary, we can distribute modified packages for TERR in our TRAN repository RIOT 2015 --- July 2015 © Copyright 2000-2015 TIBCO Software Inc. 3
4.
Example: Code Using
Rapi • R code from the CRAN package “splusTimeDate”: .Call("time_to_hour_min_sec", x, timeZoneList()) • C code: SEXP time_to_hour_min_sec(SEXP time_vec, SEXP zone_list) { ... PROTECT(ret = NEW_LIST(4)); ... SET_VECTOR_ELT(ret, 0, PROTECT(NEW_INTEGER(lng))); ... hour_data = INTEGER(VECTOR_ELT(ret, 0)); ... hour_data[i] = td.hour; ... UNPROTECT(7); return( ret ); } • NEW_INTEGER macro expands to a call to the Rf_allocVector Rapi entry RIOT 2015 --- July 2015 © Copyright 2000-2015 TIBCO Software Inc. 4
5.
Rapi Shared Libraries:
R.dll, etc. • Rapi defines hundreds of library entries • ATTRIB, SET_VECTOR_ELT, R_alloc, Rf_allocVector, Rf_Protect, dcopy_, dgemm_, dlaic1_, etc. • Embedding API (used by Rstudio) • Global variables: R_GlobalEnv, R_NaInt, etc. • Packages link to shared library files R.dll, Rblas.dll, etc. (libR.so, etc. on Linux) that export these Rapi entries • To support Rapi, TERR contains R.dll, etc. libraries that forward Rapi calls to the engine RIOT 2015 --- July 2015 © Copyright 2000-2015 TIBCO Software Inc. 5
6.
TERR Rapi Support:
Handles • Observation: Rapi entries treat SEXP (R object pointer) values as opaque values passed to and from the engine • TERR approach: Treat SEXP as an offset in a “handle table” containing pointers to internal TERR objects • Benefit: Can convert TERR-only objects “in-place” as needed • Ex: Expand TERR integer sequence object to an integer vector object when Rapi code calls INTEGER to access its contents • Works well for many packages RIOT 2015 --- July 2015 © Copyright 2000-2015 TIBCO Software Inc. 6
7.
Problem: USE_RINTERNALS • If
the C constant USE_RINTERNALS is defined, many Rapi function calls are redefined as macros directly accessing R object internals • USE_RINTERNALS is used in many popular CRAN packages: Rcpp, Rserve, igraph, etc • TERR workaround: Make our own versions of packages without USE_RINTERNALS defined • Some tweaks needed to compile: STRING_ELT(x, i) = value; // change this SET_STRING_ELT(x, i, value); // to this RIOT 2015 --- July 2015 © Copyright 2000-2015 TIBCO Software Inc. 7
8.
USE_RINTERNALS More Efficient? •
Can improve efficiency of some idioms: for (int i = 0; i<LENGTH(obj); ++i) { INTEGER(obj)[i] = 0; } • However, it is easy to rework code to reduce function calls: int len = LENGTH(obj); int* data = INTEGER(obj); for (int i = 0; i<len; ++i) { data[i] = 0 } RIOT 2015 --- July 2015 © Copyright 2000-2015 TIBCO Software Inc. 8
9.
Solution: New Object
Layout • The TERR team is currently reworking the TERR object layout to be more compatible with R • SEXP is pointer to R-compatible object • TERR C++ header stored before R-compatible object bytes RIOT 2015 --- July 2015 © Copyright 2000-2015 TIBCO Software Inc. 9 SObject* SEXP TERR C++ Object Header R-Compatible Header Data
10.
New Object Layout:
Issues • Issue: List object must contain array of SEXP pointers, not TERR C++ object pointers • Issue: TERR-only objects (like sequence objects) must be converted before exposing to Rapi code • Only allow R-compatible objects within “Rapi space” • Convert arguments to .Call • Convert value returned by Rapi entries Rf_eval, etc. • Concerns: Extra complexity, object size, performance hit RIOT 2015 --- July 2015 © Copyright 2000-2015 TIBCO Software Inc. 10
11.
Beyond USE_RINTERNALS: The data.table
Package • The data.table package exploits knowledge of engine behavior and object layout to improve performance • Manipulates TRUELENGTH field to reuse vectors • Uses TRUELENGTH field of CHARSXP as for own uses during sorting • Reads object bits to access string encoding quickly without Rapi function calls • Problem: It is coding to a particular implementation of the R engine, rather than to a well-defined API RIOT 2015 --- July 2015 © Copyright 2000-2015 TIBCO Software Inc. 11
12.
Beyond USE_RINTERNALS: The stringi
Package • Recent discovery: extern "C" void R_init_stringi(DllInfo* dll) { ... stri_set_icu_data_directory( (char*)*(char**)(dll) /* dll->path */); ... } • Uses knowledge of internal DllInfo data structure • May break if DllInfo structure changed • Would be better to get path some other way RIOT 2015 --- July 2015 © Copyright 2000-2015 TIBCO Software Inc. 12
13.
Challenge: TERR vs
R GC Behavior • TERR does more aggressive GC, collecting an object immediately when its reference count goes to zero • Matrix package: code swapping dimnames // Csparse.c:Csparse_transpose SEXP dn = PROTECT(duplicate(GET_SLOT(x, Matrix_DimNamesSym))); tmp = VECTOR_ELT(dn, 0); SET_VECTOR_ELT(dn, 0, VECTOR_ELT(dn, 1)); /* GC tmp here? */ SET_VECTOR_ELT(dn, 1, tmp); • Problem: TERR collects tmp immediately if SET_VECTOR_ELT reduces tmp reference count to zero • Solution: Change SET_VECTOR_ELT so it won’t kill old element RIOT 2015 --- July 2015 © Copyright 2000-2015 TIBCO Software Inc. 13
14.
Challenge: SET_TYPEOF • SET_TYPEOF
changes an object type • Mainly used for converting pairlist to language type • Using Rapi handles, SET_TYPEOF can change object in place • With USE_RINTERNALS defined, SET_TYPEOF just changes type bits • Problem: We can’t change TERR C++ object type • Possibility: Auto-convert pairlist object as needed in engine, if type bits are set to language type RIOT 2015 --- July 2015 © Copyright 2000-2015 TIBCO Software Inc. 14
15.
Bad code: .Call
returning void • In R, .Call can call function returning void • Ex: in RSQLite: void rsqlite_driver_init(SEXP records_, SEXP cache_) • As long as the value is not used, no problem • In TERR, .Call manipulates returned object • TERR can check for valid return object pointers, but this has a performance cost • Possibility: Special processing of .Call where value is not used • Possibility: Turn on/off valid-pointer check • Q: worth supporting bad code? RIOT 2015 --- July 2015 © Copyright 2000-2015 TIBCO Software Inc. 15
16.
TERR Rapi Support:
Status • TERR supports many packages with Rapi code, using handles to SEXP objects • We are reworking TERR object layout to support packages that access object internals via USE_RINTERNALS • We are dealing with a number of compatibility challenges RIOT 2015 --- July 2015 © Copyright 2000-2015 TIBCO Software Inc. 16
Download now