Changeset 5d300ba for doc/theses
- Timestamp:
- Dec 16, 2025, 7:41:51 AM (7 days ago)
- Branches:
- master
- Children:
- 0210a543
- Parents:
- 35fc819
- Location:
- doc/theses/mike_brooks_MMath
- Files:
-
- 7 edited
-
plots/list-zoomout-noshuf.gp (modified) (1 diff)
-
plots/list-zoomout-shuf.gp (modified) (1 diff)
-
plots/string-peq-cppemu.gp (modified) (3 diffs)
-
plots/string-peq-sharing.gp (modified) (3 diffs)
-
plots/string-pta-sharing.gp (modified) (3 diffs)
-
programs/sharing-demo.cfa (modified) (1 diff)
-
string.tex (modified) (63 diffs)
Legend:
- Unmodified
- Added
- Removed
-
doc/theses/mike_brooks_MMath/plots/list-zoomout-noshuf.gp
r35fc819 r5d300ba 10 10 set key top left 11 11 set logscale x 12 set logscale y13 set yrange [1:1000];12 #set logscale y 13 #set yrange [1:1000]; 14 14 set xlabel "List length (item count)" offset 2,0 15 15 set ylabel "Duration (ns)" -
doc/theses/mike_brooks_MMath/plots/list-zoomout-shuf.gp
r35fc819 r5d300ba 11 11 set logscale x 12 12 set logscale y 13 set yrange [1:1000];13 #set yrange [1:1000]; 14 14 set xlabel "List length (item count)" offset 2,0 15 set ylabel "Duration (ns) "15 set ylabel "Duration (ns), log scale" 16 16 set linetype 3 dashtype 2 17 17 set linetype 4 dashtype 2 -
doc/theses/mike_brooks_MMath/plots/string-peq-cppemu.gp
r35fc819 r5d300ba 1 set terminal pdf color enhanced size 6. 0in,3.0in font "Times,17"1 set terminal pdf color enhanced size 6.5in,3.5in font "Times,17" 2 2 #set terminal postscript portrait enhanced size 7.5, 10. color solid 9.5; 3 3 #set terminal wxt size 950,1250 … … 11 11 set grid 12 12 set key top left 13 set xrange [1:500] 13 14 set xtics (1,2,5,10,20,50,100,200,500) 14 15 set logscale x … … 20 21 set linetype 4 dashtype 2 21 22 plot INDIR."/plot-string-peq-cppemu.dat" \ 22 i 0 using 1:2 title columnheader(1) with points lt rgb "red" pt 2 ps 1, \ 23 '' i 1 using 1:2 title columnheader(1) with points lt rgb "red" pt 1 ps 1, \ 24 '' i 2 using 1:2 title columnheader(1) with points lt rgb "blue" pt 6 ps 1, \ 25 '' i 3 using 1:2 title columnheader(1) with points lt rgb "blue" pt 8 ps 1 23 i 0 using 1:2 title columnheader(1) with points lt rgb "red" pt 2 ps 1, \ 24 '' i 0 using 1:2 notitle smooth sbezier lt rgb "red" dashtype 1, \ 25 '' i 1 using 1:2 title columnheader(1) with points lt rgb "red" pt 1 ps 1, \ 26 '' i 1 using 1:2 notitle smooth sbezier lt rgb "red" dashtype 4, \ 27 '' i 2 using 1:2 title columnheader(1) with points lt rgb "blue" pt 6 ps 1, \ 28 '' i 2 using 1:2 notitle smooth sbezier lt rgb "blue" dashtype 1, \ 29 '' i 3 using 1:2 title columnheader(1) with points lt rgb "blue" pt 8 ps 1, \ 30 '' i 3 using 1:2 notitle smooth sbezier lt rgb "blue" dashtype 4 \ -
doc/theses/mike_brooks_MMath/plots/string-peq-sharing.gp
r35fc819 r5d300ba 1 set terminal pdf color enhanced size 6. 0in,3.0in font "Times,17"1 set terminal pdf color enhanced size 6.5in,3.5in font "Times,17" 2 2 #set terminal postscript portrait enhanced size 7.5, 10. color solid 9.5; 3 3 #set terminal wxt size 950,1250 … … 11 11 set grid 12 12 set key top left 13 set xrange [1:500] 13 14 set xtics (1,2,5,10,20,50,100,200,500) 14 15 set logscale x … … 20 21 set linetype 4 dashtype 2 21 22 plot INDIR."/plot-string-peq-sharing.dat" \ 22 i 0 using 1:2 title columnheader(1) with points lt rgb "red" pt 2 ps 1, \ 23 '' i 1 using 1:2 title columnheader(1) with points lt rgb "red" pt 1 ps 1, \ 24 '' i 2 using 1:2 title columnheader(1) with points lt rgb "blue" pt 6 ps 1, \ 25 '' i 3 using 1:2 title columnheader(1) with points lt rgb "blue" pt 8 ps 1 23 i 0 using 1:2 title columnheader(1) with points lt rgb "red" pt 2 ps 1, \ 24 '' i 0 using 1:2 notitle smooth sbezier lt rgb "red" dashtype 1, \ 25 '' i 1 using 1:2 title columnheader(1) with points lt rgb "red" pt 1 ps 1, \ 26 '' i 1 using 1:2 notitle smooth sbezier lt rgb "red" dashtype 4, \ 27 '' i 2 using 1:2 title columnheader(1) with points lt rgb "blue" pt 6 ps 1, \ 28 '' i 2 using 1:2 notitle smooth sbezier lt rgb "blue" dashtype 1, \ 29 '' i 3 using 1:2 title columnheader(1) with points lt rgb "blue" pt 8 ps 1, \ 30 '' i 3 using 1:2 notitle smooth sbezier lt rgb "blue" dashtype 4 \ 31 -
doc/theses/mike_brooks_MMath/plots/string-pta-sharing.gp
r35fc819 r5d300ba 1 set terminal pdf color enhanced size 6. 0in,3.0in font "Times,17"1 set terminal pdf color enhanced size 6.5in,3.5in font "Times,17" 2 2 #set terminal postscript portrait enhanced size 7.5, 10. color solid 9.5; 3 3 #set terminal wxt size 950,1250 … … 11 11 set grid 12 12 set key top left 13 set xrange [1:500] 13 14 set xtics (1,2,5,10,20,50,100,200,500) 14 15 set logscale x … … 17 18 set xlabel "String Length being appended (mean, geo. dist.), log scale" offset 2,0 18 19 set ylabel "Time per append (ns, mean), log_{2} scale" 19 #show colornames20 20 plot INDIR."/plot-string-pta-sharing.dat" \ 21 i 0 using 1:2 title columnheader(1) with points lt rgb "red" pt 2 ps 1, \ 22 '' i 1 using 1:2 title columnheader(1) with points lt rgb "dark-green" pt 4 ps 1, \ 23 '' i 2 using 1:2 title columnheader(1) with points lt rgb "blue" pt 6 ps 1, \ 24 '' i 3 using 1:2 title columnheader(1) with points lt rgb "dark-green" pt 12 ps 1 21 i 0 using 1:2 title columnheader(1) with points lt rgb "red" pt 2 ps 1, \ 22 '' i 0 using 1:2 notitle smooth sbezier lt rgb "red" dashtype 1, \ 23 '' i 1 using 1:2 title columnheader(1) with points lt rgb "dark-green" pt 4 ps 1, \ 24 '' i 1 using 1:2 notitle smooth sbezier lt rgb "dark-green" dashtype 4, \ 25 '' i 2 using 1:2 title columnheader(1) with points lt rgb "blue" pt 6 ps 1, \ 26 '' i 2 using 1:2 notitle smooth sbezier lt rgb "blue" dashtype 1, \ 27 '' i 3 using 1:2 title columnheader(1) with points lt rgb "dark-green" pt 12 ps 1, \ 28 '' i 3 using 1:2 notitle smooth sbezier lt rgb "dark-green" dashtype 4 \ 29 -
doc/theses/mike_brooks_MMath/programs/sharing-demo.cfa
r35fc819 r5d300ba 300 300 open( outfile, "build/sharing10.tex" ); 301 301 outfile | "\\begin{cquote}"; 302 outfile | "\\setlength{\\tabcolsep}{10pt}"; 302 303 outfile | "\\begin{tabular}{@{}rlllll@{}}"; 303 304 outfile | "\t\t\t\t& @s1@\t& @s1_bgn@\t& @s1_crs@\t& @s1_mid@\t& @s1_end@\t\\\\"; -
doc/theses/mike_brooks_MMath/string.tex
r35fc819 r5d300ba 17 17 \begin{cquote} 18 18 \begin{tabular}{@{}l|l|l|l@{}} 19 C @char [ ]@ & \CC @string@ & Java @String@ & \CFA @string@ \\19 C @char [ ]@ & \CC @string@ & Java @String@ & \CFA @string@ \\ 20 20 \hline 21 21 @strcpy@, @strncpy@ & @=@ & @=@ & @=@ \\ … … 60 60 As a result, a @string@ declaration does not specify a maximum length, where a C string array does. 61 61 For \CFA, as a @string@ dynamically grows and shrinks in size, so does its underlying storage. 62 For C, as a string dynamically grows and shrinks in size, butits underlying storage does not.62 For C, as a string dynamically grows and shrinks in size, its underlying storage does not. 63 63 The maximum storage for a \CFA @string@ value is @size_t@ characters, which is $2^{32}$ or $2^{64}$ respectively. 64 64 A \CFA string manages its length separately from the string, so there is no null (@'\0'@) terminating value at the end of a string value. … … 88 88 Hence, the basic types @char@, @char *@, @int@, @double@, @_Complex@, including any signness and size variations, implicitly convert to type @string@ (as in Java). 89 89 \begin{cquote} 90 \begin{tabular}{@{}l|ll|l@{}} 90 \setlength{\tabcolsep}{10pt} 91 \begin{tabular}{@{}llll@{}} 91 92 \begin{cfa} 92 93 string s = 5; … … 128 129 Conversions can be explicitly specified using a compound literal. 129 130 \begin{cfa} 130 s = (string){ 5 }; s = (string){ "abc" }; s = (string){ 5.5 };131 s = (string){ 5 }; s = (string){ "abc" }; s = (string){ 5.5 }; 131 132 \end{cfa} 132 133 133 134 Conversions from @string@ to @char *@ attempt to be safe. 134 The @strncpy@ conversion requires the maximum length for the pointer's target buffer.135 The overloaded @strncpy@ function is safe, if the length of the C string is correct. 135 136 The assignment operator and constructor both allocate the buffer and return its address, meaning the programmer must free it. 136 137 Note, a C string is always null terminated, implying storage is always necessary for the null. 137 138 \begin{cquote} 138 \begin{tabular}{@{}l |l@{}}139 \begin{tabular}{@{}ll@{}} 139 140 \begin{cfa} 140 141 string s = "abcde"; 141 142 char cs[4]; 142 143 strncpy( cs, s, sizeof(cs) ); 143 char * cp = s; // ownership144 char * cp = s; // ownership 144 145 delete( cp ); 145 146 cp = s + ' ' + s; // ownership … … 162 163 \subsection{Length} 163 164 164 The @len@ operation (short for @strlen@) returns the length of a C or \CFA string.165 For compatibility, @strlen@ alsoworks with \CFA strings.166 \begin{cquote} 167 \begin{tabular}{@{}l |l@{}}165 The @len@ operation (short for @strlen@) returns the length of a C (not including the terminating null) or \CFA string. 166 For compatibility, an overloaded @strlen@ works with \CFA strings. 167 \begin{cquote} 168 \begin{tabular}{@{}ll@{}} 168 169 \begin{cfa} 169 170 i = len( "" ); … … 192 193 In C, these operators compare the C string pointer not its value, which does not match programmer expectation. 193 194 C strings use function @strcmp@ to lexicographically compare the string value. 194 Java has the same issue with @==@ and @.equals@.195 Java has the same issue with @==@ (reference) and @.equals@ (value) comparison. 195 196 196 197 … … 199 200 The binary operators @+@ and @+=@ concatenate C @char@, @char *@ and \CFA strings, creating the sum of the characters. 200 201 \begin{cquote} 201 \begin{tabular}{@{}l|l@{\hspace{15pt}}l|l@{\hspace{15pt}}l|l@{}} 202 \setlength{\tabcolsep}{5pt} 203 \begin{tabular}{@{}ll|ll|ll@{}} 202 204 \begin{cfa} 203 205 s = ""; … … 264 266 Similarly, it is impossible to restrict or remove addition on type @char *@ because (unfortunately) it is subscripting: @cs + 'a'@ implies @cs['a']@ or @'a'[cs]@. 265 267 266 The prior \CFA concatenation examples show complex mixed-mode interactions among @char@, @char *@, and @string@ constants work correctly ( variables are the same).268 The prior \CFA concatenation examples show complex mixed-mode interactions among @char@, @char *@, and @string@ constants work correctly (@string@ variables are the same). 267 269 The reason is that the \CFA type-system handles this kind of overloading well using the left-hand assignment-type and complex conversion costs. 268 270 Hence, the type system correctly handles all uses of addition (explicit or implicit) for @char *@. … … 299 301 If $N = 0$, a zero length string, @""@, is returned. 300 302 \begin{cquote} 301 \begin{tabular}{@{}l |l@{}}303 \begin{tabular}{@{}ll@{}} 302 304 \begin{cfa} 303 305 s = 'x' * 0; … … 318 320 multiplication of pointers does not exist in C. 319 321 \begin{cfa} 320 ch = ch * 3; $\C[2in]{// LHS disambiguate, multiply character value s}$322 ch = ch * 3; $\C[2in]{// LHS disambiguate, multiply character value}$ 321 323 s = 'a' * 3; $\C{// LHS disambiguate, concatenate characters}$ 322 324 printf( "%c\n", @'a' * 3@ ); $\C{// no LHS information, ambiguous}$ … … 330 332 The substring operation returns a subset of a string starting at a position in the string and traversing a length, or matching a pattern string. 331 333 \begin{cquote} 332 \setlength{\tabcolsep}{ 10pt}333 \begin{tabular}{@{}l |ll|l@{}}334 \setlength{\tabcolsep}{8pt} 335 \begin{tabular}{@{}ll|ll@{}} 334 336 \multicolumn{2}{@{}c}{\textbf{length}} & \multicolumn{2}{c@{}}{\textbf{pattern}} \\ 335 337 \multicolumn{4}{@{}l}{\lstinline{string name = "PETER"}} \\ … … 350 352 "TER" // clip length to 3 351 353 "ER" 352 "" // beyond string to right, clip to null353 "" // beyond string to left, clip to null354 "" // clip, beyond right 355 "" // clip, beyond left 354 356 "ER" 355 357 "TER" // to end of string … … 390 392 Hence, the left string may decrease, stay the same, or increase in length. 391 393 \begin{cquote} 392 \begin{tabular}{@{}l |l@{}}394 \begin{tabular}{@{}ll@{}} 393 395 \begin{cfa}[escapechar={}] 394 396 digit( 3, 3 ) = ""; … … 408 410 \end{tabular} 409 411 \end{cquote} 410 Nowsubstring pattern matching is useful on the left-hand side of assignment.411 \begin{cquote} 412 \begin{tabular}{@{}l |l@{}}412 Here, substring pattern matching is useful on the left-hand side of assignment. 413 \begin{cquote} 414 \begin{tabular}{@{}ll@{}} 413 415 \begin{cfa}[escapechar={}] 414 416 digit( "$$" ) = "345"; … … 422 424 \end{tabular} 423 425 \end{cquote} 424 Extending the pattern to a regular expression is a possible extension.426 Supporting a regular-expression pattern is a possible extension. 425 427 426 428 The replace operation extends substring to substitute all occurrences. 427 429 \begin{cquote} 428 \begin{tabular}{@{}l |l@{}}430 \begin{tabular}{@{}ll@{}} 429 431 \begin{cfa} 430 432 s = replace( "PETER", "E", "XX" ); … … 448 450 If the key does not appear in the string, the length of the string is returned. 449 451 \begin{cquote} 450 \begin{tabular}{@{}l |l@{}}452 \begin{tabular}{@{}ll@{}} 451 453 \begin{cfa} 452 454 i = find( digit, '3' ); … … 465 467 A character-class operation indicates if a string is composed completely of a particular class of characters, \eg, alphabetic, numeric, vowels, \etc. 466 468 \begin{cquote} 467 \begin{tabular}{@{}l |l@{}}469 \begin{tabular}{@{}ll@{}} 468 470 \begin{cfa} 469 471 charclass vowels{ "aeiouy" }; … … 484 486 Function @exclude@ is the reverse of @include@, checking if all characters in the string are excluded from the class (compliance). 485 487 \begin{cquote} 486 \begin{tabular}{@{}l |l@{}}488 \begin{tabular}{@{}ll@{}} 487 489 \begin{cfa} 488 490 i = exclude( "cdbfghmk", vowels ); … … 498 500 Both forms can return the longest substring of compliant characters. 499 501 \begin{cquote} 500 \begin{tabular}{@{}l |l@{}}502 \begin{tabular}{@{}ll@{}} 501 503 \begin{cfa} 502 504 s = include( "aaeiuyoo", vowels ); … … 517 519 There are also versions of @include@ and @exclude@, returning a position or string, taking a validation function, like one of the C character-class functions.\footnote{It is part of the hereditary of C that these function take and return an \lstinline{int} rather than a \lstinline{bool}, which affects the function type.} 518 520 \begin{cquote} 519 \begin{tabular}{@{}l |l@{}}521 \begin{tabular}{@{}ll@{}} 520 522 \begin{cfa} 521 523 i = include( "1FeC34aB", @isxdigit@ ); … … 536 538 The translate operation returns a string with each character transformed by one of the C character transformation functions. 537 539 \begin{cquote} 538 \begin{tabular}{@{}l |l@{}}540 \begin{tabular}{@{}ll@{}} 539 541 \begin{cfa} 540 542 s = translate( "abc", @toupper@ ); … … 559 561 However, string search can fail, which is reported as an alternate search outcome, possibly an exception. 560 562 Many string libraries use a return code to indicate search failure, with a failure value of @0@ or @-1@ (PL/I~\cite{PLI} returns @0@). 561 This semantics leads to theawkward pattern, which can appear many times in a string library or user code.563 This semantics leads to an awkward pattern, which can appear many times in a string library or user code. 562 564 \begin{cfa} 563 565 i = exclude( s, alpha ); … … 565 567 else return ""; 566 568 \end{cfa} 569 The problem is that substring does the wrong thing or fails with the failure return-code in most string libraries, so it has to be special cased. 567 570 568 571 \CFA adopts a return code but the failure value is taken from the index-of function in APL~\cite{apl}, which returns the length of the target string $N$ (or $N+1$ for 1 origin). … … 582 585 \begin{figure} 583 586 \begin{cquote} 584 \begin{tabular}{@{}l |l@{}}587 \begin{tabular}{@{}ll@{}} 585 588 \multicolumn{1}{c}{\textbf{\CC}} & \multicolumn{1}{c}{\textbf{\CFA}} \\ 586 589 \begin{cfa} … … 628 631 \begin{cquote} 629 632 \begin{tabular}{@{}ll@{}} 630 \ begin{cfa}631 char s[32]; // string s; 633 \multicolumn{2}{@{}l@{}}{\lstinline{char s[32]; // changing s's type to string works}} \\ 634 \begin{cfa} 632 635 strlen( s ); 633 636 strnlen( s, 3 ); … … 637 640 & 638 641 \begin{cfa} 639 640 642 strcpy( s, "abc" ); 641 643 strncpy( s, "abcdef", 3 ); … … 651 653 \subsection{I/O Operators} 652 654 653 The ability to input and output stringsis as essential as for any other type.654 The goal for character I/O is to alsowork with groups rather than individual characters.655 The ability to input and output a string is as essential as for any other type. 656 The goal for character I/O is to work with groups rather than individual characters. 655 657 A comparison with \CC string I/O is presented as a counterpoint to \CFA string I/O. 656 658 … … 659 661 The \CC manipulators are @setw@, and its associated width controls @left@, @right@ and @setfill@. 660 662 \begin{cquote} 661 \begin{tabular}{@{}l |l@{}}663 \begin{tabular}{@{}ll@{}} 662 664 \begin{c++} 663 665 string s = "abc"; … … 676 678 The \CFA manipulators are @bin@, @oct@, @hex@, @wd@, and its associated width control and @left@. 677 679 \begin{cquote} 678 \begin{tabular}{@{}l |l@{}}680 \begin{tabular}{@{}ll@{}} 679 681 \begin{cfa} 680 682 string s = "abc"; … … 704 706 Reading into a @char@ is safe as the size is 1, @char *@ is unsafe without using @setw@ to constraint the length (which includes @'\0'@), @string@ is safe as its grows dynamically as characters are read. 705 707 \begin{cquote} 706 \begin{tabular}{@{}l |l@{}}708 \begin{tabular}{@{}ll@{}} 707 709 \begin{c++} 708 710 char ch, c[10]; … … 721 723 \end{cquote} 722 724 Input text can be \emph{gulped}, including whitespace, from the current point to an arbitrary delimiter character using @getline@. 725 \begin{cquote} 726 \setlength{\tabcolsep}{10pt} 727 \begin{tabular}{@{}ll@{}} 728 \multicolumn{1}{c}{\textbf{\CC}} & \multicolumn{1}{c}{\textbf{\CFA}} \\ 729 \begin{cfa} 730 string s1, s2, s3; 731 getline( cin, s1, 'a' ); 732 getline( cin, s2, 'w' ); 733 getline( cin, s3 ); 734 cout << s1 << ' ' << s2 << ' ' << s3 << endl; 735 @bbbad ddwxyz@ 736 \end{cfa} 737 & 738 \begin{cfa} 739 740 sin | getline( s1, 'a' ) 741 | getline( s2, 'w' ) 742 | getline( s3 ); 743 sout | s1 | s2 | s3; "bbb" "d dd" "xyz" 744 745 \end{cfa} 746 \end{tabular} 747 748 \end{cquote} 723 749 724 750 The \CFA philosophy for input is that, for every constant type in C, these constants should be usable as input. … … 730 756 \begin{cquote} 731 757 \setlength{\tabcolsep}{10pt} 732 \begin{tabular}{@{}l |l@{}}758 \begin{tabular}{@{}ll@{}} 733 759 \begin{c++} 734 760 char ch, c[10]; … … 736 762 sin | ch | wdi( 5, c ) | s; 737 763 @abcde fg@ 738 sin | quote( ch ) | quote( wdi( sizeof(c), c ) ) | quote( s, '[', ']' ) | nl;739 @'a' "bcde"[fg]@764 sin | @quote@( ch ) | @quote@( wdi( sizeof(c), c ) ) | @quote@( s, '[', ']' ) | nl; 765 @'a' "bcde" [fg]@ 740 766 sin | incl( "a-zA-Z0-9 ?!&\n", s ) | nl; 741 767 @x?&000xyz TOM !.@ … … 767 793 For example, the \CC @replace@ function selects a substring in the target and substitutes it with the source string, which can be smaller or larger than the substring. 768 794 \CC modifies the mutable receiver object, replacing by position (zero origin) and length. 769 \begin{cquote}770 \begin{tabular}{@{}l|l@{}}771 795 \begin{c++} 772 796 string s1 = "abcde"; 773 s1.replace( 2, 3, "xy" ); 797 s1.replace( 2, 3, "xy" ); "abxy" 774 798 \end{c++} 775 &776 \begin{c++}777 778 "abxy"779 \end{c++}780 \end{tabular}781 \end{cquote}782 799 Java cannot modify the receiver (immutable strings) so it returns a new string, replacing by text. 783 800 \label{p:JavaReplace} 784 \begin{cquote}785 \begin{tabular}{@{}l|l@{}}786 801 \begin{java} 787 802 String s = "abcde"; 788 String r = s.replace( "cde", "xy" ); 803 String r = s.replace( "cde", "xy" ); "abxy" 789 804 \end{java} 790 &791 \begin{java}792 793 "abxy"794 \end{java}795 \end{tabular}796 \end{cquote}797 805 Java also provides a mutable @StringBuffer@, replacing by position (zero origin) and length. 798 \begin{cquote}799 \begin{tabular}{@{}l|l@{}}800 806 \begin{java} 801 807 StringBuffer sb = new StringBuffer( "abcde" ); 802 sb.replace( 2, 5, "xy" ); 808 sb.replace( 2, 5, "xy" ); "abxy" 803 809 \end{java} 804 &805 \begin{java}806 807 "abxy"808 \end{java}809 \end{tabular}810 \end{cquote}811 810 However, there are anomalies. 812 811 @StringBuffer@'s @substring@ returns a @String@ copy that is immutable rather than modifying the receiver. … … 818 817 \begin{figure} 819 818 \setlength{\extrarowheight}{2pt} 820 \begin{tabularx}{\textwidth}{@{}p{0.6in}XXcccc@{}} 819 \setlength{\tabcolsep}{5pt} 820 \begin{tabularx}{\textwidth}{@{}p{0.8in}XXcccc@{}} 821 821 & & & \multicolumn{4}{@{}c@{}}{\underline{Supports Helpful?}} \\ 822 822 & Required & Helpful & C & \CC & Java & \CFA \\ 823 823 \hline 824 Type abst'n824 Type Abstraction 825 825 & Low-level: The string type is a varying amount of text communicated via a parameter or return. 826 826 & High-level: The string-typed relieves the user of managing memory for the text. … … 913 913 String s3 = s2.substring( 1, 2 ); $\C{// snapshot state (possible), strict symmetry, fragment referent}\CRT$ 914 914 System.out.println( s + ' ' + s1 + ' ' + s2 + ' ' + s3 ); 915 $\texttt{\small abcde abcde bc c}$ 915 916 System.out.println( (s == s1) + " " + (s == s2) + " " + (s2 == s3) ); 916 $\texttt{\small abcde abcde bc c}$917 917 $\texttt{\small true false false}$ 918 918 \end{java} … … 939 939 string s3 = s`share; $\C{// alias state, strict symmetry, variable-constrained referent}$ 940 940 string s4 = s( 1, 2 ); $\C{// snapshot state, strict symmetry, fragment referent}$ 941 string s5 = s4( 1, 1 )`share '; $\C{// alias state, strict symmetry, fragment referent}\CRT$941 string s5 = s4( 1, 1 )`share; $\C{// alias state, strict symmetry, fragment referent}\CRT$ 942 942 sout | s | s1 | s2 | s3 | s4 | s5; 943 943 $\texttt{\small abcde abcde abcde abcde bc c}$ … … 995 995 996 996 String sharing is expressed using the @`share@ marker to indicate aliasing (mutations shared) \vs snapshot (not quite an immutable result, but one with subsequent mutations isolated). 997 This aliasing relationship is a sticky propertyestablished at initialization.997 This aliasing relationship is a \newterm{sticky property} established at initialization. 998 998 For example, here strings @s1@ and @s1a@ are in an aliasing relationship, while @s2@ is in a copy relationship. 999 999 \input{sharing1.tex} … … 1030 1030 When changes happen on an aliasing substring that overlap. 1031 1031 \input{sharing10.tex} 1032 Strings @s1_crs@ and @s1_mid@ overlap at character 4, @ j@, because the substrings are 3,2 and 4,2.1032 Strings @s1_crs@ and @s1_mid@ overlap at character 4, @'j'@, because the substrings are 3,2 and 4,2. 1033 1033 When @s1_crs@'s size increases by 1, @s1_mid@'s starting location moves from 4 to 5, but the overlapping character remains, changing to @'+'@. 1034 1034 … … 1136 1136 Normally, one global context is appropriate for an entire program; 1137 1137 concurrency is discussed in \VRef{s:ControllingImplicitSharing}. 1138 A string is a handle to a node in a linked list containing ainformation about a string text in the buffer.1138 A string is a handle to a node in a linked list containing information about a string text in the buffer. 1139 1139 The list is doubly linked for $O(1)$ insertion and removal at any location. 1140 1140 Strings are ordered in the list by text start address. … … 1151 1151 The linked handles define all live strings in the buffer, which indirectly defines the allocated and free space in the buffer. 1152 1152 The string handles are maintained in sorted order, so the handle list can be traversed, copying the first live text to the start of the buffer, and subsequent strings after each other. 1153 After compaction, if free storage is still beless than the new string allocation, a larger text buffer is heap-allocated, the current buffer is copied into the new buffer, and the original buffer is freed.1153 After compaction, if free storage is still less than the new string allocation, a larger text buffer is heap-allocated, the current buffer is copied into the new buffer, and the original buffer is freed. 1154 1154 Note, the list of string handles is structurally unaffected during a compaction; 1155 1155 only the text pointers in the handles are modified to new buffer locations. … … 1158 1158 There are two fundamental string-creation functions: importing external text like a C-string or reading a string, and initialization from an existing \CFA string. 1159 1159 When importing, storage comes from the end of the buffer, into which the text is copied. 1160 T he new string handle is inserted at the end of the handle list because the new text is at the end of the buffer.1160 To maintain sorted order, the new string handle is inserted at the end of the handle list because the new text is at the end of the buffer. 1161 1161 When initializing from text already in the buffer, the new handle is a second reference into the original run of characters. 1162 In this case, the new handle's linked-list position is after the original handle.1162 To maintain sorted order, the new handle's linked-list position is after the original handle. 1163 1163 Both string initialization styles preserve the string module's internal invariant that the linked-list order matches the buffer order. 1164 1164 For string destruction, handles are removed from the list. … … 1177 1177 Favourable conditions allow for in-place editing: where there is room for the resulting value in the original buffer location, and where all handles referring to the original buffer location see the new value. 1178 1178 One notable example of favourable conditions occurs because the most recently written string is often the last in the buffer, after which a large amount of free space occurs. 1179 So, repeated appends often occur without copying previously accumulated characters.1179 Now, repeated appends (reading) can occur without copying previously accumulated characters. 1180 1180 However, the general case requires a new buffer allocation: where the new value does not fit in the old place, or if other handles are still using the old value. 1181 1181 … … 1194 1194 Both \CC and \CFA RAII systems are powerful enough to achieve reference counting. 1195 1195 1196 In general, a lifecycle function has access to an object by location, \ie constructors and destructors receive a @this@ parameter providing an object's memory address. 1196 In general, a lifecycle function has access to an object by location, \ie constructors and destructors receive a parameter providing an object's memory address.\footnote{ 1197 Historically in \CC, the type of \lstinline[language=C++]{this} is a pointer versus a reference; 1198 in \CFA, the first parameter of a constructor or destructor must be a reference.} 1197 1199 \begin{cfa} 1198 1200 struct S { int * ip; }; 1199 1201 void ?{}( S & @this@ ) { this.ip = new(); } $\C[3in]{// default constructor}$ 1200 void ?{}( S & @this@, int i ) { (this){}; *this.ip = i; } $\C{// initializing constructor}$1201 void ?{}( S & @this@, S s ) { (this){*s.ip}; } $\C{// copy constructor}$1202 void ?{}( S & @this@, int i ) { this{}; *this.ip = i; } $\C{// initializing constructor}$ 1203 void ?{}( S & @this@, S s ) { this{ *s.ip }; } $\C{// copy constructor}$ 1202 1204 void ^?{}( S & @this@ ) { delete( this.ip ); } $\C{// destructor}\CRT$ 1203 1205 \end{cfa} 1204 1206 Such basic examples use the @this@ address only to gain access to the values being managed. 1205 But the lifecycle logic can use the pointer generally, too. 1206 For example, they can add @this@ object to a collection at creation and remove it at destruction. 1207 \begin{cfa} 1208 // header 1209 struct T { 1207 But lifecycle logic can use the address, too, \eg add the @this@ object to a collection at creation and remove it at destruction. 1208 \begin{cfa} 1209 // header (.hfa) 1210 struct N { $\C[3in]{// list node}$ 1210 1211 // private 1211 inline dlink( T);1212 inline dlink( N ); 1212 1213 }; 1213 void ?{}( T & ); $\C[3in]{// default constructor}$1214 void ^?{}( T& ); $\C{// destructor}\CRT$1215 // implementation 1216 static dlist( T) @all_T@;1217 void ?{}( T & this ) { insert_last(all_T, @this@) }1218 void ^?{}( T & this ) { remove(this); }1219 \end{cfa} 1220 A module providing the @ T@ type can traverse @all_T@ at relevant times, to keep the objects ``good.''1221 Hence, declaring a @ T@ not only ensures that it begins with an initially ``good'' value, but it also provides an implicit subscription to a service that keeps the value ``good'' during its lifetime.1214 void ?{}( N & ); $\C{// default constructor}$ 1215 void ^?{}( N & ); $\C{// destructor}\CRT$ 1216 // implementation (.cfa) 1217 static dlist( N ) @list_N@; 1218 void ?{}( N & this ) { insert_last( list_N, @this@ ) } 1219 void ^?{}( N & this ) { remove( this ); } 1220 \end{cfa} 1221 A module providing the @N@ (node) type can traverse @list_N@ to manipulate the objects. 1222 Hence, declaring a @N@ not only ensures that it begins with an initially ``good'' value, but it also provides an implicit subscription to a service that keeps the value ``good'' during its lifetime. 1222 1223 Again, both \CFA and \CC support this usage style. 1223 1224 … … 1226 1227 In the parameter direction, the language's function-call handling must arrange for a copy-constructor call to happen, at a time near the control transfer into the callee. %, with the source as the caller's (sender's) version and the target as the callee's (receiver's) version. 1227 1228 In the return direction, the roles are reversed and the copy-constructor call happens near the return of control. 1228 \CC supports this capability. % without qualification.1229 \CC supports this capability. % without qualification. 1229 1230 \CFA offers limited support; 1230 simple examples work, but implicit copying does not combine successfully with the other RAII capabilities discussed.1231 simple examples work, but implicit copying does not combine successfully with other RAII capabilities. 1231 1232 1232 1233 \CC also offers move constructors and return-value optimization~\cite{RVO20}. … … 1239 1240 \begin{enumerate} 1240 1241 \item 1242 \label{p:feature1} 1241 1243 Object provider implements lifecycle functions to manage a resource outside of the object. 1242 1244 \item 1243 Object provider implements lifecycle functions to store references back to the object, often originating from outside of it. 1245 \label{p:feature2} 1246 Object provider implements lifecycle functions to store references to the object, often originating from outside of it. 1244 1247 \item 1248 \label{p:feature3} 1245 1249 Object user expects to pass (in either direction) an object by value for function calls. 1246 1250 \end{enumerate} 1247 \CC supports all three simultaneously. \CFA does not currently support \#2 and \#3 on the same object, though \#1 works along with either one of \#2 or \#3. \CFA needs to be fixed to support all three simultaneously. 1248 1249 The reason that \CFA does not support \#2 with \#3 is a holdover from how \CFA function calls lowered to C, before \CFA got references and RAII. 1250 At that time, adhering to a principal of minimal intervention, this code could always be treated as passthrough: 1251 \CC supports all three simultaneously. 1252 \CFA does not currently support \ref{p:feature2} and \ref{p:feature3} on the same object, though \ref{p:feature1} works along with either one of \ref{p:feature2} or \ref{p:feature3}. 1253 \CFA needs to be fixed to support all three simultaneously. 1254 1255 The reason \CFA does not support \ref{p:feature2} with \ref{p:feature3} is a holdover from how \CFA lowered function calls to C, before \CFA got references and RAII. 1256 At that time, adhering to a principal of minimal intervention, this code was treated as a passthrough: 1251 1257 \begin{cfa} 1252 1258 struct U { ... }; 1253 1259 // RAII to go here 1254 void f( U u ) { F_BODY( u) }1260 void f( U u ) { F_BODY( u ) } 1255 1261 U x; 1256 1262 f( x ); 1257 1263 \end{cfa} 1258 But adding custom RAII (at ``...go here'') changes things. 1259 The common \CC lowering~\cite[Sec. 3.1.2.3]{cxx:raii-abi} proceeds differently than the present \CFA lowering. 1260 \begin{cquote} 1264 However, adding custom RAII (at ``...go here'') changes things. 1265 1266 \VRef[Figure]{f:CodeLoweringRAII} shows the common \CC lowering~\cite[Sec. 3.1.2.3]{cxx:raii-abi} (right) proceeds differently than the present \CFA lowering (left). 1267 The current \CFA scheme is still using a by-value C call. 1268 C does a @memcpy@ on structures passed by value. 1269 And so, @F_BODY@ sees the bits of @__u_for_f@ occurring at an address that has never been presented to the @U@ lifecycle functions. 1270 If @U@ is trying to have a style- \ref{p:feature2} invariant, it shows up broken in @F_BODY@: references supposedly to @u@ are actually to @__u_for_f@. 1271 The \CC scheme does not have this problem because it constructs the @u@ copy in the correct location within @f@. 1272 Yet, the current \CFA scheme is sufficient to deliver style-\ref{p:feature1} invariants (in this style-\ref{p:feature3} use case) because this scheme still does the correct number of lifecycle calls, using correct values, at correct times. 1273 So, reference-counting or simple ownership applications get their invariants respected under call/return-by-value. 1274 1275 \begin{figure} 1276 \centering 1261 1277 \begin{tabular}{@{}l|l@{}} 1262 \begin{cfa} 1263 $\C[0.0in]{// \CC, \CFA future}\CRT$ 1278 \multicolumn{1}{@{}c|}{\CFA today} & \multicolumn{1}{c@{}}{\CC, \CFA future} \\ 1279 \begin{cfa} 1280 struct U {...}; 1281 // RAII elided 1282 void f( U u ) { 1283 1284 F_BODY( u ); 1285 1286 } 1287 U x; // call default ctor 1288 { 1289 @U __u_for_f = x;@ // call copy ctor 1290 f( __u_for_f ); 1291 // call dtor, __u_for_f 1292 } 1293 // call dtor, x 1294 \end{cfa} 1295 & 1296 \begin{cfa} 1264 1297 struct U {...}; 1265 1298 // RAII elided 1266 1299 void f( U * __u_orig ) { 1267 U u = * __u_orig;// call copy ctor1300 @U u = * __u_orig;@ // call copy ctor 1268 1301 F_BODY( u ); 1269 1302 // call dtor, u … … 1277 1310 // call dtor, x 1278 1311 \end{cfa} 1279 & 1280 \begin{cfa} 1281 $\C[0.0in]{// \CFA today}\CRT$ 1282 struct U {...}; 1283 // RAII elided 1284 void f( U u ) { 1285 1286 F_BODY( u ); 1287 1288 } 1289 U x; // call default ctor 1290 { 1291 U __u_for_f = x; // call copy ctor 1292 f( __u_for_f ); 1293 // call dtor, __u_for_f 1294 } 1295 // call dtor, x 1296 \end{cfa} 1297 \end{tabular} 1298 \end{cquote} 1299 The current \CFA scheme is still using a by-value C call. 1300 C does a @memcpy@ on structures passed by value. 1301 And so, @F_BODY@ sees the bits of @__u_for_f@ occurring at an address that has never been presented to the @U@ lifecycle functions. 1302 If @U@ is trying to have a style-\#2 invariant, it shows up broken in @F_BODY@: references supposedly to @u@ are actually to @__u_for_f@. 1303 The \CC scheme does not have this problem because it constructs the for @f@ copy in the correct location within @f@. 1304 1305 Yet, the current \CFA scheme is sufficient to deliver style-\#1 invariants (in this style-\#3 use case) because this scheme still does the correct number of lifecycle calls, using correct values, at correct times. 1306 So, reference-counting or simple ownership applications get their invariants respected under call/return-by-value. 1312 \end{tabular} 1313 1314 \caption{Code Lowering for RAII} 1315 \label{f:CodeLoweringRAII} 1316 \end{figure} 1307 1317 1308 1318 % [Mike is not currently seeing how distinguishing initialization from assignment is relevant] … … 1338 1348 % The following discusses the consequences of this semantics with respect to lifetime management of \CFA strings. 1339 1349 1340 The string API offers style \ #3's pass-by-value in, \eg in the return of @"a" + "b"@.1341 Its implementation uses the style-\ #2invariant of the string handles being linked to each other, helping to achieve high performance.1350 The string API offers style \ref{p:feature3}'s pass-by-value, \eg in the return of @"a" + "b"@. 1351 Its implementation uses the style-\ref{p:feature2} invariant of the string handles being linked to each other, helping to achieve high performance. 1342 1352 Since these two RAII styles cannot coexist, a workaround splits the API into two layers: one that provides pass-by-value, built upon the other with inter-linked handles. 1343 1353 The layer with pass-by-value incurs a performance penalty, while the layer without delivers the desired runtime performance. … … 1345 1355 Both APIs present the same features, up to return-by-value operations being unavailable in LL and implemented via the workaround in HL. 1346 1356 The intention is for most future code to target HL. 1347 When the RAII issue is fixed, the full HL feature set will be achievable using the LL-style lifetime management. 1348 Then, HL will be removed; 1349 LL's type will be renamed @string@ and programs written for current HL will run faster. 1357 When the RAII issue is fixed, the full HL feature set is achievable using the LL-style lifetime management. 1358 Then, HL can be removed, LL's type renamed to @string@, and programs generated with the current HL will run faster. 1350 1359 In the meantime, performance-critical sections of applications must use LL. 1351 1360 Subsequent performance experiments \see{\VRef{s:PerformanceAssessment}} use the LL API when comparing \CFA to other languages. 1352 1361 This measurement gives a fair estimate of the goal state for \CFA. 1353 1362 A separate measure of the HL overhead is also included. 1354 hence, \VRef[Section]{string-general-impl} us describing the goal state for \CFA.1355 In present state, the type @string_res@ replaces its mention of @string@ asinter-linked handle.1363 Hence, \VRef[Section]{string-general-impl} is describing the goal state for \CFA. 1364 In present state, the internal type @string_res@ replaces @string@ for an inter-linked handle. 1356 1365 1357 1366 To use LL, a programmer rewrites invocations using pass-by-value APIs into invocations where resourcing is more explicit. 1358 1367 Many invocations are unaffected, notably assignment and comparison. 1359 Of the capabilities listed in \VRef[Figure]{f:StrApiCompare}, only the following three cases need revisions. 1360 \begin{cquote} 1361 \begin{tabular}{ll} 1368 \VRef[Figure]{f:HL_LL_Lowering} shows, of the capabilities listed in \VRef[Figure]{f:StrApiCompare}, only three cases need revisions. 1369 The actual HL workaround wraps @string@ as a pointer to a uniquely owned, heap-allocated @string_res@. 1370 This arrangement has @string@ using style-\ref{p:feature1} RAII, which is compatible with pass-by-value. 1371 1372 \begin{figure} 1373 \centering 1374 \begin{tabular}{@{}ll@{}} 1362 1375 HL & LL \\ 1363 1376 \hline … … 1375 1388 \begin{cfa} 1376 1389 string s = "abcde"; 1377 string s2 = s(2, 3); // s2 == "cde"1378 1379 s(2,3) = "x"; // s == "abx" && s2 == "cde"1390 string s2 = s(2, 3); // s2 == "cde" 1391 1392 s(2,3) = "x"; // s == "abx" && s2 == "cde" 1380 1393 \end{cfa} 1381 1394 & 1382 1395 \begin{cfa} 1383 1396 string_res sr = "abcde"; 1384 string_res sr2 = {sr, 2, 3}; // sr2 == "cde"1397 string_res sr2 = {sr, 2, 3}; // sr2 == "cde" 1385 1398 string_res sr_mid = { sr, 2, 3, SHARE }; 1386 sr_mid = "x"; // sr == "abx" && sr2 == "cde"1399 sr_mid = "x"; // sr == "abx" && sr2 == "cde" 1387 1400 \end{cfa} 1388 1401 \\ … … 1391 1404 string s = "abcde"; 1392 1405 1393 s[2] = "xxx"; // s == "abxxxde"1406 s[2] = "xxx"; // s == "abxxxde" 1394 1407 \end{cfa} 1395 1408 & … … 1397 1410 string_res sr = "abcde"; 1398 1411 string_res sr_mid = { sr, 2, 1, SHARE }; 1399 mid = "xxx"; // sr == "abxxxde" 1400 \end{cfa} 1401 \end{tabular} 1402 \end{cquote} 1403 The actual HL workaround is having @string@ wrap a pointer to a uniquely owned, heap-allocated @string_res@. This arrangement has @string@ being style-\#1 RAII, which is compatible with pass-by-value. 1412 mid = "xxx"; // sr == "abxxxde" 1413 \end{cfa} 1414 \end{tabular} 1415 1416 \caption{HL to LL Lowering} 1417 \label{f:HL_LL_Lowering} 1418 \end{figure} 1404 1419 1405 1420 … … 1505 1520 It might be possible to pack 16- or 32-bit Unicode characters within the same string buffer as 8-bit characters. 1506 1521 Again, locations for identification flags must be found and checked along the fast path to select the correct actions. 1507 Handling utf8 (variable length) ,is more problematic because simple pointer arithmetic cannot be used to stride through the variable-length characters.1522 Handling utf8 (variable length) is more problematic because simple pointer arithmetic cannot be used to stride through the variable-length characters. 1508 1523 Trying to use a secondary array of fixed-sized pointers/offsets to the characters is possible, but raises the question of storage management for the utf8 characters themselves. 1509 1524 … … 1513 1528 1514 1529 I assessed the \CFA string library's speed and memory usage against strings in \CC STL. 1515 Overall, this analysis shows that adding support for the features shown earlier in the chapter comes at no substantial cost in the performance of features common to both APIs. 1516 1517 Moreover, the results support the \CFA string's position as a high-level enabler of simplified text processing. 1518 STL makes its user think about memory management. 1530 Overall, this analysis shows that features common to both APIs comes at no substantial cost in the performance. 1531 Moreover, the comparison shows that \CFA's high-level string features simplify text processing because the STL requires users to think more about memory management. 1519 1532 When the user does, and is successful, STL's performance can be very good. 1520 But when the user fails to think throughthe consequences of the STL representation, performance becomes poor.1533 But if a user does understand the consequences of the STL representation, performance becomes poor. 1521 1534 The \CFA string lets the user work at the level of just putting the right text into the right variables, with corresponding performance degradations reduced or eliminated. 1522 1535 … … 1529 1542 These tests use a \emph{corpus} of strings. 1530 1543 Their lengths are important; the specific characters occurring in them are immaterial. 1531 In a result graph, a corpus's mean string length is often the independent variable shown on the X axis. 1532 1544 In a result graph, a corpus's mean string-length is often the independent variable on the x-axis. 1533 1545 When a corpus contains strings of different lengths, the lengths are drawn from a lognormal distribution. 1534 1546 Therefore, strings much longer than the mean occur less often and strings slightly shorter than the mean occur most often. … … 1544 1556 To ensure comparable results, a common memory allocator is used for \CFA and \CC. 1545 1557 \CFA runs the llheap allocator~\cite{Zulfiqar22}, which is also plugged into \CC. 1558 The llheap allocator is significantly better than the standard @glibc@ allocator. 1546 1559 1547 1560 The operations being measured take dozens of nanoseconds, so a succession of many invocations is run and timed as a group. … … 1636 1649 1637 1650 \VRef[Figure]{fig:string-graph-peq-cppemu} shows the resulting performance. 1638 The two fresh (solid ) lines and the two reuse (dash) linesare identical, except for lengths $\le$10, where the \CC SSO has a 40\% average and minimally 24\% advantage.1651 The two fresh (solid spline lines) and the two reuse (dash spline lines) are identical, except for lengths $\le$10, where the \CC SSO has a 40\% average and minimally 24\% advantage. 1639 1652 The gap between the fresh and reuse lines is the removal of the dynamic memory allocates and reuse of prior storage, \eg 100M allocations for fresh \vs 100 allocations for reuse across all experiments. 1640 1653 While allocation reduction is huge, data copying dominates the cost, so the lines are still reasonably close together. … … 1691 1704 In earlier experiments, the choice of \CFA API among HL and LL had no impact on the functionality being tested. 1692 1705 Here, however, the @+@ operation, which returns its result by value, is only available in HL. 1693 The \CFA @+@ number was obtained by inlining the HL implementation of @+@, which is done using LL's @+=@, into the test harness, while omitting the HL-inherent extra dynamic allocation. The HL-upon-LL @+@ implementation, is: 1694 \begin{cfa} 1695 struct string { 1696 string_res * inner; // RAII manages malloc/free, simple ownership 1706 The \CFA @+=@ is obtained by inlining the HL implementation of @+@, which is done using LL's @+=@, into the test harness, while omitting the HL-inherent extra dynamic allocation. The HL-upon-LL @+@ implementation, is: 1707 \begin{cquote} 1708 \setlength{\tabcolsep}{20pt} 1709 \begin{tabular}{@{}ll@{}} 1710 \begin{cfa} 1711 struct string { // simple ownership 1712 string_res * inner; // RAII manages malloc/free 1697 1713 }; 1698 1714 void ?+=?( string & s, string s2 ) { 1699 1715 (*s.inner) += (*s2.inner); 1700 1716 } 1717 \end{cfa} 1718 & 1719 \begin{cfa} 1701 1720 string @?+?@( string lhs, string rhs ) { 1702 1721 string ret = lhs; … … 1704 1723 return ret; 1705 1724 } 1706 \end{cfa} 1725 1726 \end{cfa} 1727 \end{tabular} 1728 \end{cquote} 1707 1729 This @+@ implementation is also the goal implementation of @+@ once the HL/LL workaround is no longer needed. Inlining the induced LL steps into the test harness gives: 1708 1730 \begin{cquote} … … 1750 1772 So again, \CFA helps users who just want to treat strings as values, and not think about the resource management under the covers. 1751 1773 1752 While not a design goal, and not graphed, \CFA in STL-emulation mode outperformed STL in this case.1753 User-managed allocation reuse did not affect either implementation in this case; only ``fresh'' results are shown. 1774 \PAB{Something is wrong with these sentences: While not a design goal, and not graphed, \CFA in STL-emulation mode outperformed STL in this case. 1775 User-managed allocation reuse did not affect either implementation in this case; only ``fresh'' results are shown.} 1754 1776 1755 1777 … … 1768 1790 \end{cfa} 1769 1791 With implicit sharing active, \CFA treats this operation as normal and supported. 1770 1771 Again, an HL-LL difference requires an LL mockup. This time, the fact to integrate into the test harness is that LL does not directly support pass-by-value. 1792 Again, an HL-LL difference requires a mockup as LL does not directly support pass-by-value. 1772 1793 \begin{cquote} 1773 1794 \setlength{\tabcolsep}{20pt} … … 1797 1818 The goal (HL) version gives the modified test harness, with a single loop. 1798 1819 Each iteration uses a corpus item as the argument to the function call. 1799 These corpus items were imported to the string heap before beginning the timed run.1820 These corpus items are imported to the string heap before beginning the timed run. 1800 1821 1801 1822 \begin{figure} … … 1811 1832 1812 1833 \VRef[Figure]{fig:string-graph-pbv} shows the costs for calling a function that receives a string argument by value. 1813 STL's performance worsens uniformly as string length increases, while \CFA has the same performance at all sizes. 1814 Although the STL is better than \CFA until string length 10 because of the SSO. 1834 STL's performance worsens uniformly as string length increases, except for short strings due to SSO, while \CFA has the same performance at all sizes. 1815 1835 While improved, the \CFA cost to pass a string is still nontrivial. 1816 1836 The contributor is adding and removing the callee's string handle from the global list.
Note:
See TracChangeset
for help on using the changeset viewer.