Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Ticket #982 (closed enhancement: fixed)

Opened 12 years ago

Last modified 12 years ago

GC optimization for contiguous pointers to the same page [Patch]

Reported by: CyberShadow Assigned to: sean
Priority: normal Milestone: 0.99.7
Component: Core Functionality Version: 0.99.5 Jascha
Keywords: Cc:


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() {
  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:

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.


tango.patch (1.2 kB) - added by CyberShadow on 03/14/08 07:52:43.

Change History

03/14/08 07:52:43 changed by CyberShadow

  • attachment tango.patch added.

03/14/08 17:43:50 changed by sean

  • status changed from new to assigned.

Pretty simple change for such an improvement. Thanks.

04/27/08 09:19:28 changed by larsivi

  • milestone changed from 0.99.6 to 0.99.7.

05/04/08 02:12:13 changed by sean

  • status changed from assigned to closed.
  • resolution set to fixed.

(In [3482]) Applied changes from #982. This closes #982

05/04/08 06:07:12 changed by kris