forked from hunt-framework/hunt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
246 lines (189 loc) · 7.84 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
# disable prarallel builds.
.NOTPARALLEL:
# the -A option is important for garbage collection performance,
# a good value is about the size of the L2 cache of the cpu
# the default is set to 8M
# more info on rts opts below
N = 8
H = 500
A = 8
RTSPROF =
#RUNOPTS = +RTS -N$(N) -s $(RTSPROF) -K$(K)M -A$(A)M -H$(H)M -RTS
RUNOPTS = +RTS $(RTSPROF) -RTS
PATTERN =
SERVER = http://localhost:3000
EXE = $(shell [ -d ".cabal-sandbox" ] && echo ".cabal-sandbox/bin/hunt-server" || echo "hunt-server")
PROFSH = ./prof.sh
# profiling on/off
export PROF=0
# RandomData options
# min/max size of a document
export RD_SIZEMIN = 200
export RD_SIZEMAX = 200
# number of documents
export RD_NUMDOCS = 1000
# set test pattern
ifdef PATTERN
ifeq ($(action),test)
pattern = --test-options='-t $(PATTERN)'
endif
endif
# RTS options
# http://www.haskell.org/ghc/docs/latest/html/users_guide/runtime-control.html
# ------------------
# -N[<n>] Use <n> processors (default: 1, -N alone determines the number of
# processors to use automatically)
# -H<size> Sets the minimum heap size (default 0M) Egs: -H24m -H1G
# -A<size> Sets the minimum allocation area size (default 512k) Egs: -A1m -A10k
# -K<size> Sets the maximum stack size (default 80% avaliable RAM) Egs: -K32k -K512k (a low value causes stackoverflows)
# -t[<file>] One-line GC statistics (if <file> omitted, uses stderr)
# -s[<file>] Summary GC statistics (if <file> omitted, uses stderr)
# -S[<file>] Detailed GC statistics (if <file> omitted, uses stderr)
# default profiling options
PROFOPTS_DEFAULT=--enable-library-profiling --enable-executable-profiling --ghc-option=-auto-all
ifndef PROFOPTS
ifeq ($(PROF),1)
PROFOPTS=$(PROFOPTS_DEFAULT)
else
PROFOPTS=
endif
endif
# comma to use in functions
comma := ,
action = install
all: install
first-install: delete sandbox force-install
clean:
- $(MAKE) -e -C hunt-test/data/random clean
- $(MAKE) -e -C hunt-test/data/jokes clean
- $(MAKE) target action=clean PROFOPTS=''
cleanData:
- $(MAKE) -e -C hunt-test/data/random cleanData
- $(MAKE) -e -C hunt-test/data/jokes cleanData
delete: clean
- $(MAKE) -e -C hunt-test/data/random delete
- $(MAKE) -e -C hunt-test/data/jokes delete
- rm -rf .cabal-sandbox/
configure: ; $(MAKE) -e target action=configure
build: ; $(MAKE) -e target action=build PROFOPTS=''
install: ; $(MAKE) -e target action=install
force-install: ; $(MAKE) -e target action=install PROFOPTS="--force-reinstalls $(PROFOPTS)"
#test: ; $(MAKE) -e target action=test PROFOPTS=''
target: searchengine server
sandbox:
cabal sandbox init --sandbox .cabal-sandbox
cd hunt-searchengine && cabal sandbox init --sandbox ../.cabal-sandbox
cd hunt-compression && cabal sandbox init --sandbox ../.cabal-sandbox
cd hunt-crawler && cabal sandbox init --sandbox ../.cabal-sandbox
cd hunt-server && cabal sandbox init --sandbox ../.cabal-sandbox
cd hunt-client && cabal sandbox init --sandbox ../.cabal-sandbox
cd hunt-server-cli && cabal sandbox init --sandbox ../.cabal-sandbox
cabal sandbox add-source hunt-searchengine
cabal sandbox add-source hunt-compression
cabal sandbox add-source hunt-crawler
cabal sandbox add-source hunt-client
cabal sandbox add-source hunt-server-cli
cd hunt-demos/geoFrontend && cabal sandbox init --sandbox ../../.cabal-sandbox
cd html-hunter && cabal sandbox init --sandbox ../.cabal-sandbox
compression: sandbox
cd hunt-compression && cabal $(action) $(PROFOPTS) $(pattern)
searchengine: sandbox
cd hunt-searchengine && cabal $(action) $(PROFOPTS) $(pattern)
server: stopServer sandbox
cd hunt-server && cabal $(action) $(PROFOPTS) $(pattern)
client: sandbox
cd hunt-client && cabal $(action) $(PROFOPTS) $(pattern)
hunt-server-cli: sandbox
cd hunt-server-cli && cabal $(action) $(PROFOPTS) $(pattern)
html-hunter: sandbox
cd html-hunter && cabal $(action) $(PROFOPTS) $(pattern)
test:
cd hunt-searchengine && cabal install --enable-tests --enable-library-coverage
cd hunt-searchengine && cabal configure --enable-tests --enable-library-coverage && cabal test
test-strict:
cd hunt-searchengine && cabal install --enable-tests -ftest-strict --enable-library-coverage
cd hunt-searchengine && cabal configure --enable-tests -ftest-strict --enable-library-coverage && cabal test
execTest:
cd hunt-searchengine && cabal test
startServer: stopServer
$(EXE) $(RUNOPTS) &
stopServer:
- killall $(notdir $(EXE)) \
&& sleep 1 # wait for shutdown and socket release
jokes: hunt-test/data/jokes/FussballerSprueche.js
insertJokes: hunt-test/data/jokes/FussballerSprueche.js
curl -X POST -d @hunt-test/data/jokes/contexts.js $(SERVER)/eval
curl -X POST -d @hunt-test/data/jokes/FussballerSprueche.js $(SERVER)/document/insert
hunt-test/data/hayoo/hayoo.index.json:
mkdir -p hunt-test/data/hayoo
cd hunt-test/data/hayoo && curl -O http://hayoo.fh-wedel.de/download/hayoo-tutorial.tar.gz
cd hunt-test/data/hayoo && tar -xf hayoo-tutorial.tar.gz
- cd hunt-test/data/hayoo && rm hayoo-tutorial.tar.gz
insertHayooTest: hunt-test/data/hayoo/hayoo.index.json
curl -X POST -d @hunt-test/data/hayoo/hayoo.index.json $(SERVER)/eval
# NOTE: profiling does not use the makefile target to start the server (RUNOPTS is discarded)
profServer: stopServer
./hunt-server/prof.sh
profServer-fb: stopServer
./hunt-server/prof.sh "make insertJokes"
profServer-rd: stopServer
./hunt-server/prof.sh "make insertRandom"
insertHayoo: ../hayoo/hayooFrontend/functions.js
$(MAKE) -e -C ../hayoo/hayoo-json insert SERVER=$(SERVER)
startHayoo: hayooFrontend/functions.js insertHayoo
cd ../hayoo/hayooFrontend && cabal run &
random:
$(MAKE) -C hunt-test/data/random
generateRandom:
$(MAKE) -e -C hunt-test/data/random cleanData generate
hunt-test/data/random/RandomData.js:
$(MAKE) -e -C hunt-test/data/random generate
hunt-test/data/jokes/FussballerSprueche.js:
$(MAKE) -e -C hunt-test/data/jokes generate
haddock:
cd hunt-searchengine && cabal haddock --hyperlink-source
- cd hunt-searchengine && xdg-open dist/doc/html/hunt-searchengine/index.html
insertRandom: hunt-test/data/random/RandomData.js
curl -X POST -d @hunt-test/data/random/contexts.js $(SERVER)/eval
curl -X POST -d @hunt-test/data/random/RandomData.js $(SERVER)/document/insert
hunt-test/data/dict/en_US.dict.js:
$(MAKE) -e -C hunt-test/data/dict
insertenUSDict: hunt-test/data/dict/en_US.dict.js
curl -X POST -d @hunt-test/data/dict/en_US.dict.js $(SERVER)/eval
# ab - Apache HTTP server benchmarking tool
benchmark-ab:
ab -k -n 1000 -c 20 http://localhost:3000/search/Data.Text/0/100
# siege - http load testing and benchmarking utility
benchmark-siege:
siege -c50 -d10 -t3M -f hunt-test/data/random/urls
# able to read heap profile at runtime
runtimeHeapProfile:
head -`fgrep -n END_SAMPLE hunt-server.hp | tail -1 | cut -d : -f 1` hunt-server.hp | hp2ps -d -c > hunt-server.ps
ps2pdf hunt-server.ps
cabal-%:
cd hunt-searchengine \
&& cabal install $(PROFOPTS) $* --constraint=text\<1
#unused at them moment. used to install non hackag packages directly into the sandbox (eg murmur: github-chrisreu!murmur-hash)
github-%:
git clone https://github.com/$(subst !,/,$*).git tmpgithubdir \
&& ( cd hunt-searchengine && cabal install $(PROFOPTS) ../tmpgithubdir ) \
; rm -rf tmpgithubdir
geo-osm: github-sebastian-philipp!geo-osm
membench:
$(MAKE) -C hunt-test/bench $@
membench-%:
$(MAKE) -C hunt-test/bench $*
bench:
$(MAKE) -C hunt-test/bench $@
bench-%:
$(MAKE) -C hunt-test/bench $@
searchengine-force:
cd hunt-searchengine \
&& cabal install $(PROFOPTS) --reinstall --force-reinstalls
.PHONY: target clean configure build install test all searchengine server insertJokes startServer \
first-install first-install-bs \
stopServer sandbox benchmark-ab benchmark-siege runtimeHeapProfile startServer \
bench bench-* membench membench-* \
profServer profServer-fb profServer-rd
searchengine-force
github-* cabal-*