Skip to content

Commit 9dae729

Browse files
committed
Release 0.2.3-r67
* Set default --max_old_space_size to 16384 * Allow to change --max_old_space_size also with option -M, which is shorter * Updated instructions on compiling k8, as gyp svn is offline now
1 parent 6d8797c commit 9dae729

File tree

2 files changed

+26
-16
lines changed

2 files changed

+26
-16
lines changed

README.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,15 @@ for a hash map without hitting the memory limit of V8.
3232

3333
You need to first compile V8 and then compile and link K8. Here is the full procedure:
3434

35-
git clone https://github.com/v8/v8 # download V8
36-
(cd v8; git checkout 3.16.4) # k8 only works with 3.16.x
37-
(cd v8; make dependencies; make x64.release) # compile V8
38-
g++ -O2 -Wall -o k8 -Iv8/include k8.cc -lpthread -lz v8/out/*/libv8_{base,snapshot}.a
35+
# download compilable V8 source code; K8 only works with v8-3.16
36+
wget -O- https://github.com/attractivechaos/k8/releases/download/v0.2.1/v8-3.16.4.tar.bz2 | tar jxf -
37+
# compile V8
38+
cd v8-3.16.4 && make -j4 x64.release
39+
# compile K8
40+
g++ -O2 -Wall -o k8 -Iinclude ../k8.cc -lpthread -lz `find out -name "libv8_*.a"|grep -v nosnap`
3941

40-
The two `libv8*.a` files should always be placed somewhere in `v8/out`, but
41-
maybe in a deeper directory, depending on the OS.
42-
43-
Alternatively, you may download the compiled binaries for Mac and Linux from
44-
[SourceForge][11]. The source code is also included.
42+
Alternatively, you may download the precompiled binaries for Mac and Linux from
43+
the [release page][release].
4544

4645
#### 4. An earlier version of K8 implemented a generic buffered stream. Why has it been removed?
4746

@@ -191,3 +190,5 @@ when we want to stage a huge hash table in memory. `Map` has the following metho
191190
[8]: http://nodejs.org/api/stream.html
192191
[9]: http://www.commonjs.org/specs/
193192
[11]: https://sourceforge.net/projects/lh3/files/
193+
[gyp]: https://gyp.gsrc.io/
194+
[release]: https://github.com/attractivechaos/k8/releases

k8.cc

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#define K8_VERSION "0.2.2-r65" // known to work with V8-3.16.14
1+
#define K8_VERSION "0.2.3-r67" // known to work with V8-3.16.14
22

33
#include <stdlib.h>
44
#include <stdint.h>
@@ -596,9 +596,9 @@ JS_METHOD(k8_file_readline, args) // see iStream::readline(sep=line) for details
596596
return ret >= 0? scope.Close(v8::Integer::New(dret)) : scope.Close(v8::Integer::New(ret));
597597
}
598598

599-
/**********************
599+
/******************
600600
*** Set object ***
601-
**********************/
601+
******************/
602602

603603
#include "khash.h"
604604
KHASH_MAP_INIT_STR(str, kh_cstr_t)
@@ -792,9 +792,19 @@ static v8::Persistent<v8::Context> CreateShellContext() // adapted from shell.cc
792792
int main(int argc, char* argv[])
793793
{
794794
v8::V8::SetFlagsFromCommandLine(&argc, argv, true);
795+
796+
// set --max_old_space_size. We have to do it before CreateShellContext(), I guess.
797+
int c;
798+
char flag_buf[256], *size = 0;
799+
while ((c = getopt(argc, argv, "ve:E:M:")) >= 0)
800+
if (c == 'M') size = optarg;
801+
strcat(strcpy(flag_buf, "--max_old_space_size="), size? size : "16384");
802+
v8::V8::SetFlagsFromString(flag_buf, strlen(flag_buf));
803+
opterr = optind = 1;
804+
795805
int ret = 0;
796806
if (argc == 1) {
797-
fprintf(stderr, "Usage: k8 [-v] [-e jsSrc] [-E jsSrc] <src.js> [arguments]\n");
807+
fprintf(stderr, "Usage: k8 [-v] [-e jsSrc] [-E jsSrc] [-M maxRSS] <src.js> [arguments]\n");
798808
return 1;
799809
}
800810
{
@@ -805,8 +815,7 @@ int main(int argc, char* argv[])
805815
return 1;
806816
}
807817
context->Enter();
808-
int i, c;
809-
while ((c = getopt(argc, argv, "ve:E:")) >= 0) // parse k8 related command line options
818+
while ((c = getopt(argc, argv, "ve:E:M:")) >= 0) // parse k8 related command line options
810819
if (c == 'e' || c == 'E') {
811820
if (!k8_execute(JS_STR(optarg), JS_STR("CLI"), (c == 'E'))) { // note the difference between 'e' and 'E'
812821
ret = 1;
@@ -816,7 +825,7 @@ int main(int argc, char* argv[])
816825
if (!ret && optind != argc) {
817826
v8::HandleScope scope2;
818827
v8::Local<v8::Array> args = v8::Array::New(argc - optind - 1);
819-
for (i = optind + 1; i < argc; ++i)
828+
for (int i = optind + 1; i < argc; ++i)
820829
args->Set(v8::Integer::New(i - optind - 1), JS_STR(argv[i]));
821830
context->Global()->Set(JS_STR("arguments"), args);
822831
if (!k8_execute(k8_readfile(argv[optind]), JS_STR(argv[optind]), false)) ret = 1;

0 commit comments

Comments
 (0)