[Issue 1923] New: GC optimization for contiguous pointers to the same page
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Mar 14 01:10:59 PDT 2008
http://d.puremagic.com/issues/show_bug.cgi?id=1923
Summary: GC optimization for contiguous pointers to the same page
Product: D
Version: 1.028
Platform: All
OS/Version: All
Status: NEW
Keywords: patch
Severity: enhancement
Priority: P3
Component: Phobos
AssignedTo: bugzilla at digitalmars.com
ReportedBy: thecybershadow at gmail.com
Probably the best practical example for this situation is splitting a large
text file by whitespace:
import std.file, std.string, std.gc;
import std.stdio: putr = writefln;
alias char[] string;
static import std.c.time;
double clock() {
auto t = std.c.time.clock();
return t/cast(double)std.c.time.CLOCKS_PER_SEC;
}
void main() {
//disable;
auto t0 = clock();
auto txt = cast(string)read("text.txt"); // 6.3 MB of text
auto t1 = clock();
auto words = txt.split();
auto t2 = clock();
putr("loading time: ", t1 - t0); // 0.08 s
putr("splitting time: ", t2 - t1); // 3.69 s with GC, 0.66 s without
// Total running time with GC = 10.85 s
}
Example is from this NG post by bearophile:
http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id=67673
The attached patch increases the performance of this particular case tenfold by
my tests. It should have no significant overhead on other situations. There's a
bit more info in my reply to the abovementioned NG post.
--
More information about the Digitalmars-d-bugs
mailing list