August Lilleaas
09/24/2022, 6:21 PMclass MyHandler :
RequestHandler<Map<String, String>, String>
{
companion object {
init {
dataSource
println(Intrinsics::class.java)
println(Result::class.java)
println(Session::class.java)
println(::handleUserEmailSearch.toString())
println(Continuation::class.java)
println(Function::class.java)
println(Unit::class.java)
}
}
override fun handleRequest(input: Map<String, String>, context: Context): String {
return serverlessWebResponseDb(dataSource) { dbSess ->
handleUserEmailSearch(dbSess, input["email"])
}
}
}
Big Chungus
09/24/2022, 8:13 PMephemient
09/25/2022, 12:44 AMBig Chungus
09/25/2022, 9:18 AMAugust Lilleaas
09/25/2022, 3:24 PMclass MyHandler :
RequestHandler<Map<String, String>, String>
{
companion object {
init {
runBlocking {
serverlessWebResponseDb(dataSource) { dbSess ->
dbSess.single(queryOf("SELECT 1"), ::mapFromRow)
JsonWebResponse("")
}
}
}
}
override fun handleRequest(
input: Map<String, String>,
context: Context
): String {
return serverlessWebResponseDb(dataSource) { dbSess ->
handleUserEmailSearch(dbSess, input["email"])
}
}
}
That way, most of the code that’s used in the handler, is invoked in the init phase, as a side effect of doing an actual query etc. The code went from spending 600ms on a cold start, to 1300ms. Additionally, it only spends 20ms in the execution phase on a cold start, instead of 5700ms.August Lilleaas
09/25/2022, 3:25 PMAugust Lilleaas
09/25/2022, 3:26 PMephemient
09/25/2022, 5:50 PMephemient
09/25/2022, 5:51 PMAugust Lilleaas
09/25/2022, 5:51 PMephemient
09/25/2022, 5:52 PMAugust Lilleaas
09/25/2022, 5:53 PMAugust Lilleaas
09/25/2022, 5:54 PMAugust Lilleaas
09/25/2022, 5:55 PMAugust Lilleaas
09/25/2022, 5:56 PMephemient
09/25/2022, 5:58 PMephemient
09/25/2022, 5:59 PMAugust Lilleaas
09/25/2022, 6:00 PMAugust Lilleaas
09/25/2022, 6:03 PMAugust Lilleaas
09/25/2022, 6:03 PMephemient
09/25/2022, 6:05 PMAugust Lilleaas
09/25/2022, 6:08 PMAugust Lilleaas
09/25/2022, 6:09 PMAugust Lilleaas
09/25/2022, 6:09 PMAugust Lilleaas
09/25/2022, 6:25 PMephemient
09/25/2022, 6:27 PMBig Chungus
09/25/2022, 6:32 PMAugust Lilleaas
09/25/2022, 6:33 PMBig Chungus
09/25/2022, 6:34 PMPetter Måhlén
09/26/2022, 7:26 AMAugust Lilleaas
09/26/2022, 7:41 AM