Archive

Archive for October, 2012

TraceMonkey (not) in Firefox

October 28th, 2012 No comments

这个世界总是变化太快。浏览器的世界变化更快。

2008年左右加入到Firefox/SpiderMonkey中的Trace-based JIT引擎TraceMonkey,2011年10月份的时候被默认禁用(bug#697666),11月份的时候已经被David Anderson从Mozilla-Central中移除了(bug#698201)。

Nicholas Nethercote在他的博客中解释说,当时Firefox中有TraceMonkey(TM)和JaegerMonkey(JM)两个不同的JIT同时存在,而引入的Type Inference技术(TI)使得JM+TI的执行性能超过了JM+TM的执行速度。TM针对特定的代码优化的效果还是不错的,例如没有分支跳转的循环。但是在其它的代码情形下,不如JM(它是Method-based)。除此之外TM的代码的复杂性和内存消耗也是它被移除的原因之一。在移除前,TM的代码行数已经达到了67000+的规模,对于一个JS编译器来说已经是很大了。

TraceMonkey诞生的时候出了好几篇高质量的论文(PLDI’09, VEE’09),我也曾经想在上面做一些工作。想不到我还没有克服自己的拖延症,TraceMonkey就已经告别了。只能叹“相逢恨晚,造物弄人” :-D。

Multicore JIT in .NET 4.5

October 28th, 2012 No comments

前不久微软推出了 .NET 4.5,其中包含了一个 Multicore JIT。

这个Multicore JIT的目标是减少应用程序的启动时间,提高启动速度。根据相关的介绍,.NET程序在运行时需要先从平台无关的字节码翻译到本地码,这个过程就依赖JIT。如此JIT的运行时间就包含在了应用程序的启动时间内了。为了提高应用程序的启动时间,微软的做法是将JIT从主线程中拆出来,放在一个单独的线程中。在目前的多核平台上,这一个单独的线程可以和主线程并行的执行,减少用户的等待时间。

但是这样会遇到一个问题:一般情况下JIT是在程序的函数即将被执行的时候进行翻译的,这样就会导致主线程执行一个函数时,需要等待JIT进行即时编译,效果上跟把JIT放在主线程中没有什么区别。为了使JIT线程在翻译的时候主线程不至于停顿,就需要JIT能够提前判断接下来要执行的函数并进行编译。JIT不是神仙,能够未卜先知,于是微软给出来一个Profile-based的方案:启用Multicore JIT之前,首先要对应用程序进行Profiling,记录下程序在启动时调用的函数(代码)序列,并保存在文件中。下次应用程序启动的时候,Multicore JIT从Profile中读取函数调用序列并提前进行翻译。

理论上Multicore JIT最大能够缩短50%的启动时间,如果Profile信息和当前程序运行的情况是相同的话。最坏情况是Profile跟应用程序的当前执行情况完全不懂,那么可能就反而有降速了。

为什么只有一个JIT线程?用两个JIT线程会不会将启动速度缩短到原来的三分之一?我想,大概是因为以下的几个原因:

  • .NET环境中还有别的线程执行,应用程序本身也可能是多线程的,JIT能够使用的空闲核心不会太多;
  • 有不少的运行环境还是双核平台的,两个JIT线程不会增加速度;
  • 多个JIT线程会导致更多的并发数据访问和线程上下文切换开销,性能反而可能会下降;
  • 多个JIT线程开发难度更大,非确定性的bug会让调试的人发疯。

另外,看相关的文档,似乎微软的.NET环境中,应用程序只会被JIT一次,而不是像JVM(如Oracle HotSpot)一样有多个JIT编译器可以对一个函数生成多种不同的本地码。

以下是微软开发人员关于Multicore JIT的访谈视频,中间的是Multicore JIT程序经理Dan Taylor,右边是.NET性能架构师(Performance Architect)Vance Morrison,左边是Windows软件工程师Rick Brewster。Dan和Vance介绍Multicore JIT原理和初心,Rick现身说法用了Multicore JIT之后他开发的大型.NET桌面程序启动时间上的改进。

OCCP 2013: Call for Papers

October 22nd, 2012 No comments

一个新的 Workshop,做事务内存方向的同学可以关注下。

—————————————————————-

CALL FOR PAPERS

OCCP 2013

1st Workshop on Optimistic Cooperation in Concurrent Programming

Rome, Italy, March 16th, 2013
(collocated with ETAPS 2013)

http://www.scss.tcd.ie/Vasileios.Koutavas/occp-workshop/
—————————————————————-

* DESCRIPTION

Optimistic concurrency has long been accepted as a convenient method for programming systems where there is contention for resources. Traditionally in database systems and more recently in software transactional memory systems, optimistic concurrency is realized in the form of transactions, which the programmer can assume run isolated from their environment, thereby alleviating the need for explicit programming of locking schemes.

Recent research on concurrent programming models have lead to the realization in both academia and industry that optimistic concurrency can also be advantageous in programming systems where concurrent processes need to cooperate to perform a desired task. In such systems transactional isolation needs to be abandoned.  This brings forward numerous challenges in 1) the design and implementation of such systems, 2) the invention of appropriate programming language support for optimistic process cooperation, 3) the semantics, theory and verification of these systems.

