Viktor Palmkvist, Anders Ågren Thuné, Elias Castegren, David Broman
{"title":"Repr 类型:一个抽象概念统领一切","authors":"Viktor Palmkvist, Anders Ågren Thuné, Elias Castegren, David Broman","doi":"arxiv-2409.07950","DOIUrl":null,"url":null,"abstract":"The choice of how to represent an abstract type can have a major impact on\nthe performance of a program, yet mainstream compilers cannot perform\noptimizations at such a high level. When dealing with optimizations of data\ntype representations, an important feature is having extensible\nrepresentation-flexible data types; the ability for a programmer to add new\nabstract types and operations, as well as concrete implementations of these,\nwithout modifying the compiler or a previously defined library. Many research\nprojects support high-level optimizations through static analysis,\ninstrumentation, or benchmarking, but they are all restricted in at least one\naspect of extensibility. This paper presents a new approach to representation-flexible data types\nwithout such restrictions and which still finds efficient optimizations. Our\napproach centers around a single built-in type $\\texttt{repr}$ and function\noverloading with cost annotations for operation implementations. We evaluate\nour approach (i) by defining a universal collection type as a library, a single\ntype for all conventional collections, and (ii) by designing and implementing a\nrepresentation-flexible graph library. Programs using $\\texttt{repr}$ types are\ntypically faster than programs with idiomatic representation choices --\nsometimes dramatically so -- as long as the compiler finds good implementations\nfor all operations. Our compiler performs the analysis efficiently by finding\noptimized solutions quickly and by reusing previous results to avoid\nrecomputations.","PeriodicalId":501197,"journal":{"name":"arXiv - CS - Programming Languages","volume":"8 1","pages":""},"PeriodicalIF":0.0000,"publicationDate":"2024-09-12","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"0","resultStr":"{\"title\":\"Repr Types: One Abstraction to Rule Them All\",\"authors\":\"Viktor Palmkvist, Anders Ågren Thuné, Elias Castegren, David Broman\",\"doi\":\"arxiv-2409.07950\",\"DOIUrl\":null,\"url\":null,\"abstract\":\"The choice of how to represent an abstract type can have a major impact on\\nthe performance of a program, yet mainstream compilers cannot perform\\noptimizations at such a high level. When dealing with optimizations of data\\ntype representations, an important feature is having extensible\\nrepresentation-flexible data types; the ability for a programmer to add new\\nabstract types and operations, as well as concrete implementations of these,\\nwithout modifying the compiler or a previously defined library. Many research\\nprojects support high-level optimizations through static analysis,\\ninstrumentation, or benchmarking, but they are all restricted in at least one\\naspect of extensibility. This paper presents a new approach to representation-flexible data types\\nwithout such restrictions and which still finds efficient optimizations. Our\\napproach centers around a single built-in type $\\\\texttt{repr}$ and function\\noverloading with cost annotations for operation implementations. We evaluate\\nour approach (i) by defining a universal collection type as a library, a single\\ntype for all conventional collections, and (ii) by designing and implementing a\\nrepresentation-flexible graph library. Programs using $\\\\texttt{repr}$ types are\\ntypically faster than programs with idiomatic representation choices --\\nsometimes dramatically so -- as long as the compiler finds good implementations\\nfor all operations. Our compiler performs the analysis efficiently by finding\\noptimized solutions quickly and by reusing previous results to avoid\\nrecomputations.\",\"PeriodicalId\":501197,\"journal\":{\"name\":\"arXiv - CS - Programming Languages\",\"volume\":\"8 1\",\"pages\":\"\"},\"PeriodicalIF\":0.0000,\"publicationDate\":\"2024-09-12\",\"publicationTypes\":\"Journal Article\",\"fieldsOfStudy\":null,\"isOpenAccess\":false,\"openAccessPdf\":\"\",\"citationCount\":\"0\",\"resultStr\":null,\"platform\":\"Semanticscholar\",\"paperid\":null,\"PeriodicalName\":\"arXiv - CS - Programming Languages\",\"FirstCategoryId\":\"1085\",\"ListUrlMain\":\"https://doi.org/arxiv-2409.07950\",\"RegionNum\":0,\"RegionCategory\":null,\"ArticlePicture\":[],\"TitleCN\":null,\"AbstractTextCN\":null,\"PMCID\":null,\"EPubDate\":\"\",\"PubModel\":\"\",\"JCR\":\"\",\"JCRName\":\"\",\"Score\":null,\"Total\":0}","platform":"Semanticscholar","paperid":null,"PeriodicalName":"arXiv - CS - Programming Languages","FirstCategoryId":"1085","ListUrlMain":"https://doi.org/arxiv-2409.07950","RegionNum":0,"RegionCategory":null,"ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"","JCRName":"","Score":null,"Total":0}
The choice of how to represent an abstract type can have a major impact on
the performance of a program, yet mainstream compilers cannot perform
optimizations at such a high level. When dealing with optimizations of data
type representations, an important feature is having extensible
representation-flexible data types; the ability for a programmer to add new
abstract types and operations, as well as concrete implementations of these,
without modifying the compiler or a previously defined library. Many research
projects support high-level optimizations through static analysis,
instrumentation, or benchmarking, but they are all restricted in at least one
aspect of extensibility. This paper presents a new approach to representation-flexible data types
without such restrictions and which still finds efficient optimizations. Our
approach centers around a single built-in type $\texttt{repr}$ and function
overloading with cost annotations for operation implementations. We evaluate
our approach (i) by defining a universal collection type as a library, a single
type for all conventional collections, and (ii) by designing and implementing a
representation-flexible graph library. Programs using $\texttt{repr}$ types are
typically faster than programs with idiomatic representation choices --
sometimes dramatically so -- as long as the compiler finds good implementations
for all operations. Our compiler performs the analysis efficiently by finding
optimized solutions quickly and by reusing previous results to avoid
recomputations.