背景
资料中常见一些关于Runtime的名词,比如Java Runtime Environment(JRE),Spark Runtime,Runtime到底是什么呢?
Runtime来源
Runtime是指程序在运行阶段的时间,与Runtime对应的是程序生命周期中的其它阶段,例如compile time, link time 和 load time. 程序生命周期内的一些具体操作如下:
When a program is to be executed, a loader first performs the necessary memory setup and links the program with any dynamically linked libraries it needs, and then the execution begins starting from the program's entry point.
Runtime environment & Runtime library
每一种编程语言都有自己的执行模型(Execution model),执行模型定义了语言的一些规范,包括:什么是一个独立的工作单元,这些工作单元执行的约束条件。
For example, the addition operation is an indivisible unit of work in many languages, and in sequential languages such units of work are constrained to take place one after the other.
Runtime environment 是执行模型的实现部分。这个环境解决程序运行时的一些问题:应用如何分配内存,程序如何使用变量,程序之间传递参数的机制,与操作系统的交互。具体的,Runtime Environment 会建立和管理堆和栈,管理垃圾回收和线程操作等。
Runtime library (RTL) 封装了底层的操作,编译器用Runtime library产生的二进制文件来构建Runtime Environment.
Java Runtime Environment
The Java Runtime Environment is a software layer that runs on top of a computer's operating system, providing additional services specific to Java.
正是由于JRE,Java的 write once, run anywhere 原则才得以实现。
"rt.jar" 代表runtime JAR, 包括所有用于构建核心Java Runtime environment的所有编译好的类,例如java.lang.String
, java.lang.Thread
, java.util.ArrayList
和 java.io.InputStream
.
Ref: What is rt.jar in Java/JDK/JRE? Why it’s Important?
Spark Runtime Environment
Spark Runtime Environment (SparkEnv) is the runtime environment with Spark’s public services that interact with each other to establish a distributed computing platform for a Spark application.
Running Spark: an overview of Spark’s runtime architecture 介绍了Spark 是如何进行计算的。