This workshop aims to bring together researchers and practitioners from academia and industry who work on aspects of optimistic process cooperation. It also aims to connect the different research communities pertinent to this field. These include the programming language community, the systems community and the concurrent calculi community.

* SCOPE

Topics of interest include, but are not limited to:

– Programming language support for optimistic process cooperation.
– Semantics and theory of optimistic process cooperation.
– Compilation techniques and runtime systems.
– Calculi for modelling optimistic process cooperation in concurrent and distributed computing.
– Use of optimistic cooperation in the modelling of service-oriented and biological systems.
– Reversible computation.
– Static analysis and verification of systems employing optimistic process cooperation.
– Programming idioms for optimistic process cooperation.
– Applications where optimistic process cooperation can provide a significant benefit to the programmer.
– Experience reports of existing systems and prototypes employing forms of optimistic cooperation.

* INVITED SPEAKERS

– Suresh Jagannathan (Purdue University)
– Victor Luchangco (Oracle Labs)

* TUTORIALS

– Matthew Fluet  (Rochester Institute of Technology)  Transactional Events
– Vasileios Koutavas  (Trinity College Dublin)  Theory of Optimistic Cooperation

* PAPER SUBMISSION AND PUBLICATION

Submitted papers should contain previously unpublished complete work, work in progress, or experience reports. Submissions should be in PDF format, prepared using the EPTCS style (http://style.eptcs.org/), and should be from 7 to 15 pages long, including references. Papers must be submitted through the Easychair page of the workshop: http://www.easychair.org/conferences/?conf=occp2013

Accepted papers will be distributed in electronic preliminary proceedings at the workshop. Subsequently, selected papers will be invited for publication in a post-workshop refereed proceedings in Electronic Proceedings in Theoretical Computer Science.

* DATES

Abstract submission deadline:  17 December 2012
Paper submission deadline:  21 December 2012
Notification:  18 January 2013
Camera ready deadline:  22 February 2013

* ORGANISERS

Nick Benton  (Mircosoft Research)
Matthew Fluet  (Rochester Institute of Technology)
Matthew Hennessy  (Trinity College Dublin)
Vasileios Koutavas  (Trinity College Dublin)
Jens Palsberg  (UCLA)

微软推出TypeScript

October 11th, 2012 No comments

微软最近推出了 TypeScript 语言,用来提高 JavaScript 程序员的生产力。传奇人物 Anders Hejlsberg 参与了该项目的工作,这让 TypeScript 的未来充满了希望。ZDNet 作家 Mary Jo Foley 的这篇文章在上个月注意到了 Anders Hejlsberg 的简历进行了更新,可能参与了微软 JavaScript 相关团队的工作。

在 TypeScript 的官方页面上有一段大约一个小时的视频,Anders Hejlsberg 介绍了 TypeScript 的特性。Anders 的观点是目前使用 JavaScript 写大型程序非常的难(hard),而 TypeScript 可以让这个过程简单一些。语言上主要的改变,一个是增加了一些类型的限定,使得在编辑的时候能够更好的进行检查,另外一个是提供了一些传统 OOP 的抽象方式,可以不用原型继承来构造层级关系。

视频的亮点之一是 TypeScript 提供的界面的提示非常的给力,感觉很智能并且速度快。不知道在 VisualStudio 2012 上运行超大代码时性能是否跟得上。我尝试将 jQuery.min.js 丢入官网的在线编辑页面中,居然还能够吭哧吭哧断断续续的运行。

目前 TypeScript 是将 JavaScript 作为自己的目标语言,跟 JavaScript 能够做到完全兼容,这点跟 CoffeeScript 是不是有点类似?不知道 TypeScript 会不会在后续跟 Google Dart 语言绕开 JavaScript —— 希望不要。