Ruby Enterpriseの高速化案(その3)

キャッシュを無効化(正確には汚染を少なくする)と299秒となりました。何もしないのが309秒なので、10秒早くなりました。

それにしても、GCをキャッシュを効かないようにしてわざと遅くすると、全体的には速くなるとは・・・。GC奥が深すぎる。

追記

すでに同じようなことをやっていた人がいらっしゃいました。
http://d.hatena.ne.jp/hyoshiok/20061002

このページからリンクされていた次のページが大変役に立ちました。
追記の追記: リンクされているのではなく、ページ中で言及されていた__builtin_prefetchをぐぐった結果でした。
http://www.yoh.u-tokyo.com/pukiwiki/?x86%2F%BE%AE%BC%EA%C0%E8%BA%C7%C5%AC%B2%BD

ソースをさらしておきます。

static inline struct heaps_slot *
find_heap_slot_for_object(RVALUE *object)
{
	register int i;

	/* Look in the cache first. */
	if (last_heap != NULL && object >= last_heap->slot
	 && object < last_heap->slotlimit) {
	        cnthit++;
		return last_heap;
	}
	cntmiss++;

#ifdef __GNUC__
	__builtin_prefetch(object, 0, 0);
#endif
	for (i = 0; i < heaps_used; i++) {
		struct heaps_slot *heap = &heaps[i];
		if (object >= heap->slot
		 && object < heap->slotlimit) {
			/* Cache this result. According to empirical evidence, the chance is
			 * high that the next lookup will be for the same heap slot.
			 */
			last_heap = heap;
			return heap;
		}
	}
	return NULL;
}